From 1478cf7590c7c2f37f6621e7fa5d236382040e3e Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 16:49:19 +0000 Subject: [PATCH] Release 1.3.0 --- package.json | 11 +- src/Client.ts | 1 + src/api/errors/BadRequestError.ts | 1 + src/api/errors/TooManyRequestsError.ts | 1 + src/api/errors/UnauthorizedError.ts | 1 + src/api/index.ts | 2 +- .../businessUserEvents/client/Client.ts | 18 +- .../client/requests/BusinessUserEvent.ts | 2 +- .../resources/businessUsers/client/Client.ts | 14 +- src/api/resources/businessUsers/index.ts | 1 + .../types/BusinessUsersCreateResponse.ts | 2 +- .../resources/businessUsers/types/index.ts | 1 + .../consumerUserEvents/client/Client.ts | 18 +- .../client/requests/ConsumerUserEvent.ts | 2 +- .../resources/consumerUsers/client/Client.ts | 12 +- src/api/resources/consumerUsers/index.ts | 1 + .../types/ConsumerUsersCreateResponse.ts | 2 +- .../resources/consumerUsers/types/index.ts | 1 + src/api/resources/index.ts | 5 +- .../transactionEvents/client/Client.ts | 19 ++- .../resources/transactions/client/Client.ts | 35 ++-- src/api/resources/transactions/index.ts | 1 + .../types/TransactionsVerifyResponse.ts | 2 +- src/api/resources/transactions/types/index.ts | 1 + src/api/types/AchDetails.ts | 7 +- src/api/types/Address.ts | 8 +- src/api/types/Business.ts | 2 +- src/api/types/BusinessBase.ts | 2 +- ...BusinessOptionalSavedPaymentDetailsItem.ts | 56 +++++- src/api/types/BusinessUsersResponse.ts | 2 +- src/api/types/CardDetails.ts | 9 +- src/api/types/CardMerchantDetails.ts | 1 - src/api/types/CaseManagementEvent.ts | 2 +- src/api/types/CheckDetails.ts | 1 - src/api/types/CompanyGeneralDetails.ts | 3 +- src/api/types/CompanyRegistrationDetails.ts | 2 +- src/api/types/ConsumerName.ts | 6 +- src/api/types/ConsumerUsersResponse.ts | 2 +- src/api/types/DeviceData.ts | 14 +- src/api/types/ExecutedRulesResult.ts | 6 +- src/api/types/FailedRulesResult.ts | 6 +- src/api/types/GenericBankAccountDetails.ts | 5 +- src/api/types/HitRulesDetails.ts | 6 +- src/api/types/IbanDetails.ts | 5 +- src/api/types/LegalDocument.ts | 4 +- src/api/types/MpesaDetails.ts | 3 +- src/api/types/PepStatus.ts | 1 - src/api/types/RuleFailureException.ts | 4 +- src/api/types/SwiftDetails.ts | 7 +- src/api/types/Tag.ts | 4 +- src/api/types/TransactionBase.ts | 4 +- src/api/types/TransactionEvent.ts | 2 +- src/api/types/TransactionUpdatable.ts | 2 +- ...ctionUpdatableDestinationPaymentDetails.ts | 56 +++++- ...ransactionUpdatableOriginPaymentDetails.ts | 56 +++++- src/api/types/UpiDetails.ts | 7 +- src/api/types/UserBase.ts | 2 +- src/api/types/WalletDetails.ts | 3 +- src/api/types/WebhookEvent.ts | 2 +- src/api/types/index.ts | 29 ++-- src/core/fetcher/APIResponse.ts | 1 + src/core/fetcher/Fetcher.ts | 109 ++++++++---- src/core/fetcher/getHeader.ts | 8 + src/core/fetcher/index.ts | 1 + src/core/schemas/Schema.ts | 1 + .../builders/literals/booleanLiteral.ts | 29 ++++ src/core/schemas/builders/literals/index.ts | 1 + src/serialization/index.ts | 2 +- .../resources/businessUsers/index.ts | 1 + .../types/BusinessUsersCreateResponse.ts | 8 +- .../resources/businessUsers/types/index.ts | 1 + .../resources/consumerUsers/index.ts | 1 + .../types/ConsumerUsersCreateResponse.ts | 8 +- .../resources/consumerUsers/types/index.ts | 1 + src/serialization/resources/index.ts | 6 + .../resources/transactions/index.ts | 1 + .../types/TransactionsVerifyResponse.ts | 8 +- .../resources/transactions/types/index.ts | 1 + src/serialization/types/AchDetails.ts | 2 - ...BusinessOptionalSavedPaymentDetailsItem.ts | 81 ++++++--- src/serialization/types/CardDetails.ts | 4 +- src/serialization/types/CheckDetails.ts | 2 - .../types/GenericBankAccountDetails.ts | 2 - src/serialization/types/IbanDetails.ts | 2 - src/serialization/types/MpesaDetails.ts | 2 - src/serialization/types/SwiftDetails.ts | 2 - src/serialization/types/TransactionBase.ts | 5 +- ...ctionUpdatableDestinationPaymentDetails.ts | 81 ++++++--- ...ransactionUpdatableOriginPaymentDetails.ts | 81 ++++++--- src/serialization/types/UpiDetails.ts | 2 - src/serialization/types/WalletDetails.ts | 2 - src/serialization/types/WebhookEvent.ts | 5 +- src/serialization/types/index.ts | 29 ++-- yarn.lock | 161 ++++++++++++++++-- 94 files changed, 791 insertions(+), 345 deletions(-) rename src/api/{ => resources/businessUsers}/types/BusinessUsersCreateResponse.ts (82%) create mode 100644 src/api/resources/businessUsers/types/index.ts rename src/api/{ => resources/consumerUsers}/types/ConsumerUsersCreateResponse.ts (82%) create mode 100644 src/api/resources/consumerUsers/types/index.ts rename src/api/{ => resources/transactions}/types/TransactionsVerifyResponse.ts (83%) create mode 100644 src/api/resources/transactions/types/index.ts create mode 100644 src/core/fetcher/getHeader.ts create mode 100644 src/core/schemas/builders/literals/booleanLiteral.ts create mode 100644 src/serialization/resources/businessUsers/index.ts rename src/serialization/{ => resources/businessUsers}/types/BusinessUsersCreateResponse.ts (76%) create mode 100644 src/serialization/resources/businessUsers/types/index.ts create mode 100644 src/serialization/resources/consumerUsers/index.ts rename src/serialization/{ => resources/consumerUsers}/types/ConsumerUsersCreateResponse.ts (76%) create mode 100644 src/serialization/resources/consumerUsers/types/index.ts create mode 100644 src/serialization/resources/transactions/index.ts rename src/serialization/{ => resources/transactions}/types/TransactionsVerifyResponse.ts (76%) create mode 100644 src/serialization/resources/transactions/types/index.ts diff --git a/package.json b/package.json index 835bd4a..daa650d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flagright", - "version": "1.2.1", + "version": "1.3.0", "private": false, "repository": "https://github.com/flagright/flagright-node", "main": "./index.js", @@ -11,12 +11,15 @@ "prepack": "cp -rv dist/. ." }, "dependencies": { - "@ungap/url-search-params": "0.2.2", "url-join": "4.0.1", - "@types/url-join": "4.0.1", - "axios": "0.27.2" + "form-data": "4.0.0", + "node-fetch": "2.7.0", + "qs": "6.11.2" }, "devDependencies": { + "@types/url-join": "4.0.1", + "@types/qs": "6.9.8", + "@types/node-fetch": "2.6.9", "@types/node": "17.0.33", "prettier": "2.7.1", "typescript": "4.6.4" diff --git a/src/Client.ts b/src/Client.ts index 10f1f5c..1f177d7 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -19,6 +19,7 @@ export declare namespace FlagrightClient { interface RequestOptions { timeoutInSeconds?: number; + maxRetries?: number; } } diff --git a/src/api/errors/BadRequestError.ts b/src/api/errors/BadRequestError.ts index a91d8c3..7fefd19 100644 --- a/src/api/errors/BadRequestError.ts +++ b/src/api/errors/BadRequestError.ts @@ -7,6 +7,7 @@ import * as errors from "../../errors"; export class BadRequestError extends errors.FlagrightError { constructor(body?: unknown) { super({ + message: "BadRequestError", statusCode: 400, body: body, }); diff --git a/src/api/errors/TooManyRequestsError.ts b/src/api/errors/TooManyRequestsError.ts index 1b5f925..026e18f 100644 --- a/src/api/errors/TooManyRequestsError.ts +++ b/src/api/errors/TooManyRequestsError.ts @@ -7,6 +7,7 @@ import * as errors from "../../errors"; export class TooManyRequestsError extends errors.FlagrightError { constructor(body?: unknown) { super({ + message: "TooManyRequestsError", statusCode: 429, body: body, }); diff --git a/src/api/errors/UnauthorizedError.ts b/src/api/errors/UnauthorizedError.ts index 59273e2..82a780d 100644 --- a/src/api/errors/UnauthorizedError.ts +++ b/src/api/errors/UnauthorizedError.ts @@ -7,6 +7,7 @@ import * as errors from "../../errors"; export class UnauthorizedError extends errors.FlagrightError { constructor(body?: unknown) { super({ + message: "UnauthorizedError", statusCode: 401, body: body, }); diff --git a/src/api/index.ts b/src/api/index.ts index 1cb55b6..3006072 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,3 +1,3 @@ +export * from "./resources"; export * from "./types"; export * from "./errors"; -export * from "./resources"; diff --git a/src/api/resources/businessUserEvents/client/Client.ts b/src/api/resources/businessUserEvents/client/Client.ts index 8d4c2dd..58b004b 100644 --- a/src/api/resources/businessUserEvents/client/Client.ts +++ b/src/api/resources/businessUserEvents/client/Client.ts @@ -5,7 +5,6 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; import * as Flagright from "../../.."; -import { default as URLSearchParams } from "@ungap/url-search-params"; import * as serializers from "../../../../serialization"; import urlJoin from "url-join"; import * as errors from "../../../../errors"; @@ -18,6 +17,7 @@ export declare namespace BusinessUserEvents { interface RequestOptions { timeoutInSeconds?: number; + maxRetries?: number; } } @@ -31,8 +31,8 @@ export class BusinessUserEvents { * * User events are created after the initial `POST /business/users` call (which creates a user) and are used to: * - * * Update the STATE and KYC Status of the user, using the `userStateDetails` or `kycStatusDetails` field - * * Update the user details, using the `updatedBusinessUserAttributes` field. + * - Update the STATE and KYC Status of the user, using the `userStateDetails` or `kycStatusDetails` field + * - Update the user details, using the `updatedBusinessUserAttributes` field. * * > If you have neither of the above two use cases, you do not need to use user events. * @@ -40,11 +40,10 @@ export class BusinessUserEvents { * * Each user event needs three mandatory fields: * - * * `timestamp`- the timestamp of when the event was created or occured in your system - * * `userId` - The ID of the transaction for which this event is generated. + * - `timestamp`- the timestamp of when the event was created or occured in your system + * - `userId` - The ID of the transaction for which this event is generated. * * In order to make individual events retrievable, you also need to pass in a unique `eventId` to the request body. - * * @throws {@link Flagright.BadRequestError} * @throws {@link Flagright.UnauthorizedError} * @throws {@link Flagright.TooManyRequestsError} @@ -54,9 +53,9 @@ export class BusinessUserEvents { requestOptions?: BusinessUserEvents.RequestOptions ): Promise { const { allowUserTypeConversion, ..._body } = request; - const _queryParams = new URLSearchParams(); + const _queryParams: Record = {}; if (allowUserTypeConversion != null) { - _queryParams.append("allowUserTypeConversion", allowUserTypeConversion); + _queryParams["allowUserTypeConversion"] = allowUserTypeConversion; } const _response = await core.fetcher({ @@ -69,12 +68,13 @@ export class BusinessUserEvents { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", queryParameters: _queryParams, body: await serializers.BusinessUserEvent.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.BusinessWithRulesResult.parseOrThrow(_response.body, { diff --git a/src/api/resources/businessUserEvents/client/requests/BusinessUserEvent.ts b/src/api/resources/businessUserEvents/client/requests/BusinessUserEvent.ts index 141c421..899c370 100644 --- a/src/api/resources/businessUserEvents/client/requests/BusinessUserEvent.ts +++ b/src/api/resources/businessUserEvents/client/requests/BusinessUserEvent.ts @@ -11,7 +11,7 @@ export interface BusinessUserEvent { allowUserTypeConversion?: Flagright.BooleanString; /** Timestamp of the event */ timestamp: number; - /** Transaction ID the event pertains to `non-empty` */ + /** Transaction ID the event pertains to */ userId: string; /** Unique event ID */ eventId?: string; diff --git a/src/api/resources/businessUsers/client/Client.ts b/src/api/resources/businessUsers/client/Client.ts index 2b43f8e..208d57b 100644 --- a/src/api/resources/businessUsers/client/Client.ts +++ b/src/api/resources/businessUsers/client/Client.ts @@ -17,6 +17,7 @@ export declare namespace BusinessUsers { interface RequestOptions { timeoutInSeconds?: number; + maxRetries?: number; } } @@ -32,12 +33,11 @@ export class BusinessUsers { * * ### Payload * - * * Each consumer Business entity needs three mandatory fields: * - * * `userId` - Unique identifier for the user - * * `legalEntity` - Details of the business legal entity (CompanyGeneralDetails, FinancialDetails etc) - only `legalName`in `CompanyGeneralDetails` is mandatory - * * `createdTimestamp` - UNIX timestamp in *milliseconds* for when the User is created in your system + * - `userId` - Unique identifier for the user + * - `legalEntity` - Details of the business legal entity (CompanyGeneralDetails, FinancialDetails etc) - only `legalName`in `CompanyGeneralDetails` is mandatory + * - `createdTimestamp` - UNIX timestamp in _milliseconds_ for when the User is created in your system * @throws {@link Flagright.BadRequestError} * @throws {@link Flagright.UnauthorizedError} * @throws {@link Flagright.TooManyRequestsError} @@ -56,11 +56,12 @@ export class BusinessUsers { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", body: await serializers.Business.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.BusinessUsersCreateResponse.parseOrThrow(_response.body, { @@ -125,10 +126,11 @@ export class BusinessUsers { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.BusinessResponse.parseOrThrow(_response.body, { diff --git a/src/api/resources/businessUsers/index.ts b/src/api/resources/businessUsers/index.ts index 5ec7692..c9240f8 100644 --- a/src/api/resources/businessUsers/index.ts +++ b/src/api/resources/businessUsers/index.ts @@ -1 +1,2 @@ +export * from "./types"; export * from "./client"; diff --git a/src/api/types/BusinessUsersCreateResponse.ts b/src/api/resources/businessUsers/types/BusinessUsersCreateResponse.ts similarity index 82% rename from src/api/types/BusinessUsersCreateResponse.ts rename to src/api/resources/businessUsers/types/BusinessUsersCreateResponse.ts index 92e586e..8fcfcd8 100644 --- a/src/api/types/BusinessUsersCreateResponse.ts +++ b/src/api/resources/businessUsers/types/BusinessUsersCreateResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from ".."; +import * as Flagright from "../../.."; export interface BusinessUsersCreateResponse extends Flagright.BusinessUsersResponse { message?: string; diff --git a/src/api/resources/businessUsers/types/index.ts b/src/api/resources/businessUsers/types/index.ts new file mode 100644 index 0000000..0d5b65d --- /dev/null +++ b/src/api/resources/businessUsers/types/index.ts @@ -0,0 +1 @@ +export * from "./BusinessUsersCreateResponse"; diff --git a/src/api/resources/consumerUserEvents/client/Client.ts b/src/api/resources/consumerUserEvents/client/Client.ts index 1f4e047..42a5653 100644 --- a/src/api/resources/consumerUserEvents/client/Client.ts +++ b/src/api/resources/consumerUserEvents/client/Client.ts @@ -5,7 +5,6 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; import * as Flagright from "../../.."; -import { default as URLSearchParams } from "@ungap/url-search-params"; import * as serializers from "../../../../serialization"; import urlJoin from "url-join"; import * as errors from "../../../../errors"; @@ -18,6 +17,7 @@ export declare namespace ConsumerUserEvents { interface RequestOptions { timeoutInSeconds?: number; + maxRetries?: number; } } @@ -31,8 +31,8 @@ export class ConsumerUserEvents { * * User events are created after the initial `POST /consumer/users` call (which creates a user) and are used to: * - * * Update the STATE and KYC Status of the user, using the `userStateDetails` or `kycStatusDetails` field - * * Update the user details, using the `updatedConsumerUserAttributes` field. + * - Update the STATE and KYC Status of the user, using the `userStateDetails` or `kycStatusDetails` field + * - Update the user details, using the `updatedConsumerUserAttributes` field. * * > If you have neither of the above two use cases, you do not need to use user events. * @@ -40,11 +40,10 @@ export class ConsumerUserEvents { * * Each user event needs three mandatory fields: * - * * `timestamp`- the timestamp of when the event was created or occured in your system - * * `userId` - The ID of the transaction for which this event is generated. + * - `timestamp`- the timestamp of when the event was created or occured in your system + * - `userId` - The ID of the transaction for which this event is generated. * * In order to make individual events retrievable, you also need to pass in a unique `eventId` to the request body. - * * @throws {@link Flagright.BadRequestError} * @throws {@link Flagright.UnauthorizedError} * @throws {@link Flagright.TooManyRequestsError} @@ -54,9 +53,9 @@ export class ConsumerUserEvents { requestOptions?: ConsumerUserEvents.RequestOptions ): Promise { const { allowUserTypeConversion, ..._body } = request; - const _queryParams = new URLSearchParams(); + const _queryParams: Record = {}; if (allowUserTypeConversion != null) { - _queryParams.append("allowUserTypeConversion", allowUserTypeConversion); + _queryParams["allowUserTypeConversion"] = allowUserTypeConversion; } const _response = await core.fetcher({ @@ -69,12 +68,13 @@ export class ConsumerUserEvents { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", queryParameters: _queryParams, body: await serializers.ConsumerUserEvent.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.UserWithRulesResult.parseOrThrow(_response.body, { diff --git a/src/api/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts b/src/api/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts index 0d077a6..1607ef6 100644 --- a/src/api/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts +++ b/src/api/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts @@ -11,7 +11,7 @@ export interface ConsumerUserEvent { allowUserTypeConversion?: Flagright.BooleanString; /** Timestamp of the event */ timestamp: number; - /** Transaction ID the event pertains to `non-empty` */ + /** Transaction ID the event pertains to */ userId: string; /** Unique event ID */ eventId?: string; diff --git a/src/api/resources/consumerUsers/client/Client.ts b/src/api/resources/consumerUsers/client/Client.ts index f2417c7..99592a0 100644 --- a/src/api/resources/consumerUsers/client/Client.ts +++ b/src/api/resources/consumerUsers/client/Client.ts @@ -17,6 +17,7 @@ export declare namespace ConsumerUsers { interface RequestOptions { timeoutInSeconds?: number; + maxRetries?: number; } } @@ -34,9 +35,8 @@ export class ConsumerUsers { * * Each consumer User entity needs three mandatory fields: * - * * `userId` - Unique identifier for the user - * * `createdTimestamp` - UNIX timestamp in *milliseconds* for when the User is created in your system - * + * - `userId` - Unique identifier for the user + * - `createdTimestamp` - UNIX timestamp in _milliseconds_ for when the User is created in your system * @throws {@link Flagright.BadRequestError} * @throws {@link Flagright.UnauthorizedError} * @throws {@link Flagright.TooManyRequestsError} @@ -55,11 +55,12 @@ export class ConsumerUsers { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", body: await serializers.User.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.ConsumerUsersCreateResponse.parseOrThrow(_response.body, { @@ -121,10 +122,11 @@ export class ConsumerUsers { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { diff --git a/src/api/resources/consumerUsers/index.ts b/src/api/resources/consumerUsers/index.ts index 5ec7692..c9240f8 100644 --- a/src/api/resources/consumerUsers/index.ts +++ b/src/api/resources/consumerUsers/index.ts @@ -1 +1,2 @@ +export * from "./types"; export * from "./client"; diff --git a/src/api/types/ConsumerUsersCreateResponse.ts b/src/api/resources/consumerUsers/types/ConsumerUsersCreateResponse.ts similarity index 82% rename from src/api/types/ConsumerUsersCreateResponse.ts rename to src/api/resources/consumerUsers/types/ConsumerUsersCreateResponse.ts index f5dc1b6..da3b99b 100644 --- a/src/api/types/ConsumerUsersCreateResponse.ts +++ b/src/api/resources/consumerUsers/types/ConsumerUsersCreateResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from ".."; +import * as Flagright from "../../.."; export interface ConsumerUsersCreateResponse extends Flagright.ConsumerUsersResponse { message?: string; diff --git a/src/api/resources/consumerUsers/types/index.ts b/src/api/resources/consumerUsers/types/index.ts new file mode 100644 index 0000000..23b3635 --- /dev/null +++ b/src/api/resources/consumerUsers/types/index.ts @@ -0,0 +1 @@ +export * from "./ConsumerUsersCreateResponse"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index b714505..8657cc1 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -1,7 +1,10 @@ export * as transactions from "./transactions"; -export * as transactionEvents from "./transactionEvents"; +export * from "./transactions/types"; export * as consumerUsers from "./consumerUsers"; +export * from "./consumerUsers/types"; export * as businessUsers from "./businessUsers"; +export * from "./businessUsers/types"; +export * as transactionEvents from "./transactionEvents"; export * as consumerUserEvents from "./consumerUserEvents"; export * as businessUserEvents from "./businessUserEvents"; export * from "./transactions/client/requests"; diff --git a/src/api/resources/transactionEvents/client/Client.ts b/src/api/resources/transactionEvents/client/Client.ts index ff1a80a..0b39fe5 100644 --- a/src/api/resources/transactionEvents/client/Client.ts +++ b/src/api/resources/transactionEvents/client/Client.ts @@ -17,6 +17,7 @@ export declare namespace TransactionEvents { interface RequestOptions { timeoutInSeconds?: number; + maxRetries?: number; } } @@ -30,8 +31,8 @@ export class TransactionEvents { * * Transaction events are created after the initial `POST /transactions` call (which creates a transaction) and are used to: * - * * Update the STATE of the transaction, using the `transactionState` field and manage the [Transaction Lifecycle](https://docs.flagright.com/docs/flagright-api/0f8fac59d1995-entities-and-relationships#transaction-lifecycle-through-transaction-events) - * * Update the transaction details, using the `updatedTransactionAttributes` field. + * - Update the STATE of the transaction, using the `transactionState` field and manage the [Transaction Lifecycle](https://docs.flagright.com/docs/flagright-api/0f8fac59d1995-entities-and-relationships#transaction-lifecycle-through-transaction-events) + * - Update the transaction details, using the `updatedTransactionAttributes` field. * * > If you have neither of the above two use cases, you do not need to use transaction events. * @@ -39,12 +40,11 @@ export class TransactionEvents { * * Each transaction event needs three mandatory fields: * - * * `transactionState` - STATE of the transaction -> value is set to `CREATED` after `POST /transactions` call - * * `timestamp`- the timestamp of when the event was created or occured in your system - * * `transactionId` - The ID of the transaction for which this event is generated. + * - `transactionState` - STATE of the transaction -> value is set to `CREATED` after `POST /transactions` call + * - `timestamp`- the timestamp of when the event was created or occured in your system + * - `transactionId` - The ID of the transaction for which this event is generated. * * In order to make individual events retrievable, you also need to pass in a unique `eventId` to the request body. - * * @throws {@link Flagright.BadRequestError} * @throws {@link Flagright.UnauthorizedError} * @throws {@link Flagright.TooManyRequestsError} @@ -63,11 +63,12 @@ export class TransactionEvents { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", body: await serializers.TransactionEvent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.TransactionEventMonitoringResult.parseOrThrow(_response.body, { @@ -115,7 +116,6 @@ export class TransactionEvents { * `/events/transaction` endpoint allows you to operate on the [Transaction Events entity.](https://docs.flagright.com/docs/flagright-api/0f8fac59d1995-entities-and-relationships#transaction-event). * * You can retrieve any transaction event you create using the [POST Transaction Events](https://docs.flagright.com/docs/flagright-api/d7c4dc4d02850-create-a-transaction-event) call. - * * @throws {@link Flagright.UnauthorizedError} * @throws {@link Flagright.TooManyRequestsError} */ @@ -133,10 +133,11 @@ export class TransactionEvents { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.TransactionEvent.parseOrThrow(_response.body, { diff --git a/src/api/resources/transactions/client/Client.ts b/src/api/resources/transactions/client/Client.ts index be1103a..0183e37 100644 --- a/src/api/resources/transactions/client/Client.ts +++ b/src/api/resources/transactions/client/Client.ts @@ -5,7 +5,6 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; import * as Flagright from "../../.."; -import { default as URLSearchParams } from "@ungap/url-search-params"; import * as serializers from "../../../../serialization"; import urlJoin from "url-join"; import * as errors from "../../../../errors"; @@ -18,6 +17,7 @@ export declare namespace Transactions { interface RequestOptions { timeoutInSeconds?: number; + maxRetries?: number; } } @@ -31,21 +31,20 @@ export class Transactions { * * In order to pass the payload of a transaction to Flagright and verify the transaciton, you will need to call this endpoint with the transaction payload. Not all fields are mandatory, you will only need to pass in the fields that you have and are relevant for your compliance setup. * - * * ### Payload * * Here are some of the most used payload fields explained (you can find the full payload [schema below](https://docs.flagright.com/docs/flagright-api/87742ed31b30e-verify-a-transaction#request-body) with 1 line descriptions): * - * * `type`: Type of transaction (Ex: `WITHDRAWAL`, `DEPOSIT`, `TRANSFER` etc). - * * `transactionId` - Unique Identifier for the transaction. Flagright API will generate a `transactionId` if this field is left empty - * * `timestamp` - UNIX timestamp in *milliseconds* of when the transaction took place - * * `transactionState` - The state of the transaction, set to `CREATED` by default. [More details here](https://docs.flagright.com/docs/flagright-api/0f8fac59d1995-entities-and-relationships-in-the-api#transaction-lifecycle-through-transaction-events) - * * `originUserId` - Unique identifier (if any) of the user who is sending the money. This user must be created within the Flagright system before using the [create a consumer user](https://docs.flagright.com/docs/flagright-api/18132cd454603-create-a-consumer-user) or [create a business user](https://docs.flagright.com/docs/flagright-api/f651463db29d8-create-a-business-user) endpoint - * * `destinationUserId` - Unique identifier (if any) of the user who is receiving the money. This user must be created within the Flagright system before using the [create a consumer user](https://docs.flagright.com/docs/flagright-api/18132cd454603-create-a-consumer-user) or [create a business user](https://docs.flagright.com/docs/flagright-api/f651463db29d8-create-a-business-user) endpoint - * * `originAmountDetails` - Details of the amount being sent from the origin - * * `destinationAmountDetails` - Details of the amount being received at the destination - * * `originPaymentDetails` - Payment details (if any) used at the origin (ex: `CARD`, `IBAN`, `WALLET` etc). You can click on the dropdown next to the field in the schema below to view all supported payment types. - * * `destinationPaymentDetails` - Payment details (if any) used at the destination (ex: `CARD`, `IBAN`, `WALLET` etc). You can click on the dropdown next to the field in the schema below to view all supported payment types. + * - `type`: Type of transaction (Ex: `WITHDRAWAL`, `DEPOSIT`, `TRANSFER` etc). + * - `transactionId` - Unique Identifier for the transaction. Flagright API will generate a `transactionId` if this field is left empty + * - `timestamp` - UNIX timestamp in _milliseconds_ of when the transaction took place + * - `transactionState` - The state of the transaction, set to `CREATED` by default. [More details here](https://docs.flagright.com/docs/flagright-api/0f8fac59d1995-entities-and-relationships-in-the-api#transaction-lifecycle-through-transaction-events) + * - `originUserId` - Unique identifier (if any) of the user who is sending the money. This user must be created within the Flagright system before using the [create a consumer user](https://docs.flagright.com/docs/flagright-api/18132cd454603-create-a-consumer-user) or [create a business user](https://docs.flagright.com/docs/flagright-api/f651463db29d8-create-a-business-user) endpoint + * - `destinationUserId` - Unique identifier (if any) of the user who is receiving the money. This user must be created within the Flagright system before using the [create a consumer user](https://docs.flagright.com/docs/flagright-api/18132cd454603-create-a-consumer-user) or [create a business user](https://docs.flagright.com/docs/flagright-api/f651463db29d8-create-a-business-user) endpoint + * - `originAmountDetails` - Details of the amount being sent from the origin + * - `destinationAmountDetails` - Details of the amount being received at the destination + * - `originPaymentDetails` - Payment details (if any) used at the origin (ex: `CARD`, `IBAN`, `WALLET` etc). You can click on the dropdown next to the field in the schema below to view all supported payment types. + * - `destinationPaymentDetails` - Payment details (if any) used at the destination (ex: `CARD`, `IBAN`, `WALLET` etc). You can click on the dropdown next to the field in the schema below to view all supported payment types. * @throws {@link Flagright.BadRequestError} * @throws {@link Flagright.UnauthorizedError} * @throws {@link Flagright.TooManyRequestsError} @@ -55,13 +54,13 @@ export class Transactions { requestOptions?: Transactions.RequestOptions ): Promise { const { validateOriginUserId, validateDestinationUserId, body: _body } = request; - const _queryParams = new URLSearchParams(); + const _queryParams: Record = {}; if (validateOriginUserId != null) { - _queryParams.append("validateOriginUserId", validateOriginUserId); + _queryParams["validateOriginUserId"] = validateOriginUserId; } if (validateDestinationUserId != null) { - _queryParams.append("validateDestinationUserId", validateDestinationUserId); + _queryParams["validateDestinationUserId"] = validateDestinationUserId; } const _response = await core.fetcher({ @@ -74,12 +73,13 @@ export class Transactions { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", queryParameters: _queryParams, body: await serializers.Transaction.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.TransactionsVerifyResponse.parseOrThrow(_response.body, { @@ -144,10 +144,11 @@ export class Transactions { "x-api-key": await core.Supplier.get(this._options.apiKey), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "1.2.1", + "X-Fern-SDK-Version": "1.3.0", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, }); if (_response.ok) { return await serializers.TransactionWithRulesResult.parseOrThrow(_response.body, { diff --git a/src/api/resources/transactions/index.ts b/src/api/resources/transactions/index.ts index 5ec7692..c9240f8 100644 --- a/src/api/resources/transactions/index.ts +++ b/src/api/resources/transactions/index.ts @@ -1 +1,2 @@ +export * from "./types"; export * from "./client"; diff --git a/src/api/types/TransactionsVerifyResponse.ts b/src/api/resources/transactions/types/TransactionsVerifyResponse.ts similarity index 83% rename from src/api/types/TransactionsVerifyResponse.ts rename to src/api/resources/transactions/types/TransactionsVerifyResponse.ts index b3bc962..9f36aa2 100644 --- a/src/api/types/TransactionsVerifyResponse.ts +++ b/src/api/resources/transactions/types/TransactionsVerifyResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from ".."; +import * as Flagright from "../../.."; export interface TransactionsVerifyResponse extends Flagright.TransactionMonitoringResult { message?: string; diff --git a/src/api/resources/transactions/types/index.ts b/src/api/resources/transactions/types/index.ts new file mode 100644 index 0000000..eca88f9 --- /dev/null +++ b/src/api/resources/transactions/types/index.ts @@ -0,0 +1 @@ +export * from "./TransactionsVerifyResponse"; diff --git a/src/api/types/AchDetails.ts b/src/api/types/AchDetails.ts index 3e2c213..1142fe1 100644 --- a/src/api/types/AchDetails.ts +++ b/src/api/types/AchDetails.ts @@ -8,12 +8,11 @@ import * as Flagright from ".."; * Model for ACH payment method */ export interface AchDetails { - method: Flagright.AchPaymentMethod; - /** Routing number of the bank `non-empty` */ + /** Routing number of the bank */ routingNumber?: string; - /** Bank account number of the individual `non-empty` */ + /** Bank account number of the individual */ accountNumber?: string; - /** Name of the bank `non-empty` */ + /** Name of the bank */ bankName?: string; /** Name of the account holder */ name?: string; diff --git a/src/api/types/Address.ts b/src/api/types/Address.ts index 9901060..bbc01e1 100644 --- a/src/api/types/Address.ts +++ b/src/api/types/Address.ts @@ -10,13 +10,13 @@ import * as Flagright from ".."; export interface Address { /** Address lines of the user's residence address */ addressLines: unknown[]; - /** Post code of the user's residence address `non-empty` */ + /** Post code of the user's residence address */ postcode?: string; - /** City of the user's residence address `non-empty` */ + /** City of the user's residence address */ city: string; - /** State of the user's residence address `non-empty` */ + /** State of the user's residence address */ state?: string; - /** User's country of residence `non-empty` */ + /** User's country of residence */ country: string; /** Additional information that can be added via tags */ tags?: Flagright.Tag[]; diff --git a/src/api/types/Business.ts b/src/api/types/Business.ts index 8dba7e6..470c9cd 100644 --- a/src/api/types/Business.ts +++ b/src/api/types/Business.ts @@ -5,7 +5,7 @@ import * as Flagright from ".."; export interface Business { - /** Unique user ID for the user `non-empty` */ + /** Unique user ID for the user */ userId: string; /** Timestamp when the user was created */ createdTimestamp: number; diff --git a/src/api/types/BusinessBase.ts b/src/api/types/BusinessBase.ts index fd606b3..fcc5d43 100644 --- a/src/api/types/BusinessBase.ts +++ b/src/api/types/BusinessBase.ts @@ -8,7 +8,7 @@ import * as Flagright from ".."; * Model for a business user base fields */ export interface BusinessBase { - /** Unique user ID for the user `non-empty` */ + /** Unique user ID for the user */ userId: string; /** Timestamp when the user was created */ createdTimestamp: number; diff --git a/src/api/types/BusinessOptionalSavedPaymentDetailsItem.ts b/src/api/types/BusinessOptionalSavedPaymentDetailsItem.ts index 6271ff2..e200907 100644 --- a/src/api/types/BusinessOptionalSavedPaymentDetailsItem.ts +++ b/src/api/types/BusinessOptionalSavedPaymentDetailsItem.ts @@ -5,12 +5,50 @@ import * as Flagright from ".."; export type BusinessOptionalSavedPaymentDetailsItem = - | Flagright.CardDetails - | Flagright.GenericBankAccountDetails - | Flagright.IbanDetails - | Flagright.AchDetails - | Flagright.SwiftDetails - | Flagright.MpesaDetails - | Flagright.UpiDetails - | Flagright.WalletDetails - | Flagright.CheckDetails; + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Card + | Flagright.BusinessOptionalSavedPaymentDetailsItem.GenericBankAccount + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Iban + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Ach + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Swift + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Mpesa + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Upi + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Wallet + | Flagright.BusinessOptionalSavedPaymentDetailsItem.Check; + +export declare namespace BusinessOptionalSavedPaymentDetailsItem { + interface Card extends Flagright.CardDetails { + method: "CARD"; + } + + interface GenericBankAccount extends Flagright.GenericBankAccountDetails { + method: "GENERIC_BANK_ACCOUNT"; + } + + interface Iban extends Flagright.IbanDetails { + method: "IBAN"; + } + + interface Ach extends Flagright.AchDetails { + method: "ACH"; + } + + interface Swift extends Flagright.SwiftDetails { + method: "SWIFT"; + } + + interface Mpesa extends Flagright.MpesaDetails { + method: "MPESA"; + } + + interface Upi extends Flagright.UpiDetails { + method: "UPI"; + } + + interface Wallet extends Flagright.WalletDetails { + method: "WALLET"; + } + + interface Check extends Flagright.CheckDetails { + method: "CHECK"; + } +} diff --git a/src/api/types/BusinessUsersResponse.ts b/src/api/types/BusinessUsersResponse.ts index 0467cae..9956722 100644 --- a/src/api/types/BusinessUsersResponse.ts +++ b/src/api/types/BusinessUsersResponse.ts @@ -8,7 +8,7 @@ import * as Flagright from ".."; * Model for business user risk score response */ export interface BusinessUsersResponse { - /** user ID the risk score pertains to `non-empty` */ + /** user ID the risk score pertains to */ userId: string; riskScoreDetails?: Flagright.RiskScoreDetails; hitRules?: Flagright.HitRulesDetails[]; diff --git a/src/api/types/CardDetails.ts b/src/api/types/CardDetails.ts index 5a3b2c9..8d8db7c 100644 --- a/src/api/types/CardDetails.ts +++ b/src/api/types/CardDetails.ts @@ -8,17 +8,16 @@ import * as Flagright from ".."; * Model for credit or debit card details */ export interface CardDetails { - method: Flagright.CardPaymentMethod; - /** Unique card fingerprint that helps identify a specific card without having to use explicit card number. This is likely available at your card payment scheme provider `non-empty` */ + /** Unique card fingerprint that helps identify a specific card without having to use explicit card number. This is likely available at your card payment scheme provider */ cardFingerprint?: string; cardIssuedCountry?: Flagright.CountryCode; - /** Reference for the transaction `non-empty` */ + /** Reference for the transaction */ transactionReferenceField?: string; /** Whether 3ds was successfully enforced for the transaction */ - _3DsDone?: boolean; + "3DsDone"?: boolean; nameOnCard?: Flagright.ConsumerName; cardExpiry?: Flagright.CardExpiry; - /** Last 4 digits of Card `<= 4 characters` */ + /** Last 4 digits of Card */ cardLast4Digits?: string; /** Brand of Card */ cardBrand?: Flagright.CardDetailsCardBrand; diff --git a/src/api/types/CardMerchantDetails.ts b/src/api/types/CardMerchantDetails.ts index 97b4755..26c2850 100644 --- a/src/api/types/CardMerchantDetails.ts +++ b/src/api/types/CardMerchantDetails.ts @@ -7,7 +7,6 @@ export interface CardMerchantDetails { category?: string; mcc?: string; city?: string; - /** `<= 2 characters` */ country?: string; state?: string; postCode?: string; diff --git a/src/api/types/CaseManagementEvent.ts b/src/api/types/CaseManagementEvent.ts index eba5ef7..0e872fb 100644 --- a/src/api/types/CaseManagementEvent.ts +++ b/src/api/types/CaseManagementEvent.ts @@ -14,7 +14,7 @@ export interface CaseManagementEvent { timestamp: number; /** Case status reason. E.g. Closed & False Positive, Closed & Investigation Completed etc. */ caseStatusReason: Flagright.CaseManagementEventCaseStatusReason; - /** Transaction ID the case pertains to `non-empty` */ + /** Transaction ID the case pertains to */ transactionId?: string; /** User ID the case pertains to */ userId?: string; diff --git a/src/api/types/CheckDetails.ts b/src/api/types/CheckDetails.ts index f4cddee..ac97b21 100644 --- a/src/api/types/CheckDetails.ts +++ b/src/api/types/CheckDetails.ts @@ -5,7 +5,6 @@ import * as Flagright from ".."; export interface CheckDetails { - method: Flagright.CheckPaymentMethod; checkNumber?: string; checkIdentifier?: string; name?: string; diff --git a/src/api/types/CompanyGeneralDetails.ts b/src/api/types/CompanyGeneralDetails.ts index 0dc6f9a..47b9732 100644 --- a/src/api/types/CompanyGeneralDetails.ts +++ b/src/api/types/CompanyGeneralDetails.ts @@ -8,12 +8,13 @@ import * as Flagright from ".."; * Model for business user company general details */ export interface CompanyGeneralDetails { - /** Legal name of the company `non-empty` */ + /** Legal name of the company */ legalName: string; /** The industry the business operates in for a business customer */ businessIndustry?: string[]; /** The key products and services provided by the company */ mainProductsServicesSold?: string[]; + /** Segmentation of the business user */ userSegment?: Flagright.BusinessUserSegment; userRegistrationStatus?: Flagright.UserRegistrationStatus; /** Additional information that can be added via tags */ diff --git a/src/api/types/CompanyRegistrationDetails.ts b/src/api/types/CompanyRegistrationDetails.ts index 8a2d5fe..1835e38 100644 --- a/src/api/types/CompanyRegistrationDetails.ts +++ b/src/api/types/CompanyRegistrationDetails.ts @@ -8,7 +8,7 @@ import * as Flagright from ".."; * Model for business user company registration details */ export interface CompanyRegistrationDetails { - /** Commercial registry registration number for the company in its registration country `non-empty` */ + /** Commercial registry registration number for the company in its registration country */ registrationIdentifier: string; registrationCountry: Flagright.CountryCode; /** Tax ID number of the registered entity */ diff --git a/src/api/types/ConsumerName.ts b/src/api/types/ConsumerName.ts index d743480..11f7bb5 100644 --- a/src/api/types/ConsumerName.ts +++ b/src/api/types/ConsumerName.ts @@ -6,10 +6,10 @@ * Model for a generic consumer name */ export interface ConsumerName { - /** First name of the user `non-empty` */ + /** First name of the user */ firstName: string; - /** Middle name of the user `non-empty` */ + /** Middle name of the user */ middleName?: string; - /** Last name of the user `non-empty` */ + /** Last name of the user */ lastName?: string; } diff --git a/src/api/types/ConsumerUsersResponse.ts b/src/api/types/ConsumerUsersResponse.ts index 6bdba82..7c20e87 100644 --- a/src/api/types/ConsumerUsersResponse.ts +++ b/src/api/types/ConsumerUsersResponse.ts @@ -8,7 +8,7 @@ import * as Flagright from ".."; * Model for consumer user risk score response */ export interface ConsumerUsersResponse { - /** user ID the risk score pertains to `non-empty` */ + /** user ID the risk score pertains to */ userId: string; riskScoreDetails?: Flagright.RiskScoreDetails; hitRules?: Flagright.HitRulesDetails[]; diff --git a/src/api/types/DeviceData.ts b/src/api/types/DeviceData.ts index e2f47d6..3145f4a 100644 --- a/src/api/types/DeviceData.ts +++ b/src/api/types/DeviceData.ts @@ -12,20 +12,20 @@ export interface DeviceData { deviceLatitude?: number; /** Device longitude at a give timestamp for an event or transaction */ deviceLongitude?: number; - /** IP address of the device at a given timestamp for an event or transaction `non-empty` */ + /** IP address of the device at a given timestamp for an event or transaction */ ipAddress?: string; - /** Device identifier number `non-empty` */ + /** Device identifier number */ deviceIdentifier?: string; /** Whether VPN was used at a given timestamp for an event or transaction */ vpnUsed?: boolean; - /** Operating system of the device at a given timestamp for an event or transaction `non-empty` */ + /** Operating system of the device at a given timestamp for an event or transaction */ operatingSystem?: string; - /** The maker of the device at a given timestamp for an event or transaction `non-empty` */ + /** The maker of the device at a given timestamp for an event or transaction */ deviceMaker?: string; - /** The model of the device at a given timestamp for an event or transaction `non-empty` */ + /** The model of the device at a given timestamp for an event or transaction */ deviceModel?: string; - /** The year the device was manufactured at a given timestamp for an event or transaction `non-empty` */ + /** The year the device was manufactured at a given timestamp for an event or transaction */ deviceYear?: string; - /** The version of the app your user is using on their device at a given timestamp for an event or transaction `non-empty` */ + /** The version of the app your user is using on their device at a given timestamp for an event or transaction */ appVersion?: string; } diff --git a/src/api/types/ExecutedRulesResult.ts b/src/api/types/ExecutedRulesResult.ts index 06c0e12..061fbb5 100644 --- a/src/api/types/ExecutedRulesResult.ts +++ b/src/api/types/ExecutedRulesResult.ts @@ -8,12 +8,12 @@ import * as Flagright from ".."; * Model for list of executed rules */ export interface ExecutedRulesResult { - /** Unique rule identifier `non-empty` */ + /** Unique rule identifier */ ruleId: string; ruleInstanceId: string; - /** Name of the rule `non-empty` */ + /** Name of the rule */ ruleName: string; - /** Description of the rule `non-empty` */ + /** Description of the rule */ ruleDescription: string; ruleAction: Flagright.RuleAction; ruleHit: boolean; diff --git a/src/api/types/FailedRulesResult.ts b/src/api/types/FailedRulesResult.ts index f738d53..bde44ad 100644 --- a/src/api/types/FailedRulesResult.ts +++ b/src/api/types/FailedRulesResult.ts @@ -8,11 +8,11 @@ import * as Flagright from ".."; * Model for list of rules failed execution. It means rules could not be run */ export interface FailedRulesResult { - /** Unique rule identifier `non-empty` */ + /** Unique rule identifier */ ruleId: string; - /** Name of the rule `non-empty` */ + /** Name of the rule */ ruleName: string; - /** Description of the rule `non-empty` */ + /** Description of the rule */ ruleDescription: string; failureException: Flagright.RuleFailureException; } diff --git a/src/api/types/GenericBankAccountDetails.ts b/src/api/types/GenericBankAccountDetails.ts index ce4063a..40e3583 100644 --- a/src/api/types/GenericBankAccountDetails.ts +++ b/src/api/types/GenericBankAccountDetails.ts @@ -8,12 +8,11 @@ import * as Flagright from ".."; * Model for any generic bank account */ export interface GenericBankAccountDetails { - method: Flagright.GeneralBankAccountPaymentMethod; - /** Bank account number `non-empty` */ + /** Bank account number */ accountNumber?: string; /** Bank account type. E.g. Checking, Savings etc. */ accountType?: string; - /** Name of the bank `non-empty` */ + /** Name of the bank */ bankName?: string; /** Unique identifier of the bank. In some countries, this can be the same as the bank's SWIFT code */ bankCode?: string; diff --git a/src/api/types/HitRulesDetails.ts b/src/api/types/HitRulesDetails.ts index 6ed68ed..5e9fcc2 100644 --- a/src/api/types/HitRulesDetails.ts +++ b/src/api/types/HitRulesDetails.ts @@ -8,12 +8,12 @@ import * as Flagright from ".."; * Model for list of hit rules */ export interface HitRulesDetails { - /** Unique rule identifier `non-empty` */ + /** Unique rule identifier */ ruleId: string; ruleInstanceId: string; - /** Name of the rule `non-empty` */ + /** Name of the rule */ ruleName: string; - /** Description of the rule `non-empty` */ + /** Description of the rule */ ruleDescription: string; ruleAction: Flagright.RuleAction; ruleHitMeta?: Flagright.RuleHitMeta; diff --git a/src/api/types/IbanDetails.ts b/src/api/types/IbanDetails.ts index b5b34d1..5c9f920 100644 --- a/src/api/types/IbanDetails.ts +++ b/src/api/types/IbanDetails.ts @@ -8,10 +8,9 @@ import * as Flagright from ".."; * Standardized model for Bank Details */ export interface IbanDetails { - method: Flagright.IbanPaymentMethod; - /** Identifier for the bank. Can be routing number, BIK number, SWIFT code, BIC number etc. `non-empty` */ + /** Identifier for the bank. Can be routing number, BIK number, SWIFT code, BIC number etc. */ bic?: string; - /** Name of the bank `non-empty` */ + /** Name of the bank */ bankName?: string; bankAddress?: Flagright.Address; country?: Flagright.CountryCode; diff --git a/src/api/types/LegalDocument.ts b/src/api/types/LegalDocument.ts index 7a8bea6..2eb9094 100644 --- a/src/api/types/LegalDocument.ts +++ b/src/api/types/LegalDocument.ts @@ -8,9 +8,9 @@ import * as Flagright from ".."; * LegalDocument model generalizes User's identity document type (ex: Passport) */ export interface LegalDocument { - /** User's identity document type such as passport, national ID etc. `non-empty` */ + /** User's identity document type such as passport, national ID etc. */ documentType: string; - /** User's unique identity document number such as passport number `non-empty` */ + /** User's unique identity document number such as passport number */ documentNumber: string; /** User's identity document issuance date (UNIX timestamp in milliseconds) */ documentIssuedDate?: number; diff --git a/src/api/types/MpesaDetails.ts b/src/api/types/MpesaDetails.ts index a911e60..749bcb1 100644 --- a/src/api/types/MpesaDetails.ts +++ b/src/api/types/MpesaDetails.ts @@ -8,8 +8,7 @@ import * as Flagright from ".."; * Model for Mpesa payment method */ export interface MpesaDetails { - method: Flagright.MpesaPaymentMethod; - /** Business code `non-empty` */ + /** Business code */ businessShortCode: string; /** Type of transaction */ transactionType: Flagright.MpesaDetailsTransactionType; diff --git a/src/api/types/PepStatus.ts b/src/api/types/PepStatus.ts index d9b7989..998e07d 100644 --- a/src/api/types/PepStatus.ts +++ b/src/api/types/PepStatus.ts @@ -4,6 +4,5 @@ export interface PepStatus { isPepHit: boolean; - /** `<= 2 characters` */ pepCountry?: string; } diff --git a/src/api/types/RuleFailureException.ts b/src/api/types/RuleFailureException.ts index 0541a52..164413b 100644 --- a/src/api/types/RuleFailureException.ts +++ b/src/api/types/RuleFailureException.ts @@ -3,8 +3,8 @@ */ export interface RuleFailureException { - /** Unique rule identifier `non-empty` */ + /** Unique rule identifier */ exceptionName: string; - /** Name of the rule `non-empty` */ + /** Name of the rule */ exceptionDescription: string; } diff --git a/src/api/types/SwiftDetails.ts b/src/api/types/SwiftDetails.ts index 19e5daf..1fd6297 100644 --- a/src/api/types/SwiftDetails.ts +++ b/src/api/types/SwiftDetails.ts @@ -8,14 +8,13 @@ import * as Flagright from ".."; * Model for SWIFT payment method */ export interface SwiftDetails { - method: Flagright.SwiftPaymentMethod; - /** SWIFT code of the financial institution `non-empty` */ + /** SWIFT code of the financial institution */ swiftCode?: string; - /** Account number `non-empty` */ + /** Account number */ accountNumber?: string; /** Account type. E.g. Checking, Savings etc. */ accountType?: string; - /** Name of the bank `non-empty` */ + /** Name of the bank */ bankName?: string; /** Name of the account holder */ name?: string; diff --git a/src/api/types/Tag.ts b/src/api/types/Tag.ts index e05a05b..7dca0ba 100644 --- a/src/api/types/Tag.ts +++ b/src/api/types/Tag.ts @@ -6,8 +6,8 @@ * Generic key-value pair model to append a custom variable being sent to Flagright API */ export interface Tag { - /** Key value when you are creating a custom variable `non-empty` */ + /** Key value when you are creating a custom variable */ key: string; - /** Value for a given key when you are creating a custom variable `non-empty` */ + /** Value for a given key when you are creating a custom variable */ value: string; } diff --git a/src/api/types/TransactionBase.ts b/src/api/types/TransactionBase.ts index ffe9563..741060c 100644 --- a/src/api/types/TransactionBase.ts +++ b/src/api/types/TransactionBase.ts @@ -8,8 +8,8 @@ import * as Flagright from ".."; * Model for transaction base Payload */ export interface TransactionBase { - type_: Flagright.TransactionType; - /** Unique transaction identifier `non-empty` */ + type: Flagright.TransactionType; + /** Unique transaction identifier */ transactionId: string; /** Timestamp of when transaction took place */ timestamp: number; diff --git a/src/api/types/TransactionEvent.ts b/src/api/types/TransactionEvent.ts index 40c2f7b..501807f 100644 --- a/src/api/types/TransactionEvent.ts +++ b/src/api/types/TransactionEvent.ts @@ -11,7 +11,7 @@ export interface TransactionEvent { transactionState: Flagright.TransactionState; /** Timestamp of the event */ timestamp: number; - /** Transaction ID the event pertains to `non-empty` */ + /** Transaction ID the event pertains to */ transactionId: string; /** Unique event ID */ eventId?: string; diff --git a/src/api/types/TransactionUpdatable.ts b/src/api/types/TransactionUpdatable.ts index 502eaac..f3275e1 100644 --- a/src/api/types/TransactionUpdatable.ts +++ b/src/api/types/TransactionUpdatable.ts @@ -21,7 +21,7 @@ export interface TransactionUpdatable { productType?: string; /** Whether a promotion code was used or not the transaction */ promotionCodeUsed?: boolean; - /** Reference field for the transaction indicating the purpose of the transaction etc. `non-empty` */ + /** Reference field for the transaction indicating the purpose of the transaction etc. */ reference?: string; originDeviceData?: Flagright.DeviceData; destinationDeviceData?: Flagright.DeviceData; diff --git a/src/api/types/TransactionUpdatableDestinationPaymentDetails.ts b/src/api/types/TransactionUpdatableDestinationPaymentDetails.ts index 40a23a2..76ea8bb 100644 --- a/src/api/types/TransactionUpdatableDestinationPaymentDetails.ts +++ b/src/api/types/TransactionUpdatableDestinationPaymentDetails.ts @@ -8,12 +8,50 @@ import * as Flagright from ".."; * Payment details of the destination. It can be a bank account number, wallet ID, card fingerprint etc. */ export type TransactionUpdatableDestinationPaymentDetails = - | Flagright.CardDetails - | Flagright.GenericBankAccountDetails - | Flagright.IbanDetails - | Flagright.AchDetails - | Flagright.UpiDetails - | Flagright.WalletDetails - | Flagright.SwiftDetails - | Flagright.MpesaDetails - | Flagright.CheckDetails; + | Flagright.TransactionUpdatableDestinationPaymentDetails.Card + | Flagright.TransactionUpdatableDestinationPaymentDetails.GenericBankAccount + | Flagright.TransactionUpdatableDestinationPaymentDetails.Iban + | Flagright.TransactionUpdatableDestinationPaymentDetails.Ach + | Flagright.TransactionUpdatableDestinationPaymentDetails.Upi + | Flagright.TransactionUpdatableDestinationPaymentDetails.Wallet + | Flagright.TransactionUpdatableDestinationPaymentDetails.Swift + | Flagright.TransactionUpdatableDestinationPaymentDetails.Mpesa + | Flagright.TransactionUpdatableDestinationPaymentDetails.Check; + +export declare namespace TransactionUpdatableDestinationPaymentDetails { + interface Card extends Flagright.CardDetails { + method: "CARD"; + } + + interface GenericBankAccount extends Flagright.GenericBankAccountDetails { + method: "GENERIC_BANK_ACCOUNT"; + } + + interface Iban extends Flagright.IbanDetails { + method: "IBAN"; + } + + interface Ach extends Flagright.AchDetails { + method: "ACH"; + } + + interface Upi extends Flagright.UpiDetails { + method: "UPI"; + } + + interface Wallet extends Flagright.WalletDetails { + method: "WALLET"; + } + + interface Swift extends Flagright.SwiftDetails { + method: "SWIFT"; + } + + interface Mpesa extends Flagright.MpesaDetails { + method: "MPESA"; + } + + interface Check extends Flagright.CheckDetails { + method: "CHECK"; + } +} diff --git a/src/api/types/TransactionUpdatableOriginPaymentDetails.ts b/src/api/types/TransactionUpdatableOriginPaymentDetails.ts index ebd06d0..33d9e86 100644 --- a/src/api/types/TransactionUpdatableOriginPaymentDetails.ts +++ b/src/api/types/TransactionUpdatableOriginPaymentDetails.ts @@ -8,12 +8,50 @@ import * as Flagright from ".."; * Payment details of the origin. It can be a bank account number, wallet ID, card fingerprint etc. */ export type TransactionUpdatableOriginPaymentDetails = - | Flagright.CardDetails - | Flagright.GenericBankAccountDetails - | Flagright.IbanDetails - | Flagright.AchDetails - | Flagright.SwiftDetails - | Flagright.MpesaDetails - | Flagright.UpiDetails - | Flagright.WalletDetails - | Flagright.CheckDetails; + | Flagright.TransactionUpdatableOriginPaymentDetails.Card + | Flagright.TransactionUpdatableOriginPaymentDetails.GenericBankAccount + | Flagright.TransactionUpdatableOriginPaymentDetails.Iban + | Flagright.TransactionUpdatableOriginPaymentDetails.Ach + | Flagright.TransactionUpdatableOriginPaymentDetails.Swift + | Flagright.TransactionUpdatableOriginPaymentDetails.Mpesa + | Flagright.TransactionUpdatableOriginPaymentDetails.Upi + | Flagright.TransactionUpdatableOriginPaymentDetails.Wallet + | Flagright.TransactionUpdatableOriginPaymentDetails.Check; + +export declare namespace TransactionUpdatableOriginPaymentDetails { + interface Card extends Flagright.CardDetails { + method: "CARD"; + } + + interface GenericBankAccount extends Flagright.GenericBankAccountDetails { + method: "GENERIC_BANK_ACCOUNT"; + } + + interface Iban extends Flagright.IbanDetails { + method: "IBAN"; + } + + interface Ach extends Flagright.AchDetails { + method: "ACH"; + } + + interface Swift extends Flagright.SwiftDetails { + method: "SWIFT"; + } + + interface Mpesa extends Flagright.MpesaDetails { + method: "MPESA"; + } + + interface Upi extends Flagright.UpiDetails { + method: "UPI"; + } + + interface Wallet extends Flagright.WalletDetails { + method: "WALLET"; + } + + interface Check extends Flagright.CheckDetails { + method: "CHECK"; + } +} diff --git a/src/api/types/UpiDetails.ts b/src/api/types/UpiDetails.ts index 5b8604e..e6b6c6a 100644 --- a/src/api/types/UpiDetails.ts +++ b/src/api/types/UpiDetails.ts @@ -8,12 +8,11 @@ import * as Flagright from ".."; * Model for UPI payment method */ export interface UpiDetails { - method: Flagright.UpiPaymentMethod; - /** UPI Id number `non-empty` */ + /** UPI Id number */ upiId: string; - /** Bank provider name `non-empty` */ + /** Bank provider name */ bankProvider?: string; - /** Interface provider name `non-empty` */ + /** Interface provider name */ interfaceProvider?: string; /** Name of the account holder */ name?: string; diff --git a/src/api/types/UserBase.ts b/src/api/types/UserBase.ts index 95ccba1..2d25415 100644 --- a/src/api/types/UserBase.ts +++ b/src/api/types/UserBase.ts @@ -6,7 +6,7 @@ * Model for User details */ export interface UserBase { - /** Unique user ID `non-empty` */ + /** Unique user ID */ userId: string; /** Timestamp when userId is created */ createdTimestamp: number; diff --git a/src/api/types/WalletDetails.ts b/src/api/types/WalletDetails.ts index c26cca0..71a7537 100644 --- a/src/api/types/WalletDetails.ts +++ b/src/api/types/WalletDetails.ts @@ -8,10 +8,9 @@ import * as Flagright from ".."; * Standardized model for a Generic wallet transaction */ export interface WalletDetails { - method: Flagright.WalletPaymentMethod; /** Wallet type if there are various types of wallets belonging to the same user. E.g. Checking, savings, vault, different currency wallets etc. */ walletType: string; - /** Unique ID of the wallet `non-empty` */ + /** Unique ID of the wallet */ walletId?: string; /** Payment Channel used through wallet */ paymentChannel?: string; diff --git a/src/api/types/WebhookEvent.ts b/src/api/types/WebhookEvent.ts index 9436e63..c6fae71 100644 --- a/src/api/types/WebhookEvent.ts +++ b/src/api/types/WebhookEvent.ts @@ -6,7 +6,7 @@ import * as Flagright from ".."; export interface WebhookEvent { id: string; - type_: Flagright.WebhookEventType; + type: Flagright.WebhookEventType; triggeredBy?: Flagright.WebhookEventTriggeredBy; data: Flagright.WebhookEventData; createdTimestamp: number; diff --git a/src/api/types/index.ts b/src/api/types/index.ts index d348ed4..d097cee 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -1,20 +1,15 @@ -export * from "./Transaction"; -export * from "./TransactionsVerifyResponse"; -export * from "./TransactionEvent"; -export * from "./User"; -export * from "./ConsumerUsersCreateResponse"; -export * from "./Business"; -export * from "./BusinessUsersCreateResponse"; export * from "./Address"; export * from "./UserBase"; export * from "./UserOptional"; export * from "./ConsumerUserSegment"; +export * from "./User"; export * from "./Person"; export * from "./LegalDocument"; export * from "./Tag"; -export * from "./TransactionUpdatable"; +export * from "./Transaction"; export * from "./TransactionUpdatableOriginPaymentDetails"; export * from "./TransactionUpdatableDestinationPaymentDetails"; +export * from "./TransactionUpdatable"; export * from "./TransactionBase"; export * from "./TransactionWithRulesResult"; export * from "./DeviceData"; @@ -32,39 +27,41 @@ export * from "./LegalEntity"; export * from "./SourceOfFunds"; export * from "./ContactDetails"; export * from "./CompanyFinancialDetails"; -export * from "./UserDetails"; export * from "./UserDetailsGender"; +export * from "./UserDetails"; export * from "./UserRegistrationStatus"; export * from "./BusinessUserSegment"; export * from "./CompanyGeneralDetails"; export * from "./CompanyRegistrationDetails"; +export * from "./BusinessOptionalSavedPaymentDetailsItem"; +export * from "./Business"; export * from "./BusinessBase"; export * from "./BusinessOptional"; -export * from "./BusinessOptionalSavedPaymentDetailsItem"; export * from "./BusinessUsersResponse"; export * from "./ConsumerUsersResponse"; -export * from "./CardDetails"; export * from "./CardDetailsCardBrand"; export * from "./CardDetailsCardFunding"; export * from "./CardDetailsCardType"; +export * from "./CardDetails"; export * from "./IbanDetails"; export * from "./WalletDetails"; export * from "./AchDetails"; export * from "./SwiftDetails"; -export * from "./MpesaDetails"; export * from "./MpesaDetailsTransactionType"; +export * from "./MpesaDetails"; export * from "./GenericBankAccountDetails"; export * from "./UpiDetails"; -export * from "./TransactionLimits"; export * from "./TransactionLimitsPaymentMethodLimits"; +export * from "./TransactionLimits"; export * from "./RuleAction"; export * from "./RuleHitMeta"; export * from "./RuleHitDirection"; export * from "./RuleNature"; export * from "./RuleLabels"; -export * from "./CaseManagementEvent"; +export * from "./TransactionEvent"; export * from "./CaseManagementEventCaseStatus"; export * from "./CaseManagementEventCaseStatusReason"; +export * from "./CaseManagementEvent"; export * from "./Date_"; export * from "./TransactionState"; export * from "./AcquisitionChannel"; @@ -89,9 +86,9 @@ export * from "./TransactionStatusDetails"; export * from "./RiskLevel"; export * from "./CardExpiry"; export * from "./TransactionType"; -export * from "./WebhookEvent"; export * from "./WebhookEventTriggeredBy"; export * from "./WebhookEventData"; +export * from "./WebhookEvent"; export * from "./WebhookEventType"; export * from "./ListType"; export * from "./ListSubtype"; @@ -103,8 +100,8 @@ export * from "./ListExisted"; export * from "./ListHeader"; export * from "./PaymentMethod"; export * from "./CardMerchantDetails"; -export * from "./CheckDetails"; export * from "./CheckDetailsDeliveryStatus"; +export * from "./CheckDetails"; export * from "./CountryCode"; export * from "./CurrencyCode"; export * from "./MccDetails"; diff --git a/src/core/fetcher/APIResponse.ts b/src/core/fetcher/APIResponse.ts index ea838f3..3664d09 100644 --- a/src/core/fetcher/APIResponse.ts +++ b/src/core/fetcher/APIResponse.ts @@ -3,6 +3,7 @@ export type APIResponse = SuccessfulResponse | Failed export interface SuccessfulResponse { ok: true; body: T; + headers?: Record; } export interface FailedResponse { diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index 6af0fb1..e25819a 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -1,7 +1,11 @@ -import { default as URLSearchParams } from "@ungap/url-search-params"; -import axios, { AxiosAdapter, AxiosError } from "axios"; +import { default as FormData } from "form-data"; +import qs from "qs"; import { APIResponse } from "./APIResponse"; +if (typeof window === "undefined") { + global.fetch = require("node-fetch"); +} + export type FetchFunction = (args: Fetcher.Args) => Promise>; export declare namespace Fetcher { @@ -10,13 +14,12 @@ export declare namespace Fetcher { method: string; contentType?: string; headers?: Record; - queryParameters?: URLSearchParams; + queryParameters?: Record; body?: unknown; timeoutMs?: number; + maxRetries?: number; withCredentials?: boolean; - responseType?: "json" | "blob"; - adapter?: AxiosAdapter; - onUploadProgress?: (event: ProgressEvent) => void; + responseType?: "json" | "blob" | "streaming"; } export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; @@ -43,6 +46,10 @@ export declare namespace Fetcher { } } +const INITIAL_RETRY_DELAY = 1; +const MAX_RETRY_DELAY = 60; +const DEFAULT_MAX_RETRIES = 2; + async function fetcherImpl(args: Fetcher.Args): Promise> { const headers: Record = {}; if (args.body !== undefined && args.contentType != null) { @@ -57,40 +64,71 @@ async function fetcherImpl(args: Fetcher.Args): Promise 0 + ? `${args.url}?${qs.stringify(args.queryParameters, { arrayFormat: "repeat" })}` + : args.url; + + let body: BodyInit | undefined = undefined; + if (args.body instanceof FormData) { + // @ts-expect-error + body = args.body; + } else { + body = JSON.stringify(args.body); + } + + const makeRequest = async (): Promise => { + const controller = new AbortController(); + let abortId = undefined; + if (args.timeoutMs != null) { + abortId = setTimeout(() => controller.abort(), args.timeoutMs); + } + const response = await fetch(url, { method: args.method, headers, - data: args.body, - validateStatus: () => true, - transformResponse: (response) => response, - timeout: args.timeoutMs, - transitional: { - clarifyTimeoutError: true, - }, - withCredentials: args.withCredentials, - adapter: args.adapter, - onUploadProgress: args.onUploadProgress, - maxBodyLength: Infinity, - maxContentLength: Infinity, - responseType: args.responseType ?? "json", + body, + signal: controller.signal, + credentials: args.withCredentials ? "same-origin" : undefined, }); + if (abortId != null) { + clearTimeout(abortId); + } + return response; + }; + + try { + let response = await makeRequest(); + + for (let i = 0; i < (args.maxRetries ?? DEFAULT_MAX_RETRIES); ++i) { + if ( + response.status === 408 || + response.status === 409 || + response.status === 429 || + response.status >= 500 + ) { + const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(i, 2), MAX_RETRY_DELAY); + await new Promise((resolve) => setTimeout(resolve, delay)); + response = await makeRequest(); + } else { + break; + } + } let body: unknown; - if (args.responseType === "blob") { - body = response.data; - } else if (response.data != null && response.data.length > 0) { + if (response.body != null && args.responseType === "blob") { + body = await response.blob(); + } else if (response.body != null && args.responseType === "streaming") { + body = response.body; + } else if (response.body != null) { try { - body = JSON.parse(response.data) ?? undefined; - } catch { + body = await response.json(); + } catch (err) { return { ok: false, error: { reason: "non-json", statusCode: response.status, - rawBody: response.data, + rawBody: await response.text(), }, }; } @@ -100,6 +138,7 @@ async function fetcherImpl(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise, header: string): string | undefined { + for (const [headerKey, headerValue] of Object.entries(headers)) { + if (headerKey.toLowerCase() === header.toLowerCase()) { + return headerValue; + } + } + return undefined; +} diff --git a/src/core/fetcher/index.ts b/src/core/fetcher/index.ts index 6becab2..2d658ca 100644 --- a/src/core/fetcher/index.ts +++ b/src/core/fetcher/index.ts @@ -1,4 +1,5 @@ export type { APIResponse } from "./APIResponse"; export { fetcher } from "./Fetcher"; export type { Fetcher, FetchFunction } from "./Fetcher"; +export { getHeader } from "./getHeader"; export { Supplier } from "./Supplier"; diff --git a/src/core/schemas/Schema.ts b/src/core/schemas/Schema.ts index 3211fa4..870f373 100644 --- a/src/core/schemas/Schema.ts +++ b/src/core/schemas/Schema.ts @@ -17,6 +17,7 @@ export const SchemaType = { ENUM: "enum", LIST: "list", STRING_LITERAL: "stringLiteral", + BOOLEAN_LITERAL: "booleanLiteral", OBJECT: "object", ANY: "any", BOOLEAN: "boolean", diff --git a/src/core/schemas/builders/literals/booleanLiteral.ts b/src/core/schemas/builders/literals/booleanLiteral.ts new file mode 100644 index 0000000..a83d22c --- /dev/null +++ b/src/core/schemas/builders/literals/booleanLiteral.ts @@ -0,0 +1,29 @@ +import { Schema, SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; + +export function booleanLiteral(literal: V): Schema { + const schemaCreator = createIdentitySchemaCreator( + SchemaType.BOOLEAN_LITERAL, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (value === literal) { + return { + ok: true, + value: literal, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, `${literal.toString()}`), + }, + ], + }; + } + } + ); + + return schemaCreator(); +} diff --git a/src/core/schemas/builders/literals/index.ts b/src/core/schemas/builders/literals/index.ts index a4cd05c..d2bf08f 100644 --- a/src/core/schemas/builders/literals/index.ts +++ b/src/core/schemas/builders/literals/index.ts @@ -1 +1,2 @@ export { stringLiteral } from "./stringLiteral"; +export { booleanLiteral } from "./booleanLiteral"; diff --git a/src/serialization/index.ts b/src/serialization/index.ts index 3ce0a3e..3e15e29 100644 --- a/src/serialization/index.ts +++ b/src/serialization/index.ts @@ -1,2 +1,2 @@ -export * from "./types"; export * from "./resources"; +export * from "./types"; diff --git a/src/serialization/resources/businessUsers/index.ts b/src/serialization/resources/businessUsers/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/businessUsers/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/types/BusinessUsersCreateResponse.ts b/src/serialization/resources/businessUsers/types/BusinessUsersCreateResponse.ts similarity index 76% rename from src/serialization/types/BusinessUsersCreateResponse.ts rename to src/serialization/resources/businessUsers/types/BusinessUsersCreateResponse.ts index b3a1f2e..2c1d766 100644 --- a/src/serialization/types/BusinessUsersCreateResponse.ts +++ b/src/serialization/resources/businessUsers/types/BusinessUsersCreateResponse.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from ".."; -import * as Flagright from "../../api"; -import * as core from "../../core"; +import * as serializers from "../../.."; +import * as Flagright from "../../../../api"; +import * as core from "../../../../core"; export const BusinessUsersCreateResponse: core.serialization.ObjectSchema< serializers.BusinessUsersCreateResponse.Raw, @@ -13,7 +13,7 @@ export const BusinessUsersCreateResponse: core.serialization.ObjectSchema< .object({ message: core.serialization.string().optional(), }) - .extend(core.serialization.lazyObject(async () => (await import("..")).BusinessUsersResponse)); + .extend(core.serialization.lazyObject(async () => (await import("../../..")).BusinessUsersResponse)); export declare namespace BusinessUsersCreateResponse { interface Raw extends serializers.BusinessUsersResponse.Raw { diff --git a/src/serialization/resources/businessUsers/types/index.ts b/src/serialization/resources/businessUsers/types/index.ts new file mode 100644 index 0000000..0d5b65d --- /dev/null +++ b/src/serialization/resources/businessUsers/types/index.ts @@ -0,0 +1 @@ +export * from "./BusinessUsersCreateResponse"; diff --git a/src/serialization/resources/consumerUsers/index.ts b/src/serialization/resources/consumerUsers/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/consumerUsers/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/types/ConsumerUsersCreateResponse.ts b/src/serialization/resources/consumerUsers/types/ConsumerUsersCreateResponse.ts similarity index 76% rename from src/serialization/types/ConsumerUsersCreateResponse.ts rename to src/serialization/resources/consumerUsers/types/ConsumerUsersCreateResponse.ts index c3418ec..780e6ca 100644 --- a/src/serialization/types/ConsumerUsersCreateResponse.ts +++ b/src/serialization/resources/consumerUsers/types/ConsumerUsersCreateResponse.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from ".."; -import * as Flagright from "../../api"; -import * as core from "../../core"; +import * as serializers from "../../.."; +import * as Flagright from "../../../../api"; +import * as core from "../../../../core"; export const ConsumerUsersCreateResponse: core.serialization.ObjectSchema< serializers.ConsumerUsersCreateResponse.Raw, @@ -13,7 +13,7 @@ export const ConsumerUsersCreateResponse: core.serialization.ObjectSchema< .object({ message: core.serialization.string().optional(), }) - .extend(core.serialization.lazyObject(async () => (await import("..")).ConsumerUsersResponse)); + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ConsumerUsersResponse)); export declare namespace ConsumerUsersCreateResponse { interface Raw extends serializers.ConsumerUsersResponse.Raw { diff --git a/src/serialization/resources/consumerUsers/types/index.ts b/src/serialization/resources/consumerUsers/types/index.ts new file mode 100644 index 0000000..23b3635 --- /dev/null +++ b/src/serialization/resources/consumerUsers/types/index.ts @@ -0,0 +1 @@ +export * from "./ConsumerUsersCreateResponse"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts index ff6a43a..fa910f3 100644 --- a/src/serialization/resources/index.ts +++ b/src/serialization/resources/index.ts @@ -1,3 +1,9 @@ +export * as transactions from "./transactions"; +export * from "./transactions/types"; +export * as consumerUsers from "./consumerUsers"; +export * from "./consumerUsers/types"; +export * as businessUsers from "./businessUsers"; +export * from "./businessUsers/types"; export * as consumerUserEvents from "./consumerUserEvents"; export * from "./consumerUserEvents/client/requests"; export * as businessUserEvents from "./businessUserEvents"; diff --git a/src/serialization/resources/transactions/index.ts b/src/serialization/resources/transactions/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/transactions/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/types/TransactionsVerifyResponse.ts b/src/serialization/resources/transactions/types/TransactionsVerifyResponse.ts similarity index 76% rename from src/serialization/types/TransactionsVerifyResponse.ts rename to src/serialization/resources/transactions/types/TransactionsVerifyResponse.ts index 485c4dc..1c5dced 100644 --- a/src/serialization/types/TransactionsVerifyResponse.ts +++ b/src/serialization/resources/transactions/types/TransactionsVerifyResponse.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from ".."; -import * as Flagright from "../../api"; -import * as core from "../../core"; +import * as serializers from "../../.."; +import * as Flagright from "../../../../api"; +import * as core from "../../../../core"; export const TransactionsVerifyResponse: core.serialization.ObjectSchema< serializers.TransactionsVerifyResponse.Raw, @@ -13,7 +13,7 @@ export const TransactionsVerifyResponse: core.serialization.ObjectSchema< .object({ message: core.serialization.string().optional(), }) - .extend(core.serialization.lazyObject(async () => (await import("..")).TransactionMonitoringResult)); + .extend(core.serialization.lazyObject(async () => (await import("../../..")).TransactionMonitoringResult)); export declare namespace TransactionsVerifyResponse { interface Raw extends serializers.TransactionMonitoringResult.Raw { diff --git a/src/serialization/resources/transactions/types/index.ts b/src/serialization/resources/transactions/types/index.ts new file mode 100644 index 0000000..eca88f9 --- /dev/null +++ b/src/serialization/resources/transactions/types/index.ts @@ -0,0 +1 @@ +export * from "./TransactionsVerifyResponse"; diff --git a/src/serialization/types/AchDetails.ts b/src/serialization/types/AchDetails.ts index d617e91..af00f73 100644 --- a/src/serialization/types/AchDetails.ts +++ b/src/serialization/types/AchDetails.ts @@ -8,7 +8,6 @@ import * as core from "../../core"; export const AchDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).AchPaymentMethod), routingNumber: core.serialization.string().optional(), accountNumber: core.serialization.string().optional(), bankName: core.serialization.string().optional(), @@ -20,7 +19,6 @@ export const AchDetails: core.serialization.ObjectSchema = core.serialization.undiscriminatedUnion([ - core.serialization.lazyObject(async () => (await import("..")).CardDetails), - core.serialization.lazyObject(async () => (await import("..")).GenericBankAccountDetails), - core.serialization.lazyObject(async () => (await import("..")).IbanDetails), - core.serialization.lazyObject(async () => (await import("..")).AchDetails), - core.serialization.lazyObject(async () => (await import("..")).SwiftDetails), - core.serialization.lazyObject(async () => (await import("..")).MpesaDetails), - core.serialization.lazyObject(async () => (await import("..")).UpiDetails), - core.serialization.lazyObject(async () => (await import("..")).WalletDetails), - core.serialization.lazyObject(async () => (await import("..")).CheckDetails), -]); +> = core.serialization + .union("method", { + CARD: core.serialization.lazyObject(async () => (await import("..")).CardDetails), + GENERIC_BANK_ACCOUNT: core.serialization.lazyObject(async () => (await import("..")).GenericBankAccountDetails), + IBAN: core.serialization.lazyObject(async () => (await import("..")).IbanDetails), + ACH: core.serialization.lazyObject(async () => (await import("..")).AchDetails), + SWIFT: core.serialization.lazyObject(async () => (await import("..")).SwiftDetails), + MPESA: core.serialization.lazyObject(async () => (await import("..")).MpesaDetails), + UPI: core.serialization.lazyObject(async () => (await import("..")).UpiDetails), + WALLET: core.serialization.lazyObject(async () => (await import("..")).WalletDetails), + CHECK: core.serialization.lazyObject(async () => (await import("..")).CheckDetails), + }) + .transform({ + transform: (value) => value, + untransform: (value) => value, + }); export declare namespace BusinessOptionalSavedPaymentDetailsItem { type Raw = - | serializers.CardDetails.Raw - | serializers.GenericBankAccountDetails.Raw - | serializers.IbanDetails.Raw - | serializers.AchDetails.Raw - | serializers.SwiftDetails.Raw - | serializers.MpesaDetails.Raw - | serializers.UpiDetails.Raw - | serializers.WalletDetails.Raw - | serializers.CheckDetails.Raw; + | BusinessOptionalSavedPaymentDetailsItem.Card + | BusinessOptionalSavedPaymentDetailsItem.GenericBankAccount + | BusinessOptionalSavedPaymentDetailsItem.Iban + | BusinessOptionalSavedPaymentDetailsItem.Ach + | BusinessOptionalSavedPaymentDetailsItem.Swift + | BusinessOptionalSavedPaymentDetailsItem.Mpesa + | BusinessOptionalSavedPaymentDetailsItem.Upi + | BusinessOptionalSavedPaymentDetailsItem.Wallet + | BusinessOptionalSavedPaymentDetailsItem.Check; + + interface Card extends serializers.CardDetails.Raw { + method: "CARD"; + } + + interface GenericBankAccount extends serializers.GenericBankAccountDetails.Raw { + method: "GENERIC_BANK_ACCOUNT"; + } + + interface Iban extends serializers.IbanDetails.Raw { + method: "IBAN"; + } + + interface Ach extends serializers.AchDetails.Raw { + method: "ACH"; + } + + interface Swift extends serializers.SwiftDetails.Raw { + method: "SWIFT"; + } + + interface Mpesa extends serializers.MpesaDetails.Raw { + method: "MPESA"; + } + + interface Upi extends serializers.UpiDetails.Raw { + method: "UPI"; + } + + interface Wallet extends serializers.WalletDetails.Raw { + method: "WALLET"; + } + + interface Check extends serializers.CheckDetails.Raw { + method: "CHECK"; + } } diff --git a/src/serialization/types/CardDetails.ts b/src/serialization/types/CardDetails.ts index 5cad1a2..c137e00 100644 --- a/src/serialization/types/CardDetails.ts +++ b/src/serialization/types/CardDetails.ts @@ -8,11 +8,10 @@ import * as core from "../../core"; export const CardDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).CardPaymentMethod), cardFingerprint: core.serialization.string().optional(), cardIssuedCountry: core.serialization.lazy(async () => (await import("..")).CountryCode).optional(), transactionReferenceField: core.serialization.string().optional(), - _3DsDone: core.serialization.property("3dsDone", core.serialization.boolean().optional()), + "3DsDone": core.serialization.property("3dsDone", core.serialization.boolean().optional()), nameOnCard: core.serialization.lazyObject(async () => (await import("..")).ConsumerName).optional(), cardExpiry: core.serialization.lazyObject(async () => (await import("..")).CardExpiry).optional(), cardLast4Digits: core.serialization.string().optional(), @@ -27,7 +26,6 @@ export const CardDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).CheckPaymentMethod), checkNumber: core.serialization.string().optional(), checkIdentifier: core.serialization.string().optional(), name: core.serialization.string().optional(), @@ -20,7 +19,6 @@ export const CheckDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).GeneralBankAccountPaymentMethod), accountNumber: core.serialization.string().optional(), accountType: core.serialization.string().optional(), bankName: core.serialization.string().optional(), @@ -24,7 +23,6 @@ export const GenericBankAccountDetails: core.serialization.ObjectSchema< export declare namespace GenericBankAccountDetails { interface Raw { - method: serializers.GeneralBankAccountPaymentMethod.Raw; accountNumber?: string | null; accountType?: string | null; bankName?: string | null; diff --git a/src/serialization/types/IbanDetails.ts b/src/serialization/types/IbanDetails.ts index de1bd9c..13fb81f 100644 --- a/src/serialization/types/IbanDetails.ts +++ b/src/serialization/types/IbanDetails.ts @@ -8,7 +8,6 @@ import * as core from "../../core"; export const IbanDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).IbanPaymentMethod), bic: core.serialization.property("BIC", core.serialization.string().optional()), bankName: core.serialization.string().optional(), bankAddress: core.serialization.lazyObject(async () => (await import("..")).Address).optional(), @@ -22,7 +21,6 @@ export const IbanDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).MpesaPaymentMethod), businessShortCode: core.serialization.string(), transactionType: core.serialization.lazy(async () => (await import("..")).MpesaDetailsTransactionType), phoneNumber: core.serialization.string(), @@ -17,7 +16,6 @@ export const MpesaDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).SwiftPaymentMethod), swiftCode: core.serialization.string().optional(), accountNumber: core.serialization.string().optional(), accountType: core.serialization.string().optional(), @@ -21,7 +20,6 @@ export const SwiftDetails: core.serialization.ObjectSchema = core.serialization.object({ - type_: core.serialization.property( - "type", - core.serialization.lazy(async () => (await import("..")).TransactionType) - ), + type: core.serialization.lazy(async () => (await import("..")).TransactionType), transactionId: core.serialization.string(), timestamp: core.serialization.number(), originUserId: core.serialization.string().optional(), diff --git a/src/serialization/types/TransactionUpdatableDestinationPaymentDetails.ts b/src/serialization/types/TransactionUpdatableDestinationPaymentDetails.ts index d447253..c20e78c 100644 --- a/src/serialization/types/TransactionUpdatableDestinationPaymentDetails.ts +++ b/src/serialization/types/TransactionUpdatableDestinationPaymentDetails.ts @@ -9,27 +9,68 @@ import * as core from "../../core"; export const TransactionUpdatableDestinationPaymentDetails: core.serialization.Schema< serializers.TransactionUpdatableDestinationPaymentDetails.Raw, Flagright.TransactionUpdatableDestinationPaymentDetails -> = core.serialization.undiscriminatedUnion([ - core.serialization.lazyObject(async () => (await import("..")).CardDetails), - core.serialization.lazyObject(async () => (await import("..")).GenericBankAccountDetails), - core.serialization.lazyObject(async () => (await import("..")).IbanDetails), - core.serialization.lazyObject(async () => (await import("..")).AchDetails), - core.serialization.lazyObject(async () => (await import("..")).UpiDetails), - core.serialization.lazyObject(async () => (await import("..")).WalletDetails), - core.serialization.lazyObject(async () => (await import("..")).SwiftDetails), - core.serialization.lazyObject(async () => (await import("..")).MpesaDetails), - core.serialization.lazyObject(async () => (await import("..")).CheckDetails), -]); +> = core.serialization + .union("method", { + CARD: core.serialization.lazyObject(async () => (await import("..")).CardDetails), + GENERIC_BANK_ACCOUNT: core.serialization.lazyObject(async () => (await import("..")).GenericBankAccountDetails), + IBAN: core.serialization.lazyObject(async () => (await import("..")).IbanDetails), + ACH: core.serialization.lazyObject(async () => (await import("..")).AchDetails), + UPI: core.serialization.lazyObject(async () => (await import("..")).UpiDetails), + WALLET: core.serialization.lazyObject(async () => (await import("..")).WalletDetails), + SWIFT: core.serialization.lazyObject(async () => (await import("..")).SwiftDetails), + MPESA: core.serialization.lazyObject(async () => (await import("..")).MpesaDetails), + CHECK: core.serialization.lazyObject(async () => (await import("..")).CheckDetails), + }) + .transform({ + transform: (value) => value, + untransform: (value) => value, + }); export declare namespace TransactionUpdatableDestinationPaymentDetails { type Raw = - | serializers.CardDetails.Raw - | serializers.GenericBankAccountDetails.Raw - | serializers.IbanDetails.Raw - | serializers.AchDetails.Raw - | serializers.UpiDetails.Raw - | serializers.WalletDetails.Raw - | serializers.SwiftDetails.Raw - | serializers.MpesaDetails.Raw - | serializers.CheckDetails.Raw; + | TransactionUpdatableDestinationPaymentDetails.Card + | TransactionUpdatableDestinationPaymentDetails.GenericBankAccount + | TransactionUpdatableDestinationPaymentDetails.Iban + | TransactionUpdatableDestinationPaymentDetails.Ach + | TransactionUpdatableDestinationPaymentDetails.Upi + | TransactionUpdatableDestinationPaymentDetails.Wallet + | TransactionUpdatableDestinationPaymentDetails.Swift + | TransactionUpdatableDestinationPaymentDetails.Mpesa + | TransactionUpdatableDestinationPaymentDetails.Check; + + interface Card extends serializers.CardDetails.Raw { + method: "CARD"; + } + + interface GenericBankAccount extends serializers.GenericBankAccountDetails.Raw { + method: "GENERIC_BANK_ACCOUNT"; + } + + interface Iban extends serializers.IbanDetails.Raw { + method: "IBAN"; + } + + interface Ach extends serializers.AchDetails.Raw { + method: "ACH"; + } + + interface Upi extends serializers.UpiDetails.Raw { + method: "UPI"; + } + + interface Wallet extends serializers.WalletDetails.Raw { + method: "WALLET"; + } + + interface Swift extends serializers.SwiftDetails.Raw { + method: "SWIFT"; + } + + interface Mpesa extends serializers.MpesaDetails.Raw { + method: "MPESA"; + } + + interface Check extends serializers.CheckDetails.Raw { + method: "CHECK"; + } } diff --git a/src/serialization/types/TransactionUpdatableOriginPaymentDetails.ts b/src/serialization/types/TransactionUpdatableOriginPaymentDetails.ts index 4ad75cb..6ab468d 100644 --- a/src/serialization/types/TransactionUpdatableOriginPaymentDetails.ts +++ b/src/serialization/types/TransactionUpdatableOriginPaymentDetails.ts @@ -9,27 +9,68 @@ import * as core from "../../core"; export const TransactionUpdatableOriginPaymentDetails: core.serialization.Schema< serializers.TransactionUpdatableOriginPaymentDetails.Raw, Flagright.TransactionUpdatableOriginPaymentDetails -> = core.serialization.undiscriminatedUnion([ - core.serialization.lazyObject(async () => (await import("..")).CardDetails), - core.serialization.lazyObject(async () => (await import("..")).GenericBankAccountDetails), - core.serialization.lazyObject(async () => (await import("..")).IbanDetails), - core.serialization.lazyObject(async () => (await import("..")).AchDetails), - core.serialization.lazyObject(async () => (await import("..")).SwiftDetails), - core.serialization.lazyObject(async () => (await import("..")).MpesaDetails), - core.serialization.lazyObject(async () => (await import("..")).UpiDetails), - core.serialization.lazyObject(async () => (await import("..")).WalletDetails), - core.serialization.lazyObject(async () => (await import("..")).CheckDetails), -]); +> = core.serialization + .union("method", { + CARD: core.serialization.lazyObject(async () => (await import("..")).CardDetails), + GENERIC_BANK_ACCOUNT: core.serialization.lazyObject(async () => (await import("..")).GenericBankAccountDetails), + IBAN: core.serialization.lazyObject(async () => (await import("..")).IbanDetails), + ACH: core.serialization.lazyObject(async () => (await import("..")).AchDetails), + SWIFT: core.serialization.lazyObject(async () => (await import("..")).SwiftDetails), + MPESA: core.serialization.lazyObject(async () => (await import("..")).MpesaDetails), + UPI: core.serialization.lazyObject(async () => (await import("..")).UpiDetails), + WALLET: core.serialization.lazyObject(async () => (await import("..")).WalletDetails), + CHECK: core.serialization.lazyObject(async () => (await import("..")).CheckDetails), + }) + .transform({ + transform: (value) => value, + untransform: (value) => value, + }); export declare namespace TransactionUpdatableOriginPaymentDetails { type Raw = - | serializers.CardDetails.Raw - | serializers.GenericBankAccountDetails.Raw - | serializers.IbanDetails.Raw - | serializers.AchDetails.Raw - | serializers.SwiftDetails.Raw - | serializers.MpesaDetails.Raw - | serializers.UpiDetails.Raw - | serializers.WalletDetails.Raw - | serializers.CheckDetails.Raw; + | TransactionUpdatableOriginPaymentDetails.Card + | TransactionUpdatableOriginPaymentDetails.GenericBankAccount + | TransactionUpdatableOriginPaymentDetails.Iban + | TransactionUpdatableOriginPaymentDetails.Ach + | TransactionUpdatableOriginPaymentDetails.Swift + | TransactionUpdatableOriginPaymentDetails.Mpesa + | TransactionUpdatableOriginPaymentDetails.Upi + | TransactionUpdatableOriginPaymentDetails.Wallet + | TransactionUpdatableOriginPaymentDetails.Check; + + interface Card extends serializers.CardDetails.Raw { + method: "CARD"; + } + + interface GenericBankAccount extends serializers.GenericBankAccountDetails.Raw { + method: "GENERIC_BANK_ACCOUNT"; + } + + interface Iban extends serializers.IbanDetails.Raw { + method: "IBAN"; + } + + interface Ach extends serializers.AchDetails.Raw { + method: "ACH"; + } + + interface Swift extends serializers.SwiftDetails.Raw { + method: "SWIFT"; + } + + interface Mpesa extends serializers.MpesaDetails.Raw { + method: "MPESA"; + } + + interface Upi extends serializers.UpiDetails.Raw { + method: "UPI"; + } + + interface Wallet extends serializers.WalletDetails.Raw { + method: "WALLET"; + } + + interface Check extends serializers.CheckDetails.Raw { + method: "CHECK"; + } } diff --git a/src/serialization/types/UpiDetails.ts b/src/serialization/types/UpiDetails.ts index 3b0409c..db1d5f3 100644 --- a/src/serialization/types/UpiDetails.ts +++ b/src/serialization/types/UpiDetails.ts @@ -8,7 +8,6 @@ import * as core from "../../core"; export const UpiDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).UpiPaymentMethod), upiId: core.serialization.property("upiID", core.serialization.string()), bankProvider: core.serialization.string().optional(), interfaceProvider: core.serialization.string().optional(), @@ -18,7 +17,6 @@ export const UpiDetails: core.serialization.ObjectSchema = core.serialization.object({ - method: core.serialization.lazy(async () => (await import("..")).WalletPaymentMethod), walletType: core.serialization.string(), walletId: core.serialization.string().optional(), paymentChannel: core.serialization.string().optional(), @@ -20,7 +19,6 @@ export const WalletDetails: core.serialization.ObjectSchema = core.serialization.object({ id: core.serialization.string(), - type_: core.serialization.property( - "type", - core.serialization.lazy(async () => (await import("..")).WebhookEventType) - ), + type: core.serialization.lazy(async () => (await import("..")).WebhookEventType), triggeredBy: core.serialization.lazy(async () => (await import("..")).WebhookEventTriggeredBy).optional(), data: core.serialization.lazy(async () => (await import("..")).WebhookEventData), createdTimestamp: core.serialization.number(), diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts index d348ed4..d097cee 100644 --- a/src/serialization/types/index.ts +++ b/src/serialization/types/index.ts @@ -1,20 +1,15 @@ -export * from "./Transaction"; -export * from "./TransactionsVerifyResponse"; -export * from "./TransactionEvent"; -export * from "./User"; -export * from "./ConsumerUsersCreateResponse"; -export * from "./Business"; -export * from "./BusinessUsersCreateResponse"; export * from "./Address"; export * from "./UserBase"; export * from "./UserOptional"; export * from "./ConsumerUserSegment"; +export * from "./User"; export * from "./Person"; export * from "./LegalDocument"; export * from "./Tag"; -export * from "./TransactionUpdatable"; +export * from "./Transaction"; export * from "./TransactionUpdatableOriginPaymentDetails"; export * from "./TransactionUpdatableDestinationPaymentDetails"; +export * from "./TransactionUpdatable"; export * from "./TransactionBase"; export * from "./TransactionWithRulesResult"; export * from "./DeviceData"; @@ -32,39 +27,41 @@ export * from "./LegalEntity"; export * from "./SourceOfFunds"; export * from "./ContactDetails"; export * from "./CompanyFinancialDetails"; -export * from "./UserDetails"; export * from "./UserDetailsGender"; +export * from "./UserDetails"; export * from "./UserRegistrationStatus"; export * from "./BusinessUserSegment"; export * from "./CompanyGeneralDetails"; export * from "./CompanyRegistrationDetails"; +export * from "./BusinessOptionalSavedPaymentDetailsItem"; +export * from "./Business"; export * from "./BusinessBase"; export * from "./BusinessOptional"; -export * from "./BusinessOptionalSavedPaymentDetailsItem"; export * from "./BusinessUsersResponse"; export * from "./ConsumerUsersResponse"; -export * from "./CardDetails"; export * from "./CardDetailsCardBrand"; export * from "./CardDetailsCardFunding"; export * from "./CardDetailsCardType"; +export * from "./CardDetails"; export * from "./IbanDetails"; export * from "./WalletDetails"; export * from "./AchDetails"; export * from "./SwiftDetails"; -export * from "./MpesaDetails"; export * from "./MpesaDetailsTransactionType"; +export * from "./MpesaDetails"; export * from "./GenericBankAccountDetails"; export * from "./UpiDetails"; -export * from "./TransactionLimits"; export * from "./TransactionLimitsPaymentMethodLimits"; +export * from "./TransactionLimits"; export * from "./RuleAction"; export * from "./RuleHitMeta"; export * from "./RuleHitDirection"; export * from "./RuleNature"; export * from "./RuleLabels"; -export * from "./CaseManagementEvent"; +export * from "./TransactionEvent"; export * from "./CaseManagementEventCaseStatus"; export * from "./CaseManagementEventCaseStatusReason"; +export * from "./CaseManagementEvent"; export * from "./Date_"; export * from "./TransactionState"; export * from "./AcquisitionChannel"; @@ -89,9 +86,9 @@ export * from "./TransactionStatusDetails"; export * from "./RiskLevel"; export * from "./CardExpiry"; export * from "./TransactionType"; -export * from "./WebhookEvent"; export * from "./WebhookEventTriggeredBy"; export * from "./WebhookEventData"; +export * from "./WebhookEvent"; export * from "./WebhookEventType"; export * from "./ListType"; export * from "./ListSubtype"; @@ -103,8 +100,8 @@ export * from "./ListExisted"; export * from "./ListHeader"; export * from "./PaymentMethod"; export * from "./CardMerchantDetails"; -export * from "./CheckDetails"; export * from "./CheckDetailsDeliveryStatus"; +export * from "./CheckDetails"; export * from "./CountryCode"; export * from "./CurrencyCode"; export * from "./MccDetails"; diff --git a/yarn.lock b/yarn.lock index 0f04cca..94365c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,33 +2,49 @@ # yarn lockfile v1 +"@types/node-fetch@2.6.9": + version "2.6.9" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.9.tgz#15f529d247f1ede1824f7e7acdaa192d5f28071e" + integrity sha512-bQVlnMLFJ2d35DkPNjEPmd9ueO/rh5EiaZt2bhqiSarPjZIuIV6bPQVqcrEyvNo+AfTrRGVazle1tl597w3gfA== + dependencies: + "@types/node" "*" + form-data "^4.0.0" + +"@types/node@*": + version "20.10.8" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.8.tgz#f1e223cbde9e25696661d167a5b93a9b2a5d57c7" + integrity sha512-f8nQs3cLxbAFc00vEU59yf9UyGUftkPaLGfvbVOIDdx2i1b8epBqj2aNGyP19fiyXWvlmZ7qC1XLjAzw/OKIeA== + dependencies: + undici-types "~5.26.4" + "@types/node@17.0.33": version "17.0.33" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.33.tgz#3c1879b276dc63e73030bb91165e62a4509cd506" integrity sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ== +"@types/qs@6.9.8": + version "6.9.8" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.8.tgz#f2a7de3c107b89b441e071d5472e6b726b4adf45" + integrity sha512-u95svzDlTysU5xecFNTgfFG5RUWu1A9P0VzgpcIiGZA9iraHOdSzcxMxQ55DyeRaGCSxQi7LxXDI4rzq/MYfdg== + "@types/url-join@4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@types/url-join/-/url-join-4.0.1.tgz#4989c97f969464647a8586c7252d97b449cdc045" integrity sha512-wDXw9LEEUHyV+7UWy7U315nrJGJ7p1BzaCxDpEoLr789Dk1WDVMMlf3iBfbG2F8NdWnYyFbtTxUn2ZNbm1Q4LQ== -"@ungap/url-search-params@0.2.2": - version "0.2.2" - resolved "https://registry.yarnpkg.com/@ungap/url-search-params/-/url-search-params-0.2.2.tgz#2de3bdec21476a9b70ef11fd7b794752f9afa04c" - integrity sha512-qQsguKXZVKdCixOHX9jqnX/K/1HekPDpGKyEcXHT+zR6EjGA7S4boSuelL4uuPv6YfhN0n8c4UxW+v/Z3gM2iw== - asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -axios@0.27.2: - version "0.27.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" - integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== +call-bind@^1.0.0: + version "1.0.5" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.5.tgz#6fa2b7845ce0ea49bf4d8b9ef64727a2c2e2e513" + integrity sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ== dependencies: - follow-redirects "^1.14.9" - form-data "^4.0.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.1" + set-function-length "^1.1.1" combined-stream@^1.0.8: version "1.0.8" @@ -37,17 +53,21 @@ combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" +define-data-property@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.1.tgz#c35f7cd0ab09883480d12ac5cb213715587800b3" + integrity sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ== + dependencies: + get-intrinsic "^1.2.1" + gopd "^1.0.1" + has-property-descriptors "^1.0.0" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== -follow-redirects@^1.14.9: - version "1.15.3" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" - integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== - -form-data@^4.0.0: +form-data@4.0.0, form-data@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== @@ -56,6 +76,52 @@ form-data@^4.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +get-intrinsic@^1.0.2, get-intrinsic@^1.1.3, get-intrinsic@^1.2.1, get-intrinsic@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.2.tgz#281b7622971123e1ef4b3c90fd7539306da93f3b" + integrity sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA== + dependencies: + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +has-property-descriptors@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz#52ba30b6c5ec87fd89fa574bc1c39125c6f65340" + integrity sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg== + dependencies: + get-intrinsic "^1.2.2" + +has-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" + integrity sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +hasown@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c" + integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA== + dependencies: + function-bind "^1.1.2" + mime-db@1.52.0: version "1.52.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" @@ -68,17 +134,78 @@ mime-types@^2.1.12: dependencies: mime-db "1.52.0" +node-fetch@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + +object-inspect@^1.9.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" + integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== + prettier@2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +qs@6.11.2: + version "6.11.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.2.tgz#64bea51f12c1f5da1bc01496f48ffcff7c69d7d9" + integrity sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA== + dependencies: + side-channel "^1.0.4" + +set-function-length@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.1.1.tgz#4bc39fafb0307224a33e106a7d35ca1218d659ed" + integrity sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ== + dependencies: + define-data-property "^1.1.1" + get-intrinsic "^1.2.1" + gopd "^1.0.1" + has-property-descriptors "^1.0.0" + +side-channel@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" + integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== + dependencies: + call-bind "^1.0.0" + get-intrinsic "^1.0.2" + object-inspect "^1.9.0" + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + typescript@4.6.4: version "4.6.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + url-join@4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7" integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA== + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0"