-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a67013
commit bd7a4f5
Showing
108 changed files
with
1,489 additions
and
901 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "./types"; | ||
export * from "./errors"; | ||
export * from "./client"; | ||
export * from "./resources"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<environments.FlagrightEnvironment | string>; | ||
apiKey: core.Supplier<string>; | ||
} | ||
|
||
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<Flagright.BusinessWithRulesResult> { | ||
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, | ||
}); | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { BusinessUserEvent } from "./BusinessUserEvent"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./client"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<environments.FlagrightEnvironment | string>; | ||
apiKey: core.Supplier<string>; | ||
} | ||
|
||
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<Flagright.BusinessUsersCreateResponse> { | ||
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<Flagright.BusinessResponse> { | ||
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, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./client"; |
Oops, something went wrong.