diff --git a/package.json b/package.json index 5ddb095..68e2c2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flagright", - "version": "0.0.4", + "version": "0.1.0", "private": false, "repository": "https://github.com/flagright/flagright-node", "main": "./index.js", @@ -14,7 +14,7 @@ "@ungap/url-search-params": "0.2.2", "url-join": "4.0.1", "@types/url-join": "4.0.1", - "axios": "1.4.0" + "axios": "0.27.2" }, "devDependencies": { "@types/node": "17.0.33", diff --git a/src/Client.ts b/src/Client.ts index ac1c4e7..10f1f5c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -4,706 +4,60 @@ import * as environments from "./environments"; import * as core from "./core"; -import * as Flagright from "./api"; -import { default as URLSearchParams } from "@ungap/url-search-params"; -import * as serializers from "./serialization"; -import urlJoin from "url-join"; -import * as errors from "./errors"; +import { Transactions } from "./api/resources/transactions/client/Client"; +import { TransactionEvents } from "./api/resources/transactionEvents/client/Client"; +import { ConsumerUsers } from "./api/resources/consumerUsers/client/Client"; +import { BusinessUsers } from "./api/resources/businessUsers/client/Client"; +import { ConsumerUserEvents } from "./api/resources/consumerUserEvents/client/Client"; +import { BusinessUserEvents } from "./api/resources/businessUserEvents/client/Client"; export declare namespace FlagrightClient { interface Options { environment?: core.Supplier; apiKey: core.Supplier; } + + interface RequestOptions { + timeoutInSeconds?: number; + } } export class FlagrightClient { constructor(protected readonly _options: FlagrightClient.Options) {} - /** - * ## POST Transactions - * - * `/transactions` endpoint allows you to operate on the [Transaction entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#transaction) - * - * 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/8c06ae6a3231a-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} - */ - public async postConsumerTransaction( - request: Flagright.PostConsumerTransactionRequest - ): Promise { - const { validateOriginUserId, validateDestinationUserId, body: _body } = request; - const _queryParams = new URLSearchParams(); - if (validateOriginUserId != null) { - _queryParams.append("validateOriginUserId", validateOriginUserId); - } - - if (validateDestinationUserId != null) { - _queryParams.append("validateDestinationUserId", validateDestinationUserId); - } - - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - "transactions" - ), - method: "POST", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - queryParameters: _queryParams, - body: await serializers.Transaction.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.PostConsumerTransactionResponse.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Flagright.BadRequestError(_response.error.body); - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } - - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } - } - - /** - * ### GET Transactions - * - * `/transactions` endpoint allows you to operate on the [Transaction entity](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#transaction). - * - * Calling `GET /transactions/{transactionId}` will return the entire transaction payload and rule execution results for the transaction with the corresponding `transactionId` - * @throws {@link Flagright.UnauthorizedError} - * @throws {@link Flagright.TooManyRequestsError} - */ - public async getConsumerTransaction(transactionId: string): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - `transactions/${transactionId}` - ), - method: "GET", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.TransactionWithRulesResult.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } - - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } - } - - /** - * ## POST Transaction Events - * - * `/events/transaction` endpoint allows you to operate on the [Transaction Events entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#transaction-event) - * - * 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/8c06ae6a3231a-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. - * - * ### Payload - * - * 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. - * - * 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} - */ - public async postTransactionEvent( - request: Flagright.TransactionEvent - ): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - "events/transaction" - ), - method: "POST", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - body: await serializers.TransactionEvent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.TransactionEventMonitoringResult.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Flagright.BadRequestError(_response.error.body); - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } + protected _transactions: Transactions | undefined; - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } + public get transactions(): Transactions { + return (this._transactions ??= new Transactions(this._options)); } - /** - * ## POST Consumer User - * - * `/consumer/user` endpoint allows you to operate on the [Consumer user entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user) - * - * In order to pass the payload of a User to Flagright and verify the User, you will need to call this endpoint with the User 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 - * - * 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 - * - * @throws {@link Flagright.BadRequestError} - * @throws {@link Flagright.UnauthorizedError} - * @throws {@link Flagright.TooManyRequestsError} - */ - public async postConsumerUser(request: Flagright.User): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - "consumer/users" - ), - method: "POST", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - body: await serializers.User.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.PostConsumerUserResponse.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Flagright.BadRequestError(_response.error.body); - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } + protected _transactionEvents: TransactionEvents | undefined; - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } + public get transactionEvents(): TransactionEvents { + return (this._transactionEvents ??= new TransactionEvents(this._options)); } - /** - * ### GET Consumer User - * - * `/consumer/user` endpoint allows you to operate on the [Consumer User entity](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user). - * - * Calling `GET /consumer/user/{userId}` will return the entire user payload and rule execution results for the user with the corresponding `userId` - * @throws {@link Flagright.UnauthorizedError} - * @throws {@link Flagright.TooManyRequestsError} - */ - public async getConsumerUser(userId: string): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - `consumer/users/${userId}` - ), - method: "GET", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.User.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } + protected _consumerUsers: ConsumerUsers | undefined; - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } - - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } + public get consumerUsers(): ConsumerUsers { + return (this._consumerUsers ??= new ConsumerUsers(this._options)); } - /** - * ## POST Business User - * - * `/business/user` endpoint allows you to operate on the [Business user entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user) - * - * In order to pass the payload of a User to Flagright and verify the User, you will need to call this endpoint with the User 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 - * - * - * 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 - * @throws {@link Flagright.BadRequestError} - * @throws {@link Flagright.UnauthorizedError} - * @throws {@link Flagright.TooManyRequestsError} - */ - public async postBusinessUser(request: Flagright.Business): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - "business/users" - ), - method: "POST", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - body: await serializers.Business.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.PostBusinessUserResponse.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Flagright.BadRequestError(_response.error.body); - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } + protected _businessUsers: BusinessUsers | undefined; - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } + public get businessUsers(): BusinessUsers { + return (this._businessUsers ??= new BusinessUsers(this._options)); } - /** - * ### GET Business User - * - * `/business/user` endpoint allows you to operate on the [Business User entity](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user). - * - * Calling `GET /business/user/{userId}` will return the entire User payload and rule execution results for the User with the corresponding `userId` - * @throws {@link Flagright.UnauthorizedError} - * @throws {@link Flagright.TooManyRequestsError} - */ - public async getBusinessUserUserId(userId: string): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - `business/users/${userId}` - ), - method: "GET", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.Business.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } + protected _consumerUserEvents: ConsumerUserEvents | undefined; - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } + public get consumerUserEvents(): ConsumerUserEvents { + return (this._consumerUserEvents ??= new ConsumerUserEvents(this._options)); } - /** - * ## POST Consumer User Events - * - * `/events/consumer/user` endpoint allows you to operate on the Consumer User Events entity. - * - * 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. - * - * > If you have neither of the above two use cases, you do not need to use user events. - * - * ### Payload - * - * 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. - * - * 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} - */ - public async postUserEvent(request: Flagright.ConsumerUserEvent): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - "events/consumer/user" - ), - method: "POST", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - body: await serializers.ConsumerUserEvent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.UserWithRulesResult.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Flagright.BadRequestError(_response.error.body); - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } - - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } - } - - /** - * ## POST Business User Events - * - * `/events/business/user` endpoint allows you to operate on the Business User Events entity. - * - * 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. - * - * > If you have neither of the above two use cases, you do not need to use user events. - * - * ### Payload - * - * 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. - * - * 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} - */ - public async postBusinessUserEvent( - request: Flagright.BusinessUserEvent - ): Promise { - const _response = await core.fetcher({ - url: urlJoin( - (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, - "events/business/user" - ), - method: "POST", - headers: { - "x-api-key": await core.Supplier.get(this._options.apiKey), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "flagright", - "X-Fern-SDK-Version": "0.0.4", - }, - contentType: "application/json", - body: await serializers.BusinessUserEvent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), - timeoutMs: 60000, - }); - if (_response.ok) { - return await serializers.BusinessWithRulesResult.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - breadcrumbsPrefix: ["response"], - }); - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Flagright.BadRequestError(_response.error.body); - case 401: - throw new Flagright.UnauthorizedError(_response.error.body); - case 429: - throw new Flagright.TooManyRequestsError(_response.error.body); - default: - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - } + protected _businessUserEvents: BusinessUserEvents | undefined; - switch (_response.error.reason) { - case "non-json": - throw new errors.FlagrightError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.FlagrightTimeoutError(); - case "unknown": - throw new errors.FlagrightError({ - message: _response.error.errorMessage, - }); - } + public get businessUserEvents(): BusinessUserEvents { + return (this._businessUserEvents ??= new BusinessUserEvents(this._options)); } } diff --git a/src/api/client/requests/index.ts b/src/api/client/requests/index.ts deleted file mode 100644 index 7d9f27c..0000000 --- a/src/api/client/requests/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { PostConsumerTransactionRequest } from "./PostConsumerTransactionRequest"; -export { TransactionEvent } from "./TransactionEvent"; -export { ConsumerUserEvent } from "./ConsumerUserEvent"; -export { BusinessUserEvent } from "./BusinessUserEvent"; diff --git a/src/api/index.ts b/src/api/index.ts index 9dc8224..1cb55b6 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,3 +1,3 @@ export * from "./types"; export * from "./errors"; -export * from "./client"; +export * from "./resources"; diff --git a/src/api/resources/businessUserEvents/client/Client.ts b/src/api/resources/businessUserEvents/client/Client.ts new file mode 100644 index 0000000..7a34b7c --- /dev/null +++ b/src/api/resources/businessUserEvents/client/Client.ts @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +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"; + +export declare namespace BusinessUserEvents { + interface Options { + environment?: core.Supplier; + apiKey: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; + } +} + +export class BusinessUserEvents { + constructor(protected readonly _options: BusinessUserEvents.Options) {} + + /** + * ## POST Business User Events + * + * `/events/business/user` endpoint allows you to operate on the Business User Events entity. + * + * 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. + * + * > If you have neither of the above two use cases, you do not need to use user events. + * + * ### Payload + * + * 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. + * + * 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} + */ + public async create( + request: Flagright.BusinessUserEvent, + requestOptions?: BusinessUserEvents.RequestOptions + ): Promise { + const { allowUserTypeConversion, ..._body } = request; + const _queryParams = new URLSearchParams(); + if (allowUserTypeConversion != null) { + _queryParams.append("allowUserTypeConversion", allowUserTypeConversion); + } + + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + "events/business/user" + ), + method: "POST", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + queryParameters: _queryParams, + body: await serializers.BusinessUserEvent.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.BusinessWithRulesResult.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Flagright.BadRequestError(_response.error.body); + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/client/index.ts b/src/api/resources/businessUserEvents/client/index.ts similarity index 100% rename from src/api/client/index.ts rename to src/api/resources/businessUserEvents/client/index.ts diff --git a/src/api/client/requests/BusinessUserEvent.ts b/src/api/resources/businessUserEvents/client/requests/BusinessUserEvent.ts similarity index 64% rename from src/api/client/requests/BusinessUserEvent.ts rename to src/api/resources/businessUserEvents/client/requests/BusinessUserEvent.ts index 9f5a314..141c421 100644 --- a/src/api/client/requests/BusinessUserEvent.ts +++ b/src/api/resources/businessUserEvents/client/requests/BusinessUserEvent.ts @@ -2,9 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from "../.."; +import * as Flagright from "../../../.."; export interface BusinessUserEvent { + /** + * Boolean string whether Flagright should allow a Business user event to be applied to a Consumer user with the same user ID. This will converts a Consumer user to a Business user. + */ + allowUserTypeConversion?: Flagright.BooleanString; /** Timestamp of the event */ timestamp: number; /** Transaction ID the event pertains to `non-empty` */ diff --git a/src/api/resources/businessUserEvents/client/requests/index.ts b/src/api/resources/businessUserEvents/client/requests/index.ts new file mode 100644 index 0000000..90c67bf --- /dev/null +++ b/src/api/resources/businessUserEvents/client/requests/index.ts @@ -0,0 +1 @@ +export { BusinessUserEvent } from "./BusinessUserEvent"; diff --git a/src/api/resources/businessUserEvents/index.ts b/src/api/resources/businessUserEvents/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/businessUserEvents/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/businessUsers/client/Client.ts b/src/api/resources/businessUsers/client/Client.ts new file mode 100644 index 0000000..5e49ce2 --- /dev/null +++ b/src/api/resources/businessUsers/client/Client.ts @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Flagright from "../../.."; +import * as serializers from "../../../../serialization"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors"; + +export declare namespace BusinessUsers { + interface Options { + environment?: core.Supplier; + apiKey: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; + } +} + +export class BusinessUsers { + constructor(protected readonly _options: BusinessUsers.Options) {} + + /** + * ## POST Business User + * + * `/business/user` endpoint allows you to operate on the [Business user entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user) + * + * In order to pass the payload of a User to Flagright and verify the User, you will need to call this endpoint with the User 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 + * + * + * 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 + * @throws {@link Flagright.BadRequestError} + * @throws {@link Flagright.UnauthorizedError} + * @throws {@link Flagright.TooManyRequestsError} + */ + public async create( + request: Flagright.Business, + requestOptions?: BusinessUsers.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + "business/users" + ), + method: "POST", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + body: await serializers.Business.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.BusinessUsersCreateResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Flagright.BadRequestError(_response.error.body); + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * ### GET Business User + * + * `/business/user` endpoint allows you to operate on the [Business User entity](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user). + * + * Calling `GET /business/user/{userId}` will return the entire User payload and rule execution results for the User with the corresponding `userId` + * @throws {@link Flagright.UnauthorizedError} + * @throws {@link Flagright.TooManyRequestsError} + */ + public async get( + userId: string, + requestOptions?: BusinessUsers.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + `business/users/${userId}` + ), + method: "GET", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.BusinessResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/resources/businessUsers/client/index.ts b/src/api/resources/businessUsers/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/businessUsers/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/businessUsers/index.ts b/src/api/resources/businessUsers/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/businessUsers/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/consumerUserEvents/client/Client.ts b/src/api/resources/consumerUserEvents/client/Client.ts new file mode 100644 index 0000000..dda00f2 --- /dev/null +++ b/src/api/resources/consumerUserEvents/client/Client.ts @@ -0,0 +1,118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +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"; + +export declare namespace ConsumerUserEvents { + interface Options { + environment?: core.Supplier; + apiKey: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; + } +} + +export class ConsumerUserEvents { + constructor(protected readonly _options: ConsumerUserEvents.Options) {} + + /** + * ## POST Consumer User Events + * + * `/events/consumer/user` endpoint allows you to operate on the Consumer User Events entity. + * + * 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. + * + * > If you have neither of the above two use cases, you do not need to use user events. + * + * ### Payload + * + * 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. + * + * 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} + */ + public async create( + request: Flagright.ConsumerUserEvent, + requestOptions?: ConsumerUserEvents.RequestOptions + ): Promise { + const { allowUserTypeConversion, ..._body } = request; + const _queryParams = new URLSearchParams(); + if (allowUserTypeConversion != null) { + _queryParams.append("allowUserTypeConversion", allowUserTypeConversion); + } + + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + "events/consumer/user" + ), + method: "POST", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + queryParameters: _queryParams, + body: await serializers.ConsumerUserEvent.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.UserWithRulesResult.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Flagright.BadRequestError(_response.error.body); + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/serialization/client/index.ts b/src/api/resources/consumerUserEvents/client/index.ts similarity index 100% rename from src/serialization/client/index.ts rename to src/api/resources/consumerUserEvents/client/index.ts diff --git a/src/api/client/requests/ConsumerUserEvent.ts b/src/api/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts similarity index 64% rename from src/api/client/requests/ConsumerUserEvent.ts rename to src/api/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts index 7c62a43..0d077a6 100644 --- a/src/api/client/requests/ConsumerUserEvent.ts +++ b/src/api/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts @@ -2,9 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from "../.."; +import * as Flagright from "../../../.."; export interface ConsumerUserEvent { + /** + * Boolean string whether Flagright should allow a Consumer user event to be applied to a Business user with the same user ID. This will converts a Business user to a Consumer user. + */ + allowUserTypeConversion?: Flagright.BooleanString; /** Timestamp of the event */ timestamp: number; /** Transaction ID the event pertains to `non-empty` */ diff --git a/src/api/resources/consumerUserEvents/client/requests/index.ts b/src/api/resources/consumerUserEvents/client/requests/index.ts new file mode 100644 index 0000000..30feeac --- /dev/null +++ b/src/api/resources/consumerUserEvents/client/requests/index.ts @@ -0,0 +1 @@ +export { ConsumerUserEvent } from "./ConsumerUserEvent"; diff --git a/src/api/resources/consumerUserEvents/index.ts b/src/api/resources/consumerUserEvents/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/consumerUserEvents/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/consumerUsers/client/Client.ts b/src/api/resources/consumerUsers/client/Client.ts new file mode 100644 index 0000000..fa67607 --- /dev/null +++ b/src/api/resources/consumerUsers/client/Client.ts @@ -0,0 +1,166 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Flagright from "../../.."; +import * as serializers from "../../../../serialization"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors"; + +export declare namespace ConsumerUsers { + interface Options { + environment?: core.Supplier; + apiKey: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; + } +} + +export class ConsumerUsers { + constructor(protected readonly _options: ConsumerUsers.Options) {} + + /** + * ## POST Consumer User + * + * `/consumer/user` endpoint allows you to operate on the [Consumer user entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user) + * + * In order to pass the payload of a User to Flagright and verify the User, you will need to call this endpoint with the User 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 + * + * 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 + * + * @throws {@link Flagright.BadRequestError} + * @throws {@link Flagright.UnauthorizedError} + * @throws {@link Flagright.TooManyRequestsError} + */ + public async create( + request: Flagright.User, + requestOptions?: ConsumerUsers.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + "consumer/users" + ), + method: "POST", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + body: await serializers.User.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.ConsumerUsersCreateResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Flagright.BadRequestError(_response.error.body); + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * ### GET Consumer User + * + * `/consumer/user` endpoint allows you to operate on the [Consumer User entity](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#user). + * + * Calling `GET /consumer/user/{userId}` will return the entire user payload and rule execution results for the user with the corresponding `userId` + * @throws {@link Flagright.UnauthorizedError} + * @throws {@link Flagright.TooManyRequestsError} + */ + public async get(userId: string, requestOptions?: ConsumerUsers.RequestOptions): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + `consumer/users/${userId}` + ), + method: "GET", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.UserResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/resources/consumerUsers/client/index.ts b/src/api/resources/consumerUsers/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/consumerUsers/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/consumerUsers/index.ts b/src/api/resources/consumerUsers/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/consumerUsers/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts new file mode 100644 index 0000000..b714505 --- /dev/null +++ b/src/api/resources/index.ts @@ -0,0 +1,9 @@ +export * as transactions from "./transactions"; +export * as transactionEvents from "./transactionEvents"; +export * as consumerUsers from "./consumerUsers"; +export * as businessUsers from "./businessUsers"; +export * as consumerUserEvents from "./consumerUserEvents"; +export * as businessUserEvents from "./businessUserEvents"; +export * from "./transactions/client/requests"; +export * from "./consumerUserEvents/client/requests"; +export * from "./businessUserEvents/client/requests"; diff --git a/src/api/resources/transactionEvents/client/Client.ts b/src/api/resources/transactionEvents/client/Client.ts new file mode 100644 index 0000000..e103ce5 --- /dev/null +++ b/src/api/resources/transactionEvents/client/Client.ts @@ -0,0 +1,178 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Flagright from "../../.."; +import * as serializers from "../../../../serialization"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors"; + +export declare namespace TransactionEvents { + interface Options { + environment?: core.Supplier; + apiKey: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; + } +} + +export class TransactionEvents { + constructor(protected readonly _options: TransactionEvents.Options) {} + + /** + * ## POST Transaction Events + * + * `/events/transaction` endpoint allows you to operate on the [Transaction Events entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#transaction-event) + * + * 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/8c06ae6a3231a-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. + * + * ### Payload + * + * 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. + * + * 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} + */ + public async create( + request: Flagright.TransactionEvent, + requestOptions?: TransactionEvents.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + "events/transaction" + ), + method: "POST", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + body: await serializers.TransactionEvent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.TransactionEventMonitoringResult.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Flagright.BadRequestError(_response.error.body); + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * ### GET Transaction Events + * + * `/events/transaction` endpoint allows you to operate on the [Transaction Events entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-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} + */ + public async get( + eventId: string, + requestOptions?: TransactionEvents.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + `events/transaction/${eventId}` + ), + method: "GET", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.TransactionEvent.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/resources/transactionEvents/client/index.ts b/src/api/resources/transactionEvents/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/transactionEvents/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/transactionEvents/index.ts b/src/api/resources/transactionEvents/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/transactionEvents/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/transactions/client/Client.ts b/src/api/resources/transactions/client/Client.ts new file mode 100644 index 0000000..3ba68f8 --- /dev/null +++ b/src/api/resources/transactions/client/Client.ts @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +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"; + +export declare namespace Transactions { + interface Options { + environment?: core.Supplier; + apiKey: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; + } +} + +export class Transactions { + constructor(protected readonly _options: Transactions.Options) {} + + /** + * ## POST Transactions + * + * `/transactions` endpoint allows you to operate on the [Transaction entity.](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#transaction) + * + * 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/8c06ae6a3231a-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} + */ + public async verify( + request: Flagright.TransactionsVerifyRequest, + requestOptions?: Transactions.RequestOptions + ): Promise { + const { validateOriginUserId, validateDestinationUserId, body: _body } = request; + const _queryParams = new URLSearchParams(); + if (validateOriginUserId != null) { + _queryParams.append("validateOriginUserId", validateOriginUserId); + } + + if (validateDestinationUserId != null) { + _queryParams.append("validateDestinationUserId", validateDestinationUserId); + } + + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + "transactions" + ), + method: "POST", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + queryParameters: _queryParams, + body: await serializers.Transaction.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.TransactionsVerifyResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Flagright.BadRequestError(_response.error.body); + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * ### GET Transactions + * + * `/transactions` endpoint allows you to operate on the [Transaction entity](https://docs.flagright.com/docs/flagright-api/8c06ae6a3231a-entities-and-relationships#transaction). + * + * Calling `GET /transactions/{transactionId}` will return the entire transaction payload and rule execution results for the transaction with the corresponding `transactionId` + * @throws {@link Flagright.UnauthorizedError} + * @throws {@link Flagright.TooManyRequestsError} + */ + public async get( + transactionId: string, + requestOptions?: Transactions.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.FlagrightEnvironment.Default, + `transactions/${transactionId}` + ), + method: "GET", + headers: { + "x-api-key": await core.Supplier.get(this._options.apiKey), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "flagright", + "X-Fern-SDK-Version": "0.1.0", + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.TransactionWithRulesResult.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Flagright.UnauthorizedError(_response.error.body); + case 429: + throw new Flagright.TooManyRequestsError(_response.error.body); + default: + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.FlagrightError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.FlagrightTimeoutError(); + case "unknown": + throw new errors.FlagrightError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/resources/transactions/client/index.ts b/src/api/resources/transactions/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/transactions/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/client/requests/PostConsumerTransactionRequest.ts b/src/api/resources/transactions/client/requests/TransactionsVerifyRequest.ts similarity index 64% rename from src/api/client/requests/PostConsumerTransactionRequest.ts rename to src/api/resources/transactions/client/requests/TransactionsVerifyRequest.ts index 41a1563..3e73185 100644 --- a/src/api/client/requests/PostConsumerTransactionRequest.ts +++ b/src/api/resources/transactions/client/requests/TransactionsVerifyRequest.ts @@ -2,16 +2,16 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from "../.."; +import * as Flagright from "../../../.."; -export interface PostConsumerTransactionRequest { +export interface TransactionsVerifyRequest { /** * Boolean string whether Flagright should validate if provided originUserId exist. True by default */ - validateOriginUserId?: string; + validateOriginUserId?: Flagright.BooleanString; /** * Boolean string whether Flagright should validate if provided destinationUserId exist. True by default */ - validateDestinationUserId?: string; + validateDestinationUserId?: Flagright.BooleanString; body: Flagright.Transaction; } diff --git a/src/api/resources/transactions/client/requests/index.ts b/src/api/resources/transactions/client/requests/index.ts new file mode 100644 index 0000000..bacf981 --- /dev/null +++ b/src/api/resources/transactions/client/requests/index.ts @@ -0,0 +1 @@ +export { TransactionsVerifyRequest } from "./TransactionsVerifyRequest"; diff --git a/src/api/resources/transactions/index.ts b/src/api/resources/transactions/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/transactions/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/types/AlertClosedDetails.ts b/src/api/types/AlertClosedDetails.ts index 42bafbc..fd29e7a 100644 --- a/src/api/types/AlertClosedDetails.ts +++ b/src/api/types/AlertClosedDetails.ts @@ -6,7 +6,7 @@ export interface AlertClosedDetails { alertId?: string; status?: string; reasons?: string[]; - reasonDescriptionForOther?: string[]; + reasonDescriptionForOther?: string; comment?: string; userId?: string; transactionIds?: string[]; diff --git a/src/api/types/BooleanString.ts b/src/api/types/BooleanString.ts new file mode 100644 index 0000000..34602a7 --- /dev/null +++ b/src/api/types/BooleanString.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type BooleanString = "true" | "false"; + +export const BooleanString = { + True: "true", + False: "false", +} as const; diff --git a/src/api/types/Business.ts b/src/api/types/Business.ts index 3a87d73..8dba7e6 100644 --- a/src/api/types/Business.ts +++ b/src/api/types/Business.ts @@ -4,4 +4,25 @@ import * as Flagright from ".."; -export interface Business extends Flagright.BusinessBase, Flagright.BusinessOptional {} +export interface Business { + /** Unique user ID for the user `non-empty` */ + userId: string; + /** Timestamp when the user was created */ + createdTimestamp: number; + legalEntity: Flagright.LegalEntity; + userStateDetails?: Flagright.UserStateDetails; + kycStatusDetails?: Flagright.KycStatusDetails; + /** Shareholders (beneficiaries) of the company that hold at least 25% ownership. Can be another company or an individual */ + shareHolders?: Flagright.Person[]; + /** Director(s) of the company. Must be at least one */ + directors?: Flagright.Person[]; + transactionLimits?: Flagright.TransactionLimits; + riskLevel?: Flagright.RiskLevel; + allowedPaymentMethods?: Flagright.PaymentMethod[]; + linkedEntities?: Flagright.BusinessEntityLink; + acquisitionChannel?: Flagright.AcquisitionChannel; + savedPaymentDetails?: Flagright.BusinessOptionalSavedPaymentDetailsItem[]; + mccDetails?: Flagright.MccDetails; + /** Additional information that can be added via tags */ + tags?: Flagright.Tag[]; +} diff --git a/src/api/types/BusinessBase.ts b/src/api/types/BusinessBase.ts index 96e8548..fd606b3 100644 --- a/src/api/types/BusinessBase.ts +++ b/src/api/types/BusinessBase.ts @@ -2,6 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as Flagright from ".."; + /** * Model for a business user base fields */ @@ -10,4 +12,5 @@ export interface BusinessBase { userId: string; /** Timestamp when the user was created */ createdTimestamp: number; + legalEntity: Flagright.LegalEntity; } diff --git a/src/api/types/BusinessResponse.ts b/src/api/types/BusinessResponse.ts new file mode 100644 index 0000000..bfdd107 --- /dev/null +++ b/src/api/types/BusinessResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Flagright from ".."; + +export interface BusinessResponse extends Flagright.BusinessWithRulesResult { + riskScoreDetails?: Flagright.RiskScoreDetails; +} diff --git a/src/api/types/PostConsumerUserResponse.ts b/src/api/types/BusinessUsersCreateResponse.ts similarity index 66% rename from src/api/types/PostConsumerUserResponse.ts rename to src/api/types/BusinessUsersCreateResponse.ts index 7b7b0ad..9946234 100644 --- a/src/api/types/PostConsumerUserResponse.ts +++ b/src/api/types/BusinessUsersCreateResponse.ts @@ -4,8 +4,9 @@ import * as Flagright from ".."; -export interface PostConsumerUserResponse extends Flagright.RulesResults { +export interface BusinessUsersCreateResponse extends Flagright.RulesResults { message?: string; /** user ID the risk score pertains to `non-empty` */ userId: string; + riskScoreDetails?: Flagright.RiskScoreDetails; } diff --git a/src/api/types/BusinessUsersResponse.ts b/src/api/types/BusinessUsersResponse.ts index 03b6d48..d6bd6d5 100644 --- a/src/api/types/BusinessUsersResponse.ts +++ b/src/api/types/BusinessUsersResponse.ts @@ -2,10 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as Flagright from ".."; + /** * Model for business user risk score response */ export interface BusinessUsersResponse { /** user ID the risk score pertains to `non-empty` */ userId: string; + riskScoreDetails?: Flagright.RiskScoreDetails; } diff --git a/src/api/types/CardDetails.ts b/src/api/types/CardDetails.ts index b306faf..6743cad 100644 --- a/src/api/types/CardDetails.ts +++ b/src/api/types/CardDetails.ts @@ -14,6 +14,8 @@ export interface CardDetails { cardIssuedCountry?: Flagright.CountryCode; /** Reference for the transaction `non-empty` */ transactionReferenceField?: string; + /** Whether 3ds was successfully enforced for the transaction */ + _3DsDone?: boolean; nameOnCard?: Flagright.ConsumerName; cardExpiry?: Flagright.CardExpiry; /** Last 4 digits of Card `<= 4 characters` */ diff --git a/src/api/types/CaseClosedDetails.ts b/src/api/types/CaseClosedDetails.ts index 55593d1..84e6be0 100644 --- a/src/api/types/CaseClosedDetails.ts +++ b/src/api/types/CaseClosedDetails.ts @@ -6,7 +6,7 @@ export interface CaseClosedDetails { caseId?: string; status?: string; reasons?: string[]; - reasonDescriptionForOther?: string[]; + reasonDescriptionForOther?: string; comment?: string; userId?: string; transactionIds?: string[]; diff --git a/src/api/types/CompanyGeneralDetailsUserSegment.ts b/src/api/types/CompanyGeneralDetailsUserSegment.ts index 0b8330c..f6bfd79 100644 --- a/src/api/types/CompanyGeneralDetailsUserSegment.ts +++ b/src/api/types/CompanyGeneralDetailsUserSegment.ts @@ -5,10 +5,18 @@ /** * Segmentation of the business user */ -export type CompanyGeneralDetailsUserSegment = "SOLE_PROPRIETORSHIP" | "SMB" | "SMALL" | "MEDIUM" | "LARGE" | "UNKNOWN"; +export type CompanyGeneralDetailsUserSegment = + | "SOLE_PROPRIETORSHIP" + | "LIMITED" + | "SMB" + | "SMALL" + | "MEDIUM" + | "LARGE" + | "UNKNOWN"; export const CompanyGeneralDetailsUserSegment = { SoleProprietorship: "SOLE_PROPRIETORSHIP", + Limited: "LIMITED", Smb: "SMB", Small: "SMALL", Medium: "MEDIUM", diff --git a/src/api/types/UserOptionalUserSegment.ts b/src/api/types/ConsumerUserSegment.ts similarity index 57% rename from src/api/types/UserOptionalUserSegment.ts rename to src/api/types/ConsumerUserSegment.ts index 0f1d9f8..b2817f2 100644 --- a/src/api/types/UserOptionalUserSegment.ts +++ b/src/api/types/ConsumerUserSegment.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -export type UserOptionalUserSegment = "RETAIL" | "PROFESSIONAL"; +export type ConsumerUserSegment = "RETAIL" | "PROFESSIONAL"; -export const UserOptionalUserSegment = { +export const ConsumerUserSegment = { Retail: "RETAIL", Professional: "PROFESSIONAL", } as const; diff --git a/src/api/types/PostBusinessUserResponse.ts b/src/api/types/ConsumerUsersCreateResponse.ts similarity index 66% rename from src/api/types/PostBusinessUserResponse.ts rename to src/api/types/ConsumerUsersCreateResponse.ts index dd7523a..21acb66 100644 --- a/src/api/types/PostBusinessUserResponse.ts +++ b/src/api/types/ConsumerUsersCreateResponse.ts @@ -4,8 +4,9 @@ import * as Flagright from ".."; -export interface PostBusinessUserResponse extends Flagright.RulesResults { +export interface ConsumerUsersCreateResponse extends Flagright.RulesResults { message?: string; /** user ID the risk score pertains to `non-empty` */ userId: string; + riskScoreDetails?: Flagright.RiskScoreDetails; } diff --git a/src/api/types/ConsumerUsersResponse.ts b/src/api/types/ConsumerUsersResponse.ts index b48d0f6..24cdfaf 100644 --- a/src/api/types/ConsumerUsersResponse.ts +++ b/src/api/types/ConsumerUsersResponse.ts @@ -2,10 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as Flagright from ".."; + /** * Model for consumer user risk score response */ export interface ConsumerUsersResponse { /** user ID the risk score pertains to `non-empty` */ userId: string; + riskScoreDetails?: Flagright.RiskScoreDetails; } diff --git a/src/api/types/CurrencyCode.ts b/src/api/types/CurrencyCode.ts index c086a75..2899f87 100644 --- a/src/api/types/CurrencyCode.ts +++ b/src/api/types/CurrencyCode.ts @@ -275,7 +275,7 @@ export type CurrencyCode = | "ZWL"; export const CurrencyCode = { - One: "1INCH", + OneInch: "1INCH", Aave: "AAVE", Ada: "ADA", Aed: "AED", diff --git a/src/api/types/RiskScoreDetails.ts b/src/api/types/RiskScoreDetails.ts new file mode 100644 index 0000000..a5c4ef3 --- /dev/null +++ b/src/api/types/RiskScoreDetails.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Flagright from ".."; + +export interface RiskScoreDetails { + kycRiskScore?: number; + craRiskScore?: number; + kycRiskLevel?: Flagright.RiskLevel; + craRiskLevel?: Flagright.RiskLevel; +} diff --git a/src/api/types/RiskScoringResult.ts b/src/api/types/RiskScoringResult.ts deleted file mode 100644 index 545e5c3..0000000 --- a/src/api/types/RiskScoringResult.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * Model for results from Risk Scoring - */ -export interface RiskScoringResult { - /** Quantified KYC risk score */ - kycRiskScore: number; - /** Quantified action risk score */ - transactionRiskScore: number; - /** Quantified dynamic risk score */ - customerRiskAssessment?: number; -} diff --git a/src/api/types/SanctionsDetails.ts b/src/api/types/SanctionsDetails.ts index 6d2e3e4..90edd36 100644 --- a/src/api/types/SanctionsDetails.ts +++ b/src/api/types/SanctionsDetails.ts @@ -7,5 +7,6 @@ import * as Flagright from ".."; export interface SanctionsDetails { name: string; searchId: string; + iban?: string; entityType?: Flagright.SanctionsDetailsEntityType; } diff --git a/src/api/types/TransactionBase.ts b/src/api/types/TransactionBase.ts index c2f3a81..b9f2c2d 100644 --- a/src/api/types/TransactionBase.ts +++ b/src/api/types/TransactionBase.ts @@ -8,7 +8,7 @@ import * as Flagright from ".."; * Model for transaction base Payload */ export interface TransactionBase { - type?: Flagright.TransactionType; + type_?: Flagright.TransactionType; /** Unique transaction identifier `non-empty` */ transactionId: string; /** Timestamp of when transaction took place */ diff --git a/src/api/client/requests/TransactionEvent.ts b/src/api/types/TransactionEvent.ts similarity index 88% rename from src/api/client/requests/TransactionEvent.ts rename to src/api/types/TransactionEvent.ts index fc98a44..40c2f7b 100644 --- a/src/api/client/requests/TransactionEvent.ts +++ b/src/api/types/TransactionEvent.ts @@ -2,8 +2,11 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from "../.."; +import * as Flagright from ".."; +/** + * Model for transaction-related events + */ export interface TransactionEvent { transactionState: Flagright.TransactionState; /** Timestamp of the event */ diff --git a/src/api/types/TransactionMonitoringResult.ts b/src/api/types/TransactionMonitoringResult.ts index f96d6ea..da8ba44 100644 --- a/src/api/types/TransactionMonitoringResult.ts +++ b/src/api/types/TransactionMonitoringResult.ts @@ -7,4 +7,5 @@ import * as Flagright from ".."; export interface TransactionMonitoringResult extends Flagright.RulesResults { /** Transaction ID that the results pertain to */ transactionId: string; + status: Flagright.RuleAction; } diff --git a/src/api/types/TransactionStatusDetails.ts b/src/api/types/TransactionStatusDetails.ts new file mode 100644 index 0000000..8d2c076 --- /dev/null +++ b/src/api/types/TransactionStatusDetails.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Flagright from ".."; + +export interface TransactionStatusDetails { + transactionId: string; + reasons: string[]; + status: Flagright.RuleAction; +} diff --git a/src/api/types/TransactionWithRulesResult.ts b/src/api/types/TransactionWithRulesResult.ts index 4399c68..1287a9a 100644 --- a/src/api/types/TransactionWithRulesResult.ts +++ b/src/api/types/TransactionWithRulesResult.ts @@ -10,4 +10,5 @@ import * as Flagright from ".."; export interface TransactionWithRulesResult extends Flagright.Transaction { executedRules: Flagright.ExecutedRulesResult[]; hitRules: Flagright.HitRulesDetails[]; + status: Flagright.RuleAction; } diff --git a/src/api/types/PostConsumerTransactionResponse.ts b/src/api/types/TransactionsVerifyResponse.ts similarity index 57% rename from src/api/types/PostConsumerTransactionResponse.ts rename to src/api/types/TransactionsVerifyResponse.ts index ae5603c..b3bc962 100644 --- a/src/api/types/PostConsumerTransactionResponse.ts +++ b/src/api/types/TransactionsVerifyResponse.ts @@ -4,6 +4,6 @@ import * as Flagright from ".."; -export interface PostConsumerTransactionResponse extends Flagright.TransactionMonitoringResult { +export interface TransactionsVerifyResponse extends Flagright.TransactionMonitoringResult { message?: string; } diff --git a/src/api/types/UserBase.ts b/src/api/types/UserBase.ts index 8e8a4a2..95ccba1 100644 --- a/src/api/types/UserBase.ts +++ b/src/api/types/UserBase.ts @@ -2,15 +2,12 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Flagright from ".."; - /** * Model for User details */ export interface UserBase { /** Unique user ID `non-empty` */ userId: string; - userDetails?: Flagright.UserDetails; /** Timestamp when userId is created */ createdTimestamp: number; } diff --git a/src/api/types/UserOptional.ts b/src/api/types/UserOptional.ts index 2d1eaef..e31395d 100644 --- a/src/api/types/UserOptional.ts +++ b/src/api/types/UserOptional.ts @@ -8,6 +8,7 @@ import * as Flagright from ".."; * Model for User details */ export interface UserOptional { + userDetails?: Flagright.UserDetails; userStateDetails?: Flagright.UserStateDetails; kycStatusDetails?: Flagright.KycStatusDetails; /** User's legal identity documents - See Document Model for details */ @@ -17,7 +18,7 @@ export interface UserOptional { riskLevel?: Flagright.RiskLevel; acquisitionChannel?: Flagright.AcquisitionChannel; reasonForAccountOpening?: string[]; - userSegment?: Flagright.UserOptionalUserSegment; + userSegment?: Flagright.ConsumerUserSegment; pepStatus?: Flagright.PepStatus[]; /** Additional information that can be added via tags */ tags?: Flagright.Tag[]; diff --git a/src/api/types/UserResponse.ts b/src/api/types/UserResponse.ts new file mode 100644 index 0000000..2d5a488 --- /dev/null +++ b/src/api/types/UserResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Flagright from ".."; + +export interface UserResponse extends Flagright.UserWithRulesResult { + riskScoreDetails?: Flagright.RiskScoreDetails; +} diff --git a/src/api/types/UserState.ts b/src/api/types/UserState.ts index b031811..527834e 100644 --- a/src/api/types/UserState.ts +++ b/src/api/types/UserState.ts @@ -2,27 +2,14 @@ * This file was auto-generated by Fern from our API Definition. */ -export type UserState = - | "UNACCEPTABLE" - | "UNDECIDED" - | "TERMINATED" - | "ACTIVE" - | "INACTIVE" - | "DORMANT" - | "CREATED" - | "DELETED" - | "SUSPENDED" - | "BLOCKED"; +export type UserState = "UNACCEPTABLE" | "TERMINATED" | "ACTIVE" | "DORMANT" | "CREATED" | "SUSPENDED" | "BLOCKED"; export const UserState = { Unacceptable: "UNACCEPTABLE", - Undecided: "UNDECIDED", Terminated: "TERMINATED", Active: "ACTIVE", - Inactive: "INACTIVE", Dormant: "DORMANT", Created: "CREATED", - Deleted: "DELETED", Suspended: "SUSPENDED", Blocked: "BLOCKED", } as const; diff --git a/src/api/types/WebhookEvent.ts b/src/api/types/WebhookEvent.ts index 18a22df..f4f5228 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; - data: Flagright.UserStateDetails; + type_: Flagright.WebhookEventType; + data: Flagright.WebhookEventData; createdTimestamp: number; } diff --git a/src/api/types/WebhookEventData.ts b/src/api/types/WebhookEventData.ts new file mode 100644 index 0000000..0543d06 --- /dev/null +++ b/src/api/types/WebhookEventData.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Flagright from ".."; + +export type WebhookEventData = + | Flagright.UserStateDetails + | Flagright.CaseClosedDetails + | Flagright.AlertClosedDetails + | Flagright.TransactionStatusDetails; diff --git a/src/api/types/WebhookEventType.ts b/src/api/types/WebhookEventType.ts index 82c65ea..dc8435e 100644 --- a/src/api/types/WebhookEventType.ts +++ b/src/api/types/WebhookEventType.ts @@ -2,10 +2,11 @@ * This file was auto-generated by Fern from our API Definition. */ -export type WebhookEventType = "CASE_CLOSED" | "USER_STATE_UPDATED" | "ALERT_CLOSED"; +export type WebhookEventType = "CASE_CLOSED" | "USER_STATE_UPDATED" | "ALERT_CLOSED" | "TRANSACTION_STATUS_UPDATED"; export const WebhookEventType = { CaseClosed: "CASE_CLOSED", UserStateUpdated: "USER_STATE_UPDATED", AlertClosed: "ALERT_CLOSED", + TransactionStatusUpdated: "TRANSACTION_STATUS_UPDATED", } as const; diff --git a/src/api/types/index.ts b/src/api/types/index.ts index 9bfda26..e0ee139 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -1,13 +1,14 @@ export * from "./Transaction"; -export * from "./PostConsumerTransactionResponse"; +export * from "./TransactionsVerifyResponse"; +export * from "./TransactionEvent"; export * from "./User"; -export * from "./PostConsumerUserResponse"; +export * from "./ConsumerUsersCreateResponse"; export * from "./Business"; -export * from "./PostBusinessUserResponse"; +export * from "./BusinessUsersCreateResponse"; export * from "./Address"; export * from "./UserBase"; export * from "./UserOptional"; -export * from "./UserOptionalUserSegment"; +export * from "./ConsumerUserSegment"; export * from "./Person"; export * from "./LegalDocument"; export * from "./Tag"; @@ -25,7 +26,6 @@ export * from "./ExecutedRulesResult"; export * from "./HitRulesDetails"; export * from "./FailedRulesResult"; export * from "./RuleFailureException"; -export * from "./RiskScoringResult"; export * from "./ConsumerName"; export * from "./TransactionAmountDetails"; export * from "./Amount"; @@ -84,10 +84,12 @@ export * from "./KycStatusDetails"; export * from "./UserStateDetails"; export * from "./CaseClosedDetails"; export * from "./AlertClosedDetails"; +export * from "./TransactionStatusDetails"; export * from "./RiskLevel"; export * from "./CardExpiry"; export * from "./TransactionType"; export * from "./WebhookEvent"; +export * from "./WebhookEventData"; export * from "./WebhookEventType"; export * from "./ListType"; export * from "./ListSubtype"; @@ -112,4 +114,8 @@ export * from "./SanctionsDetails"; export * from "./SanctionsDetailsEntityType"; export * from "./BusinessEntityLink"; export * from "./UserWithRulesResult"; +export * from "./RiskScoreDetails"; +export * from "./UserResponse"; export * from "./BusinessWithRulesResult"; +export * from "./BusinessResponse"; +export * from "./BooleanString"; diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index 5fe7195..6af0fb1 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -1,5 +1,5 @@ import { default as URLSearchParams } from "@ungap/url-search-params"; -import axios, { AxiosAdapter, AxiosError, AxiosProgressEvent } from "axios"; +import axios, { AxiosAdapter, AxiosError } from "axios"; import { APIResponse } from "./APIResponse"; export type FetchFunction = (args: Fetcher.Args) => Promise>; @@ -16,7 +16,7 @@ export declare namespace Fetcher { withCredentials?: boolean; responseType?: "json" | "blob"; adapter?: AxiosAdapter; - onUploadProgress?: (event: AxiosProgressEvent) => void; + onUploadProgress?: (event: ProgressEvent) => void; } export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; diff --git a/src/core/index.ts b/src/core/index.ts index bdd3645..47bda95 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,2 +1,2 @@ -export * as serialization from "./schemas"; export * from "./fetcher"; +export * as serialization from "./schemas"; diff --git a/src/core/schemas/builders/object/index.ts b/src/core/schemas/builders/object/index.ts index e6db5b5..e3f4388 100644 --- a/src/core/schemas/builders/object/index.ts +++ b/src/core/schemas/builders/object/index.ts @@ -1,4 +1,9 @@ export { getObjectUtils, object } from "./object"; +export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties"; +export type { + inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, + inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, +} from "./objectWithoutOptionalProperties"; export { isProperty, property } from "./property"; export type { Property } from "./property"; export type { diff --git a/src/core/schemas/builders/object/objectWithoutOptionalProperties.ts b/src/core/schemas/builders/object/objectWithoutOptionalProperties.ts new file mode 100644 index 0000000..a0951f4 --- /dev/null +++ b/src/core/schemas/builders/object/objectWithoutOptionalProperties.ts @@ -0,0 +1,18 @@ +import { object } from "./object"; +import { inferParsedPropertySchema, inferRawObjectFromPropertySchemas, ObjectSchema, PropertySchemas } from "./types"; + +export function objectWithoutOptionalProperties>( + schemas: T +): inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas { + return object(schemas) as unknown as inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas; +} + +export type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas> = + ObjectSchema< + inferRawObjectFromPropertySchemas, + inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas + >; + +export type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas> = { + [K in keyof T]: inferParsedPropertySchema; +}; diff --git a/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts b/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts index 9d1a589..771dc6a 100644 --- a/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts +++ b/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts @@ -1,4 +1,4 @@ -import { BaseSchema, MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; +import { BaseSchema, MaybeValid, Schema, SchemaOptions, SchemaType, ValidationError } from "../../Schema"; import { MaybePromise } from "../../utils/MaybePromise"; import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; import { getSchemaUtils } from "../schema-utils"; @@ -13,14 +13,16 @@ export function undiscriminatedUnion, ...Schem > = { parse: async (raw, opts) => { return validateAndTransformUndiscriminatedUnion>( - (schema) => schema.parse(raw, opts), - schemas + (schema, opts) => schema.parse(raw, opts), + schemas, + opts ); }, json: async (parsed, opts) => { return validateAndTransformUndiscriminatedUnion>( - (schema) => schema.json(parsed, opts), - schemas + (schema, opts) => schema.json(parsed, opts), + schemas, + opts ); }, getType: () => SchemaType.UNDISCRIMINATED_UNION, @@ -33,16 +35,17 @@ export function undiscriminatedUnion, ...Schem } async function validateAndTransformUndiscriminatedUnion( - transform: (schema: Schema) => MaybePromise>, - schemas: Schema[] + transform: (schema: Schema, opts: SchemaOptions) => MaybePromise>, + schemas: Schema[], + opts: SchemaOptions | undefined ): Promise> { const errors: ValidationError[] = []; for (const [index, schema] of schemas.entries()) { - const transformed = await transform(schema); + const transformed = await transform(schema, { ...opts, skipValidation: false }); if (transformed.ok) { return transformed; } else { - for (const error of errors) { + for (const error of transformed.errors) { errors.push({ path: error.path, message: `[Variant ${index}] ${error.message}`, diff --git a/src/serialization/client/requests/TransactionEvent.ts b/src/serialization/client/requests/TransactionEvent.ts deleted file mode 100644 index a73009b..0000000 --- a/src/serialization/client/requests/TransactionEvent.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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"; - -export const TransactionEvent: core.serialization.Schema = - core.serialization.object({ - transactionState: core.serialization.lazy(async () => (await import("../..")).TransactionState), - timestamp: core.serialization.number(), - transactionId: core.serialization.string(), - eventId: core.serialization.string().optional(), - reason: core.serialization.string().optional(), - eventDescription: core.serialization.string().optional(), - updatedTransactionAttributes: core.serialization - .lazyObject(async () => (await import("../..")).TransactionUpdatable) - .optional(), - metaData: core.serialization.lazyObject(async () => (await import("../..")).DeviceData).optional(), - }); - -export declare namespace TransactionEvent { - interface Raw { - transactionState: serializers.TransactionState.Raw; - timestamp: number; - transactionId: string; - eventId?: string | null; - reason?: string | null; - eventDescription?: string | null; - updatedTransactionAttributes?: serializers.TransactionUpdatable.Raw | null; - metaData?: serializers.DeviceData.Raw | null; - } -} diff --git a/src/serialization/client/requests/index.ts b/src/serialization/client/requests/index.ts deleted file mode 100644 index 17c1b0e..0000000 --- a/src/serialization/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { TransactionEvent } from "./TransactionEvent"; -export { ConsumerUserEvent } from "./ConsumerUserEvent"; -export { BusinessUserEvent } from "./BusinessUserEvent"; diff --git a/src/serialization/index.ts b/src/serialization/index.ts index c9240f8..3ce0a3e 100644 --- a/src/serialization/index.ts +++ b/src/serialization/index.ts @@ -1,2 +1,2 @@ export * from "./types"; -export * from "./client"; +export * from "./resources"; diff --git a/src/serialization/resources/businessUserEvents/client/index.ts b/src/serialization/resources/businessUserEvents/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/businessUserEvents/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/client/requests/BusinessUserEvent.ts b/src/serialization/resources/businessUserEvents/client/requests/BusinessUserEvent.ts similarity index 75% rename from src/serialization/client/requests/BusinessUserEvent.ts rename to src/serialization/resources/businessUserEvents/client/requests/BusinessUserEvent.ts index 77a05a5..8831d46 100644 --- a/src/serialization/client/requests/BusinessUserEvent.ts +++ b/src/serialization/resources/businessUserEvents/client/requests/BusinessUserEvent.ts @@ -2,13 +2,13 @@ * 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 BusinessUserEvent: core.serialization.Schema< serializers.BusinessUserEvent.Raw, - Flagright.BusinessUserEvent + Omit > = core.serialization.object({ timestamp: core.serialization.number(), userId: core.serialization.string(), @@ -16,7 +16,7 @@ export const BusinessUserEvent: core.serialization.Schema< reason: core.serialization.string().optional(), eventDescription: core.serialization.string().optional(), updatedBusinessUserAttributes: core.serialization - .lazyObject(async () => (await import("../..")).BusinessOptional) + .lazyObject(async () => (await import("../../../..")).BusinessOptional) .optional(), }); diff --git a/src/serialization/resources/businessUserEvents/client/requests/index.ts b/src/serialization/resources/businessUserEvents/client/requests/index.ts new file mode 100644 index 0000000..90c67bf --- /dev/null +++ b/src/serialization/resources/businessUserEvents/client/requests/index.ts @@ -0,0 +1 @@ +export { BusinessUserEvent } from "./BusinessUserEvent"; diff --git a/src/serialization/resources/businessUserEvents/index.ts b/src/serialization/resources/businessUserEvents/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/serialization/resources/businessUserEvents/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/serialization/resources/consumerUserEvents/client/index.ts b/src/serialization/resources/consumerUserEvents/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/consumerUserEvents/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/client/requests/ConsumerUserEvent.ts b/src/serialization/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts similarity index 75% rename from src/serialization/client/requests/ConsumerUserEvent.ts rename to src/serialization/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts index abb38be..2817280 100644 --- a/src/serialization/client/requests/ConsumerUserEvent.ts +++ b/src/serialization/resources/consumerUserEvents/client/requests/ConsumerUserEvent.ts @@ -2,13 +2,13 @@ * 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 ConsumerUserEvent: core.serialization.Schema< serializers.ConsumerUserEvent.Raw, - Flagright.ConsumerUserEvent + Omit > = core.serialization.object({ timestamp: core.serialization.number(), userId: core.serialization.string(), @@ -16,7 +16,7 @@ export const ConsumerUserEvent: core.serialization.Schema< reason: core.serialization.string().optional(), eventDescription: core.serialization.string().optional(), updatedConsumerUserAttributes: core.serialization - .lazyObject(async () => (await import("../..")).UserOptional) + .lazyObject(async () => (await import("../../../..")).UserOptional) .optional(), }); diff --git a/src/serialization/resources/consumerUserEvents/client/requests/index.ts b/src/serialization/resources/consumerUserEvents/client/requests/index.ts new file mode 100644 index 0000000..30feeac --- /dev/null +++ b/src/serialization/resources/consumerUserEvents/client/requests/index.ts @@ -0,0 +1 @@ +export { ConsumerUserEvent } from "./ConsumerUserEvent"; diff --git a/src/serialization/resources/consumerUserEvents/index.ts b/src/serialization/resources/consumerUserEvents/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/serialization/resources/consumerUserEvents/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts new file mode 100644 index 0000000..ff6a43a --- /dev/null +++ b/src/serialization/resources/index.ts @@ -0,0 +1,4 @@ +export * as consumerUserEvents from "./consumerUserEvents"; +export * from "./consumerUserEvents/client/requests"; +export * as businessUserEvents from "./businessUserEvents"; +export * from "./businessUserEvents/client/requests"; diff --git a/src/serialization/types/AlertClosedDetails.ts b/src/serialization/types/AlertClosedDetails.ts index 103017b..fc1c402 100644 --- a/src/serialization/types/AlertClosedDetails.ts +++ b/src/serialization/types/AlertClosedDetails.ts @@ -13,7 +13,7 @@ export const AlertClosedDetails: core.serialization.ObjectSchema< alertId: core.serialization.string().optional(), status: core.serialization.string().optional(), reasons: core.serialization.list(core.serialization.string()).optional(), - reasonDescriptionForOther: core.serialization.list(core.serialization.string()).optional(), + reasonDescriptionForOther: core.serialization.string().optional(), comment: core.serialization.string().optional(), userId: core.serialization.string().optional(), transactionIds: core.serialization.list(core.serialization.string()).optional(), @@ -28,7 +28,7 @@ export declare namespace AlertClosedDetails { alertId?: string | null; status?: string | null; reasons?: string[] | null; - reasonDescriptionForOther?: string[] | null; + reasonDescriptionForOther?: string | null; comment?: string | null; userId?: string | null; transactionIds?: string[] | null; diff --git a/src/serialization/types/BooleanString.ts b/src/serialization/types/BooleanString.ts new file mode 100644 index 0000000..99a753d --- /dev/null +++ b/src/serialization/types/BooleanString.ts @@ -0,0 +1,14 @@ +/** + * 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"; + +export const BooleanString: core.serialization.Schema = + core.serialization.enum_(["true", "false"]); + +export declare namespace BooleanString { + type Raw = "true" | "false"; +} diff --git a/src/serialization/types/Business.ts b/src/serialization/types/Business.ts index c71902f..3dfe06a 100644 --- a/src/serialization/types/Business.ts +++ b/src/serialization/types/Business.ts @@ -7,11 +7,48 @@ import * as Flagright from "../../api"; import * as core from "../../core"; export const Business: core.serialization.ObjectSchema = - core.serialization - .object({}) - .extend(core.serialization.lazyObject(async () => (await import("..")).BusinessBase)) - .extend(core.serialization.lazyObject(async () => (await import("..")).BusinessOptional)); + core.serialization.object({ + userId: core.serialization.string(), + createdTimestamp: core.serialization.number(), + legalEntity: core.serialization.lazyObject(async () => (await import("..")).LegalEntity), + userStateDetails: core.serialization.lazyObject(async () => (await import("..")).UserStateDetails).optional(), + kycStatusDetails: core.serialization.lazyObject(async () => (await import("..")).KycStatusDetails).optional(), + shareHolders: core.serialization + .list(core.serialization.lazyObject(async () => (await import("..")).Person)) + .optional(), + directors: core.serialization + .list(core.serialization.lazyObject(async () => (await import("..")).Person)) + .optional(), + transactionLimits: core.serialization.lazyObject(async () => (await import("..")).TransactionLimits).optional(), + riskLevel: core.serialization.lazy(async () => (await import("..")).RiskLevel).optional(), + allowedPaymentMethods: core.serialization + .list(core.serialization.lazy(async () => (await import("..")).PaymentMethod)) + .optional(), + linkedEntities: core.serialization.lazyObject(async () => (await import("..")).BusinessEntityLink).optional(), + acquisitionChannel: core.serialization.lazy(async () => (await import("..")).AcquisitionChannel).optional(), + savedPaymentDetails: core.serialization + .list(core.serialization.lazy(async () => (await import("..")).BusinessOptionalSavedPaymentDetailsItem)) + .optional(), + mccDetails: core.serialization.lazyObject(async () => (await import("..")).MccDetails).optional(), + tags: core.serialization.list(core.serialization.lazyObject(async () => (await import("..")).Tag)).optional(), + }); export declare namespace Business { - interface Raw extends serializers.BusinessBase.Raw, serializers.BusinessOptional.Raw {} + interface Raw { + userId: string; + createdTimestamp: number; + legalEntity: serializers.LegalEntity.Raw; + userStateDetails?: serializers.UserStateDetails.Raw | null; + kycStatusDetails?: serializers.KycStatusDetails.Raw | null; + shareHolders?: serializers.Person.Raw[] | null; + directors?: serializers.Person.Raw[] | null; + transactionLimits?: serializers.TransactionLimits.Raw | null; + riskLevel?: serializers.RiskLevel.Raw | null; + allowedPaymentMethods?: serializers.PaymentMethod.Raw[] | null; + linkedEntities?: serializers.BusinessEntityLink.Raw | null; + acquisitionChannel?: serializers.AcquisitionChannel.Raw | null; + savedPaymentDetails?: serializers.BusinessOptionalSavedPaymentDetailsItem.Raw[] | null; + mccDetails?: serializers.MccDetails.Raw | null; + tags?: serializers.Tag.Raw[] | null; + } } diff --git a/src/serialization/types/BusinessBase.ts b/src/serialization/types/BusinessBase.ts index 832655a..b89844e 100644 --- a/src/serialization/types/BusinessBase.ts +++ b/src/serialization/types/BusinessBase.ts @@ -10,11 +10,13 @@ export const BusinessBase: core.serialization.ObjectSchema (await import("..")).LegalEntity), }); export declare namespace BusinessBase { interface Raw { userId: string; createdTimestamp: number; + legalEntity: serializers.LegalEntity.Raw; } } diff --git a/src/serialization/types/BusinessResponse.ts b/src/serialization/types/BusinessResponse.ts new file mode 100644 index 0000000..2ae6661 --- /dev/null +++ b/src/serialization/types/BusinessResponse.ts @@ -0,0 +1,22 @@ +/** + * 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"; + +export const BusinessResponse: core.serialization.ObjectSchema< + serializers.BusinessResponse.Raw, + Flagright.BusinessResponse +> = core.serialization + .object({ + riskScoreDetails: core.serialization.lazyObject(async () => (await import("..")).RiskScoreDetails).optional(), + }) + .extend(core.serialization.lazyObject(async () => (await import("..")).BusinessWithRulesResult)); + +export declare namespace BusinessResponse { + interface Raw extends serializers.BusinessWithRulesResult.Raw { + riskScoreDetails?: serializers.RiskScoreDetails.Raw | null; + } +} diff --git a/src/serialization/types/PostConsumerUserResponse.ts b/src/serialization/types/BusinessUsersCreateResponse.ts similarity index 57% rename from src/serialization/types/PostConsumerUserResponse.ts rename to src/serialization/types/BusinessUsersCreateResponse.ts index 8cfe8cb..55c3d81 100644 --- a/src/serialization/types/PostConsumerUserResponse.ts +++ b/src/serialization/types/BusinessUsersCreateResponse.ts @@ -6,19 +6,21 @@ import * as serializers from ".."; import * as Flagright from "../../api"; import * as core from "../../core"; -export const PostConsumerUserResponse: core.serialization.ObjectSchema< - serializers.PostConsumerUserResponse.Raw, - Flagright.PostConsumerUserResponse +export const BusinessUsersCreateResponse: core.serialization.ObjectSchema< + serializers.BusinessUsersCreateResponse.Raw, + Flagright.BusinessUsersCreateResponse > = core.serialization .object({ message: core.serialization.string().optional(), userId: core.serialization.string(), + riskScoreDetails: core.serialization.lazyObject(async () => (await import("..")).RiskScoreDetails).optional(), }) .extend(core.serialization.lazyObject(async () => (await import("..")).RulesResults)); -export declare namespace PostConsumerUserResponse { +export declare namespace BusinessUsersCreateResponse { interface Raw extends serializers.RulesResults.Raw { message?: string | null; userId: string; + riskScoreDetails?: serializers.RiskScoreDetails.Raw | null; } } diff --git a/src/serialization/types/BusinessUsersResponse.ts b/src/serialization/types/BusinessUsersResponse.ts index 07d4fe0..7456e2e 100644 --- a/src/serialization/types/BusinessUsersResponse.ts +++ b/src/serialization/types/BusinessUsersResponse.ts @@ -11,10 +11,12 @@ export const BusinessUsersResponse: core.serialization.ObjectSchema< Flagright.BusinessUsersResponse > = core.serialization.object({ userId: core.serialization.string(), + riskScoreDetails: core.serialization.lazyObject(async () => (await import("..")).RiskScoreDetails).optional(), }); export declare namespace BusinessUsersResponse { interface Raw { userId: string; + riskScoreDetails?: serializers.RiskScoreDetails.Raw | null; } } diff --git a/src/serialization/types/CardDetails.ts b/src/serialization/types/CardDetails.ts index 17e8669..1ac3f65 100644 --- a/src/serialization/types/CardDetails.ts +++ b/src/serialization/types/CardDetails.ts @@ -12,6 +12,7 @@ export const CardDetails: core.serialization.ObjectSchema (await import("..")).CountryCode).optional(), transactionReferenceField: core.serialization.string().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(), @@ -29,6 +30,7 @@ export declare namespace CardDetails { cardFingerprint?: string | null; cardIssuedCountry?: serializers.CountryCode.Raw | null; transactionReferenceField?: string | null; + "3dsDone"?: boolean | null; nameOnCard?: serializers.ConsumerName.Raw | null; cardExpiry?: serializers.CardExpiry.Raw | null; cardLast4Digits?: string | null; diff --git a/src/serialization/types/CaseClosedDetails.ts b/src/serialization/types/CaseClosedDetails.ts index 730f159..a18fa83 100644 --- a/src/serialization/types/CaseClosedDetails.ts +++ b/src/serialization/types/CaseClosedDetails.ts @@ -13,7 +13,7 @@ export const CaseClosedDetails: core.serialization.ObjectSchema< caseId: core.serialization.string().optional(), status: core.serialization.string().optional(), reasons: core.serialization.list(core.serialization.string()).optional(), - reasonDescriptionForOther: core.serialization.list(core.serialization.string()).optional(), + reasonDescriptionForOther: core.serialization.string().optional(), comment: core.serialization.string().optional(), userId: core.serialization.string().optional(), transactionIds: core.serialization.list(core.serialization.string()).optional(), @@ -24,7 +24,7 @@ export declare namespace CaseClosedDetails { caseId?: string | null; status?: string | null; reasons?: string[] | null; - reasonDescriptionForOther?: string[] | null; + reasonDescriptionForOther?: string | null; comment?: string | null; userId?: string | null; transactionIds?: string[] | null; diff --git a/src/serialization/types/CompanyGeneralDetailsUserSegment.ts b/src/serialization/types/CompanyGeneralDetailsUserSegment.ts index f56013c..b20aba9 100644 --- a/src/serialization/types/CompanyGeneralDetailsUserSegment.ts +++ b/src/serialization/types/CompanyGeneralDetailsUserSegment.ts @@ -9,8 +9,8 @@ import * as core from "../../core"; export const CompanyGeneralDetailsUserSegment: core.serialization.Schema< serializers.CompanyGeneralDetailsUserSegment.Raw, Flagright.CompanyGeneralDetailsUserSegment -> = core.serialization.enum_(["SOLE_PROPRIETORSHIP", "SMB", "SMALL", "MEDIUM", "LARGE", "UNKNOWN"]); +> = core.serialization.enum_(["SOLE_PROPRIETORSHIP", "LIMITED", "SMB", "SMALL", "MEDIUM", "LARGE", "UNKNOWN"]); export declare namespace CompanyGeneralDetailsUserSegment { - type Raw = "SOLE_PROPRIETORSHIP" | "SMB" | "SMALL" | "MEDIUM" | "LARGE" | "UNKNOWN"; + type Raw = "SOLE_PROPRIETORSHIP" | "LIMITED" | "SMB" | "SMALL" | "MEDIUM" | "LARGE" | "UNKNOWN"; } diff --git a/src/serialization/types/UserOptionalUserSegment.ts b/src/serialization/types/ConsumerUserSegment.ts similarity index 59% rename from src/serialization/types/UserOptionalUserSegment.ts rename to src/serialization/types/ConsumerUserSegment.ts index fb7539b..05b4363 100644 --- a/src/serialization/types/UserOptionalUserSegment.ts +++ b/src/serialization/types/ConsumerUserSegment.ts @@ -6,11 +6,11 @@ import * as serializers from ".."; import * as Flagright from "../../api"; import * as core from "../../core"; -export const UserOptionalUserSegment: core.serialization.Schema< - serializers.UserOptionalUserSegment.Raw, - Flagright.UserOptionalUserSegment +export const ConsumerUserSegment: core.serialization.Schema< + serializers.ConsumerUserSegment.Raw, + Flagright.ConsumerUserSegment > = core.serialization.enum_(["RETAIL", "PROFESSIONAL"]); -export declare namespace UserOptionalUserSegment { +export declare namespace ConsumerUserSegment { type Raw = "RETAIL" | "PROFESSIONAL"; } diff --git a/src/serialization/types/PostBusinessUserResponse.ts b/src/serialization/types/ConsumerUsersCreateResponse.ts similarity index 57% rename from src/serialization/types/PostBusinessUserResponse.ts rename to src/serialization/types/ConsumerUsersCreateResponse.ts index 038321b..15ad1b1 100644 --- a/src/serialization/types/PostBusinessUserResponse.ts +++ b/src/serialization/types/ConsumerUsersCreateResponse.ts @@ -6,19 +6,21 @@ import * as serializers from ".."; import * as Flagright from "../../api"; import * as core from "../../core"; -export const PostBusinessUserResponse: core.serialization.ObjectSchema< - serializers.PostBusinessUserResponse.Raw, - Flagright.PostBusinessUserResponse +export const ConsumerUsersCreateResponse: core.serialization.ObjectSchema< + serializers.ConsumerUsersCreateResponse.Raw, + Flagright.ConsumerUsersCreateResponse > = core.serialization .object({ message: core.serialization.string().optional(), userId: core.serialization.string(), + riskScoreDetails: core.serialization.lazyObject(async () => (await import("..")).RiskScoreDetails).optional(), }) .extend(core.serialization.lazyObject(async () => (await import("..")).RulesResults)); -export declare namespace PostBusinessUserResponse { +export declare namespace ConsumerUsersCreateResponse { interface Raw extends serializers.RulesResults.Raw { message?: string | null; userId: string; + riskScoreDetails?: serializers.RiskScoreDetails.Raw | null; } } diff --git a/src/serialization/types/ConsumerUsersResponse.ts b/src/serialization/types/ConsumerUsersResponse.ts index e69564f..5e673f8 100644 --- a/src/serialization/types/ConsumerUsersResponse.ts +++ b/src/serialization/types/ConsumerUsersResponse.ts @@ -11,10 +11,12 @@ export const ConsumerUsersResponse: core.serialization.ObjectSchema< Flagright.ConsumerUsersResponse > = core.serialization.object({ userId: core.serialization.string(), + riskScoreDetails: core.serialization.lazyObject(async () => (await import("..")).RiskScoreDetails).optional(), }); export declare namespace ConsumerUsersResponse { interface Raw { userId: string; + riskScoreDetails?: serializers.RiskScoreDetails.Raw | null; } } diff --git a/src/serialization/types/RiskScoreDetails.ts b/src/serialization/types/RiskScoreDetails.ts new file mode 100644 index 0000000..c04fbef --- /dev/null +++ b/src/serialization/types/RiskScoreDetails.ts @@ -0,0 +1,26 @@ +/** + * 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"; + +export const RiskScoreDetails: core.serialization.ObjectSchema< + serializers.RiskScoreDetails.Raw, + Flagright.RiskScoreDetails +> = core.serialization.object({ + kycRiskScore: core.serialization.number().optional(), + craRiskScore: core.serialization.number().optional(), + kycRiskLevel: core.serialization.lazy(async () => (await import("..")).RiskLevel).optional(), + craRiskLevel: core.serialization.lazy(async () => (await import("..")).RiskLevel).optional(), +}); + +export declare namespace RiskScoreDetails { + interface Raw { + kycRiskScore?: number | null; + craRiskScore?: number | null; + kycRiskLevel?: serializers.RiskLevel.Raw | null; + craRiskLevel?: serializers.RiskLevel.Raw | null; + } +} diff --git a/src/serialization/types/RiskScoringResult.ts b/src/serialization/types/RiskScoringResult.ts deleted file mode 100644 index 8ac8c1b..0000000 --- a/src/serialization/types/RiskScoringResult.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 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"; - -export const RiskScoringResult: core.serialization.ObjectSchema< - serializers.RiskScoringResult.Raw, - Flagright.RiskScoringResult -> = core.serialization.object({ - kycRiskScore: core.serialization.number(), - transactionRiskScore: core.serialization.number(), - customerRiskAssessment: core.serialization.number().optional(), -}); - -export declare namespace RiskScoringResult { - interface Raw { - kycRiskScore: number; - transactionRiskScore: number; - customerRiskAssessment?: number | null; - } -} diff --git a/src/serialization/types/SanctionsDetails.ts b/src/serialization/types/SanctionsDetails.ts index a506296..0e1c364 100644 --- a/src/serialization/types/SanctionsDetails.ts +++ b/src/serialization/types/SanctionsDetails.ts @@ -12,6 +12,7 @@ export const SanctionsDetails: core.serialization.ObjectSchema< > = core.serialization.object({ name: core.serialization.string(), searchId: core.serialization.string(), + iban: core.serialization.string().optional(), entityType: core.serialization.lazy(async () => (await import("..")).SanctionsDetailsEntityType).optional(), }); @@ -19,6 +20,7 @@ export declare namespace SanctionsDetails { interface Raw { name: string; searchId: string; + iban?: string | null; entityType?: serializers.SanctionsDetailsEntityType.Raw | null; } } diff --git a/src/serialization/types/TransactionBase.ts b/src/serialization/types/TransactionBase.ts index 099f123..ca33e8f 100644 --- a/src/serialization/types/TransactionBase.ts +++ b/src/serialization/types/TransactionBase.ts @@ -10,7 +10,10 @@ export const TransactionBase: core.serialization.ObjectSchema< serializers.TransactionBase.Raw, Flagright.TransactionBase > = core.serialization.object({ - type: core.serialization.lazy(async () => (await import("..")).TransactionType).optional(), + type_: core.serialization.property( + "type", + core.serialization.lazy(async () => (await import("..")).TransactionType).optional() + ), transactionId: core.serialization.string(), timestamp: core.serialization.number(), originUserId: core.serialization.string().optional(), diff --git a/src/serialization/types/TransactionEvent.ts b/src/serialization/types/TransactionEvent.ts new file mode 100644 index 0000000..48bc0ce --- /dev/null +++ b/src/serialization/types/TransactionEvent.ts @@ -0,0 +1,36 @@ +/** + * 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"; + +export const TransactionEvent: core.serialization.ObjectSchema< + serializers.TransactionEvent.Raw, + Flagright.TransactionEvent +> = core.serialization.object({ + transactionState: core.serialization.lazy(async () => (await import("..")).TransactionState), + timestamp: core.serialization.number(), + transactionId: core.serialization.string(), + eventId: core.serialization.string().optional(), + reason: core.serialization.string().optional(), + eventDescription: core.serialization.string().optional(), + updatedTransactionAttributes: core.serialization + .lazyObject(async () => (await import("..")).TransactionUpdatable) + .optional(), + metaData: core.serialization.lazyObject(async () => (await import("..")).DeviceData).optional(), +}); + +export declare namespace TransactionEvent { + interface Raw { + transactionState: serializers.TransactionState.Raw; + timestamp: number; + transactionId: string; + eventId?: string | null; + reason?: string | null; + eventDescription?: string | null; + updatedTransactionAttributes?: serializers.TransactionUpdatable.Raw | null; + metaData?: serializers.DeviceData.Raw | null; + } +} diff --git a/src/serialization/types/TransactionMonitoringResult.ts b/src/serialization/types/TransactionMonitoringResult.ts index 932afce..36cd95c 100644 --- a/src/serialization/types/TransactionMonitoringResult.ts +++ b/src/serialization/types/TransactionMonitoringResult.ts @@ -12,11 +12,13 @@ export const TransactionMonitoringResult: core.serialization.ObjectSchema< > = core.serialization .object({ transactionId: core.serialization.string(), + status: core.serialization.lazy(async () => (await import("..")).RuleAction), }) .extend(core.serialization.lazyObject(async () => (await import("..")).RulesResults)); export declare namespace TransactionMonitoringResult { interface Raw extends serializers.RulesResults.Raw { transactionId: string; + status: serializers.RuleAction.Raw; } } diff --git a/src/serialization/types/TransactionStatusDetails.ts b/src/serialization/types/TransactionStatusDetails.ts new file mode 100644 index 0000000..38a483f --- /dev/null +++ b/src/serialization/types/TransactionStatusDetails.ts @@ -0,0 +1,24 @@ +/** + * 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"; + +export const TransactionStatusDetails: core.serialization.ObjectSchema< + serializers.TransactionStatusDetails.Raw, + Flagright.TransactionStatusDetails +> = core.serialization.object({ + transactionId: core.serialization.string(), + reasons: core.serialization.list(core.serialization.string()), + status: core.serialization.lazy(async () => (await import("..")).RuleAction), +}); + +export declare namespace TransactionStatusDetails { + interface Raw { + transactionId: string; + reasons: string[]; + status: serializers.RuleAction.Raw; + } +} diff --git a/src/serialization/types/TransactionWithRulesResult.ts b/src/serialization/types/TransactionWithRulesResult.ts index 6e812a6..e4a6090 100644 --- a/src/serialization/types/TransactionWithRulesResult.ts +++ b/src/serialization/types/TransactionWithRulesResult.ts @@ -17,6 +17,7 @@ export const TransactionWithRulesResult: core.serialization.ObjectSchema< hitRules: core.serialization.list( core.serialization.lazyObject(async () => (await import("..")).HitRulesDetails) ), + status: core.serialization.lazy(async () => (await import("..")).RuleAction), }) .extend(core.serialization.lazyObject(async () => (await import("..")).Transaction)); @@ -24,5 +25,6 @@ export declare namespace TransactionWithRulesResult { interface Raw extends serializers.Transaction.Raw { executedRules: serializers.ExecutedRulesResult.Raw[]; hitRules: serializers.HitRulesDetails.Raw[]; + status: serializers.RuleAction.Raw; } } diff --git a/src/serialization/types/PostConsumerTransactionResponse.ts b/src/serialization/types/TransactionsVerifyResponse.ts similarity index 68% rename from src/serialization/types/PostConsumerTransactionResponse.ts rename to src/serialization/types/TransactionsVerifyResponse.ts index 69d97c0..485c4dc 100644 --- a/src/serialization/types/PostConsumerTransactionResponse.ts +++ b/src/serialization/types/TransactionsVerifyResponse.ts @@ -6,16 +6,16 @@ import * as serializers from ".."; import * as Flagright from "../../api"; import * as core from "../../core"; -export const PostConsumerTransactionResponse: core.serialization.ObjectSchema< - serializers.PostConsumerTransactionResponse.Raw, - Flagright.PostConsumerTransactionResponse +export const TransactionsVerifyResponse: core.serialization.ObjectSchema< + serializers.TransactionsVerifyResponse.Raw, + Flagright.TransactionsVerifyResponse > = core.serialization .object({ message: core.serialization.string().optional(), }) .extend(core.serialization.lazyObject(async () => (await import("..")).TransactionMonitoringResult)); -export declare namespace PostConsumerTransactionResponse { +export declare namespace TransactionsVerifyResponse { interface Raw extends serializers.TransactionMonitoringResult.Raw { message?: string | null; } diff --git a/src/serialization/types/UserBase.ts b/src/serialization/types/UserBase.ts index 7bc0e4a..b6288e0 100644 --- a/src/serialization/types/UserBase.ts +++ b/src/serialization/types/UserBase.ts @@ -9,14 +9,12 @@ import * as core from "../../core"; export const UserBase: core.serialization.ObjectSchema = core.serialization.object({ userId: core.serialization.string(), - userDetails: core.serialization.lazyObject(async () => (await import("..")).UserDetails).optional(), createdTimestamp: core.serialization.number(), }); export declare namespace UserBase { interface Raw { userId: string; - userDetails?: serializers.UserDetails.Raw | null; createdTimestamp: number; } } diff --git a/src/serialization/types/UserOptional.ts b/src/serialization/types/UserOptional.ts index f2a4f3c..e3cd95d 100644 --- a/src/serialization/types/UserOptional.ts +++ b/src/serialization/types/UserOptional.ts @@ -8,6 +8,7 @@ import * as core from "../../core"; export const UserOptional: core.serialization.ObjectSchema = core.serialization.object({ + userDetails: core.serialization.lazyObject(async () => (await import("..")).UserDetails).optional(), userStateDetails: core.serialization.lazyObject(async () => (await import("..")).UserStateDetails).optional(), kycStatusDetails: core.serialization.lazyObject(async () => (await import("..")).KycStatusDetails).optional(), legalDocuments: core.serialization @@ -18,7 +19,7 @@ export const UserOptional: core.serialization.ObjectSchema (await import("..")).RiskLevel).optional(), acquisitionChannel: core.serialization.lazy(async () => (await import("..")).AcquisitionChannel).optional(), reasonForAccountOpening: core.serialization.list(core.serialization.string()).optional(), - userSegment: core.serialization.lazy(async () => (await import("..")).UserOptionalUserSegment).optional(), + userSegment: core.serialization.lazy(async () => (await import("..")).ConsumerUserSegment).optional(), pepStatus: core.serialization .list(core.serialization.lazyObject(async () => (await import("..")).PepStatus)) .optional(), @@ -27,6 +28,7 @@ export const UserOptional: core.serialization.ObjectSchema = + core.serialization + .object({ + riskScoreDetails: core.serialization + .lazyObject(async () => (await import("..")).RiskScoreDetails) + .optional(), + }) + .extend(core.serialization.lazyObject(async () => (await import("..")).UserWithRulesResult)); + +export declare namespace UserResponse { + interface Raw extends serializers.UserWithRulesResult.Raw { + riskScoreDetails?: serializers.RiskScoreDetails.Raw | null; + } +} diff --git a/src/serialization/types/UserState.ts b/src/serialization/types/UserState.ts index 33c06a3..208e69c 100644 --- a/src/serialization/types/UserState.ts +++ b/src/serialization/types/UserState.ts @@ -7,29 +7,8 @@ import * as Flagright from "../../api"; import * as core from "../../core"; export const UserState: core.serialization.Schema = - core.serialization.enum_([ - "UNACCEPTABLE", - "UNDECIDED", - "TERMINATED", - "ACTIVE", - "INACTIVE", - "DORMANT", - "CREATED", - "DELETED", - "SUSPENDED", - "BLOCKED", - ]); + core.serialization.enum_(["UNACCEPTABLE", "TERMINATED", "ACTIVE", "DORMANT", "CREATED", "SUSPENDED", "BLOCKED"]); export declare namespace UserState { - type Raw = - | "UNACCEPTABLE" - | "UNDECIDED" - | "TERMINATED" - | "ACTIVE" - | "INACTIVE" - | "DORMANT" - | "CREATED" - | "DELETED" - | "SUSPENDED" - | "BLOCKED"; + type Raw = "UNACCEPTABLE" | "TERMINATED" | "ACTIVE" | "DORMANT" | "CREATED" | "SUSPENDED" | "BLOCKED"; } diff --git a/src/serialization/types/WebhookEvent.ts b/src/serialization/types/WebhookEvent.ts index d6e8032..28fe5fa 100644 --- a/src/serialization/types/WebhookEvent.ts +++ b/src/serialization/types/WebhookEvent.ts @@ -9,8 +9,11 @@ import * as core from "../../core"; export const WebhookEvent: core.serialization.ObjectSchema = core.serialization.object({ id: core.serialization.string(), - type: core.serialization.lazy(async () => (await import("..")).WebhookEventType), - data: core.serialization.lazyObject(async () => (await import("..")).UserStateDetails), + type_: core.serialization.property( + "type", + core.serialization.lazy(async () => (await import("..")).WebhookEventType) + ), + data: core.serialization.lazy(async () => (await import("..")).WebhookEventData), createdTimestamp: core.serialization.number(), }); @@ -18,7 +21,7 @@ export declare namespace WebhookEvent { interface Raw { id: string; type: serializers.WebhookEventType.Raw; - data: serializers.UserStateDetails.Raw; + data: serializers.WebhookEventData.Raw; createdTimestamp: number; } } diff --git a/src/serialization/types/WebhookEventData.ts b/src/serialization/types/WebhookEventData.ts new file mode 100644 index 0000000..9b5468d --- /dev/null +++ b/src/serialization/types/WebhookEventData.ts @@ -0,0 +1,23 @@ +/** + * 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"; + +export const WebhookEventData: core.serialization.Schema = + core.serialization.undiscriminatedUnion([ + core.serialization.lazyObject(async () => (await import("..")).UserStateDetails), + core.serialization.lazyObject(async () => (await import("..")).CaseClosedDetails), + core.serialization.lazyObject(async () => (await import("..")).AlertClosedDetails), + core.serialization.lazyObject(async () => (await import("..")).TransactionStatusDetails), + ]); + +export declare namespace WebhookEventData { + type Raw = + | serializers.UserStateDetails.Raw + | serializers.CaseClosedDetails.Raw + | serializers.AlertClosedDetails.Raw + | serializers.TransactionStatusDetails.Raw; +} diff --git a/src/serialization/types/WebhookEventType.ts b/src/serialization/types/WebhookEventType.ts index c7a8c94..8c0a85d 100644 --- a/src/serialization/types/WebhookEventType.ts +++ b/src/serialization/types/WebhookEventType.ts @@ -7,8 +7,8 @@ import * as Flagright from "../../api"; import * as core from "../../core"; export const WebhookEventType: core.serialization.Schema = - core.serialization.enum_(["CASE_CLOSED", "USER_STATE_UPDATED", "ALERT_CLOSED"]); + core.serialization.enum_(["CASE_CLOSED", "USER_STATE_UPDATED", "ALERT_CLOSED", "TRANSACTION_STATUS_UPDATED"]); export declare namespace WebhookEventType { - type Raw = "CASE_CLOSED" | "USER_STATE_UPDATED" | "ALERT_CLOSED"; + type Raw = "CASE_CLOSED" | "USER_STATE_UPDATED" | "ALERT_CLOSED" | "TRANSACTION_STATUS_UPDATED"; } diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts index 9bfda26..e0ee139 100644 --- a/src/serialization/types/index.ts +++ b/src/serialization/types/index.ts @@ -1,13 +1,14 @@ export * from "./Transaction"; -export * from "./PostConsumerTransactionResponse"; +export * from "./TransactionsVerifyResponse"; +export * from "./TransactionEvent"; export * from "./User"; -export * from "./PostConsumerUserResponse"; +export * from "./ConsumerUsersCreateResponse"; export * from "./Business"; -export * from "./PostBusinessUserResponse"; +export * from "./BusinessUsersCreateResponse"; export * from "./Address"; export * from "./UserBase"; export * from "./UserOptional"; -export * from "./UserOptionalUserSegment"; +export * from "./ConsumerUserSegment"; export * from "./Person"; export * from "./LegalDocument"; export * from "./Tag"; @@ -25,7 +26,6 @@ export * from "./ExecutedRulesResult"; export * from "./HitRulesDetails"; export * from "./FailedRulesResult"; export * from "./RuleFailureException"; -export * from "./RiskScoringResult"; export * from "./ConsumerName"; export * from "./TransactionAmountDetails"; export * from "./Amount"; @@ -84,10 +84,12 @@ export * from "./KycStatusDetails"; export * from "./UserStateDetails"; export * from "./CaseClosedDetails"; export * from "./AlertClosedDetails"; +export * from "./TransactionStatusDetails"; export * from "./RiskLevel"; export * from "./CardExpiry"; export * from "./TransactionType"; export * from "./WebhookEvent"; +export * from "./WebhookEventData"; export * from "./WebhookEventType"; export * from "./ListType"; export * from "./ListSubtype"; @@ -112,4 +114,8 @@ export * from "./SanctionsDetails"; export * from "./SanctionsDetailsEntityType"; export * from "./BusinessEntityLink"; export * from "./UserWithRulesResult"; +export * from "./RiskScoreDetails"; +export * from "./UserResponse"; export * from "./BusinessWithRulesResult"; +export * from "./BusinessResponse"; +export * from "./BooleanString"; diff --git a/yarn.lock b/yarn.lock index c3072d5..030f4ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,14 +22,13 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -axios@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f" - integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA== +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== dependencies: - follow-redirects "^1.15.0" + follow-redirects "^1.14.9" form-data "^4.0.0" - proxy-from-env "^1.1.0" combined-stream@^1.0.8: version "1.0.8" @@ -43,7 +42,7 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== -follow-redirects@^1.15.0: +follow-redirects@^1.14.9: version "1.15.2" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== @@ -74,11 +73,6 @@ prettier@2.7.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== -proxy-from-env@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" - integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== - typescript@4.6.4: version "4.6.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9"