@afriex/sdk 5.1.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +155 -148
- package/dist/cjs/client.d.ts +110 -0
- package/dist/cjs/client.js +231 -0
- package/dist/cjs/core/api-promise.d.ts +25 -0
- package/dist/cjs/core/api-promise.js +49 -0
- package/dist/cjs/core/errors.d.ts +78 -0
- package/dist/cjs/core/errors.js +143 -0
- package/dist/cjs/core/pagination.d.ts +47 -0
- package/dist/cjs/core/pagination.js +70 -0
- package/dist/cjs/core/resource.d.ts +18 -0
- package/dist/cjs/core/resource.js +36 -0
- package/dist/cjs/core/types.d.ts +43 -0
- package/dist/cjs/core/types.js +2 -0
- package/dist/cjs/generated/openapi.d.ts +5751 -0
- package/dist/cjs/generated/openapi.js +6 -0
- package/dist/cjs/index.d.ts +21 -0
- package/dist/cjs/index.js +34 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/resources/balance.d.ts +16 -0
- package/dist/cjs/resources/balance.js +19 -0
- package/dist/cjs/resources/checkout.d.ts +12 -0
- package/dist/cjs/resources/checkout.js +16 -0
- package/dist/cjs/resources/customers.d.ts +27 -0
- package/dist/cjs/resources/customers.js +56 -0
- package/dist/cjs/resources/media.d.ts +24 -0
- package/dist/cjs/resources/media.js +39 -0
- package/dist/cjs/resources/payment-batches.d.ts +41 -0
- package/dist/cjs/resources/payment-batches.js +76 -0
- package/dist/cjs/resources/payment-methods.d.ts +49 -0
- package/dist/cjs/resources/payment-methods.js +95 -0
- package/dist/cjs/resources/rates.d.ts +9 -0
- package/dist/cjs/resources/rates.js +13 -0
- package/dist/cjs/resources/sme-registration.d.ts +24 -0
- package/dist/cjs/resources/sme-registration.js +31 -0
- package/dist/cjs/resources/transactions.d.ts +39 -0
- package/dist/cjs/resources/transactions.js +67 -0
- package/dist/cjs/resources/webhooks.d.ts +43 -0
- package/dist/cjs/resources/webhooks.js +53 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +5 -0
- package/dist/esm/client.d.ts +110 -0
- package/dist/esm/client.js +227 -0
- package/dist/esm/core/api-promise.d.ts +25 -0
- package/dist/esm/core/api-promise.js +45 -0
- package/dist/esm/core/errors.d.ts +78 -0
- package/dist/esm/core/errors.js +126 -0
- package/dist/esm/core/pagination.d.ts +47 -0
- package/dist/esm/core/pagination.js +65 -0
- package/dist/esm/core/resource.d.ts +18 -0
- package/dist/esm/core/resource.js +30 -0
- package/dist/esm/core/types.d.ts +43 -0
- package/dist/esm/core/types.js +1 -0
- package/dist/esm/generated/openapi.d.ts +5751 -0
- package/dist/esm/generated/openapi.js +5 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/resources/balance.d.ts +16 -0
- package/dist/esm/resources/balance.js +15 -0
- package/dist/esm/resources/checkout.d.ts +12 -0
- package/dist/esm/resources/checkout.js +12 -0
- package/dist/esm/resources/customers.d.ts +27 -0
- package/dist/esm/resources/customers.js +52 -0
- package/dist/esm/resources/media.d.ts +24 -0
- package/dist/esm/resources/media.js +35 -0
- package/dist/esm/resources/payment-batches.d.ts +41 -0
- package/dist/esm/resources/payment-batches.js +72 -0
- package/dist/esm/resources/payment-methods.d.ts +49 -0
- package/dist/esm/resources/payment-methods.js +91 -0
- package/dist/esm/resources/rates.d.ts +9 -0
- package/dist/esm/resources/rates.js +9 -0
- package/dist/esm/resources/sme-registration.d.ts +24 -0
- package/dist/esm/resources/sme-registration.js +27 -0
- package/dist/esm/resources/transactions.d.ts +39 -0
- package/dist/esm/resources/transactions.js +63 -0
- package/dist/esm/resources/webhooks.d.ts +43 -0
- package/dist/esm/resources/webhooks.js +49 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +2 -0
- package/package.json +52 -68
- package/dist/index.d.ts +0 -54
- package/dist/index.js +0 -54
- package/dist/version.d.ts +0 -8
- package/dist/version.js +0 -8
- package/skills/afriex-go-live/SKILL.md +0 -386
- package/skills/afriex-sdk/SKILL.md +0 -275
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { Afriex, Afriex as AfriexSDK, API_VERSION, ENVIRONMENTS } from './client.js';
|
|
2
|
+
export type { APIRequestInit, ClientOptions, Environment, SignableRequest } from './client.js';
|
|
3
|
+
export { APIPromise } from './core/api-promise.js';
|
|
4
|
+
export { AfriexError, APIConnectionError, APIConnectionTimeoutError, APIError, APIUserAbortError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, WebhookVerificationError, } from './core/errors.js';
|
|
5
|
+
export { Page, PagePromise } from './core/pagination.js';
|
|
6
|
+
export type { RequestOptions } from './core/types.js';
|
|
7
|
+
export type * from './resources/balance.js';
|
|
8
|
+
export type * from './resources/checkout.js';
|
|
9
|
+
export type * from './resources/customers.js';
|
|
10
|
+
export type * from './resources/media.js';
|
|
11
|
+
export type * from './resources/payment-batches.js';
|
|
12
|
+
export type * from './resources/payment-methods.js';
|
|
13
|
+
export type * from './resources/rates.js';
|
|
14
|
+
export type * from './resources/sme-registration.js';
|
|
15
|
+
export type * from './resources/transactions.js';
|
|
16
|
+
export type * from './resources/webhooks.js';
|
|
17
|
+
export { WEBHOOK_SIGNATURE_HEADER } from './resources/webhooks.js';
|
|
18
|
+
export { VERSION } from './version.js';
|
|
19
|
+
/** Every type the spec defines, as generated from `api-reference/openapi.json`. */
|
|
20
|
+
export type * as OpenAPI from './generated/openapi.js';
|
|
21
|
+
export { Afriex as default } from './client.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Afriex, Afriex as AfriexSDK, API_VERSION, ENVIRONMENTS } from './client.js';
|
|
2
|
+
export { APIPromise } from './core/api-promise.js';
|
|
3
|
+
export { AfriexError, APIConnectionError, APIConnectionTimeoutError, APIError, APIUserAbortError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, WebhookVerificationError, } from './core/errors.js';
|
|
4
|
+
export { Page, PagePromise } from './core/pagination.js';
|
|
5
|
+
export { WEBHOOK_SIGNATURE_HEADER } from './resources/webhooks.js';
|
|
6
|
+
export { VERSION } from './version.js';
|
|
7
|
+
export { Afriex as default } from './client.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import { APIResource } from '../core/resource.js';
|
|
3
|
+
import type { Body, Data, Query, RequestOptions } from '../core/types.js';
|
|
4
|
+
export type BalanceParams = Omit<Query<'getBalance'>, 'currencies'> & {
|
|
5
|
+
/** The currencies to return, as a list or a comma-separated string. Omit for all of them. */
|
|
6
|
+
currencies?: string | string[];
|
|
7
|
+
};
|
|
8
|
+
/** Each currency's balance, keyed by currency code. */
|
|
9
|
+
export type Balances = Data<'getBalance'>;
|
|
10
|
+
export type TopUpParams = Body<'topupBalance'>;
|
|
11
|
+
export declare class Balance extends APIResource {
|
|
12
|
+
/** Retrieves your wallet balances, keyed by currency code. */
|
|
13
|
+
getBalance(params?: BalanceParams, options?: RequestOptions): APIPromise<Balances>;
|
|
14
|
+
/** Sandbox only: adds test funds to a wallet. */
|
|
15
|
+
topUpSandbox(params: TopUpParams, options?: RequestOptions): APIPromise<Data<'topupBalance'>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { APIResource, data } from '../core/resource.js';
|
|
2
|
+
export class Balance extends APIResource {
|
|
3
|
+
/** Retrieves your wallet balances, keyed by currency code. */
|
|
4
|
+
getBalance(params = {}, options) {
|
|
5
|
+
return this._client
|
|
6
|
+
.request('get', '/api/v1/org/balance', { query: params, options })
|
|
7
|
+
._thenUnwrap((r) => r.data ?? {});
|
|
8
|
+
}
|
|
9
|
+
/** Sandbox only: adds test funds to a wallet. */
|
|
10
|
+
topUpSandbox(params, options) {
|
|
11
|
+
return this._client
|
|
12
|
+
.request('post', '/api/v1/org/balance/topup', { body: params, options })
|
|
13
|
+
._thenUnwrap(data);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import { APIResource } from '../core/resource.js';
|
|
3
|
+
import type { Body, Data, RequestOptions } from '../core/types.js';
|
|
4
|
+
export type CheckoutSessionCreateParams = Body<'createCheckoutSession'>;
|
|
5
|
+
export type CheckoutSession = Data<'createCheckoutSession'>;
|
|
6
|
+
export declare class Checkout extends APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a hosted checkout session. Redirect the payer to its
|
|
9
|
+
* `checkoutUrl`. Amounts are in minor units, such as kobo or cents.
|
|
10
|
+
*/
|
|
11
|
+
createSession(params: CheckoutSessionCreateParams, options?: RequestOptions): APIPromise<CheckoutSession>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { APIResource, data } from '../core/resource.js';
|
|
2
|
+
export class Checkout extends APIResource {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a hosted checkout session. Redirect the payer to its
|
|
5
|
+
* `checkoutUrl`. Amounts are in minor units, such as kobo or cents.
|
|
6
|
+
*/
|
|
7
|
+
createSession(params, options) {
|
|
8
|
+
return this._client
|
|
9
|
+
.request('post', '/api/v1/checkout-session', { body: params, options })
|
|
10
|
+
._thenUnwrap(data);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import type { PagePromise } from '../core/pagination.js';
|
|
3
|
+
import { APIResource } from '../core/resource.js';
|
|
4
|
+
import type { Body, Data, Item, Query, RequestOptions } from '../core/types.js';
|
|
5
|
+
import type { Customer } from '../generated/openapi.js';
|
|
6
|
+
export type { Customer };
|
|
7
|
+
export type CustomerCreateParams = Body<'createCustomer'>;
|
|
8
|
+
export type CustomerListParams = Query<'listCustomers'>;
|
|
9
|
+
export type CustomerUpdateParams = Body<'updateCustomer'>;
|
|
10
|
+
export type CustomerUpdateKycParams = Body<'updateCustomerKyc'>;
|
|
11
|
+
export type CustomerVerifyParams = Body<'verifyCustomer'>;
|
|
12
|
+
export declare class Customers extends APIResource {
|
|
13
|
+
/** Creates a customer. */
|
|
14
|
+
create(params: CustomerCreateParams, options?: RequestOptions): APIPromise<Data<'createCustomer'>>;
|
|
15
|
+
/** Lists customers, alphabetically by full name. Iterate the result with `for await` to walk every page. */
|
|
16
|
+
list(params?: CustomerListParams, options?: RequestOptions): PagePromise<Item<'listCustomers'>>;
|
|
17
|
+
/** Retrieves a customer. */
|
|
18
|
+
get(customerId: string, options?: RequestOptions): APIPromise<Data<'getCustomer'>>;
|
|
19
|
+
/** Updates a customer's details. */
|
|
20
|
+
update(customerId: string, params: CustomerUpdateParams, options?: RequestOptions): APIPromise<Data<'updateCustomer'>>;
|
|
21
|
+
/** Deletes a customer. */
|
|
22
|
+
delete(customerId: string, options?: RequestOptions): APIPromise<Data<'deleteCustomer'>>;
|
|
23
|
+
/** Adds or replaces a customer's KYC documents. */
|
|
24
|
+
updateKyc(customerId: string, params: CustomerUpdateKycParams, options?: RequestOptions): APIPromise<Data<'updateCustomerKyc'>>;
|
|
25
|
+
/** Verifies a customer's identity document. */
|
|
26
|
+
verify(customerId: string, params: CustomerVerifyParams, options?: RequestOptions): APIPromise<Data<'verifyCustomer'>>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { APIResource, data, path } from '../core/resource.js';
|
|
2
|
+
export class Customers extends APIResource {
|
|
3
|
+
/** Creates a customer. */
|
|
4
|
+
create(params, options) {
|
|
5
|
+
return this._client
|
|
6
|
+
.request('post', '/api/v1/customer', { body: params, options })
|
|
7
|
+
._thenUnwrap(data);
|
|
8
|
+
}
|
|
9
|
+
/** Lists customers, alphabetically by full name. Iterate the result with `for await` to walk every page. */
|
|
10
|
+
list(params = {}, options) {
|
|
11
|
+
return this._client.getPage('/api/v1/customer', params, options);
|
|
12
|
+
}
|
|
13
|
+
/** Retrieves a customer. */
|
|
14
|
+
get(customerId, options) {
|
|
15
|
+
return this._client
|
|
16
|
+
.request('get', path `/api/v1/customer/${customerId}`, { options })
|
|
17
|
+
._thenUnwrap(data);
|
|
18
|
+
}
|
|
19
|
+
/** Updates a customer's details. */
|
|
20
|
+
update(customerId, params, options) {
|
|
21
|
+
return this._client
|
|
22
|
+
.request('patch', path `/api/v1/customer/${customerId}`, {
|
|
23
|
+
body: params,
|
|
24
|
+
options,
|
|
25
|
+
})
|
|
26
|
+
._thenUnwrap(data);
|
|
27
|
+
}
|
|
28
|
+
/** Deletes a customer. */
|
|
29
|
+
delete(customerId, options) {
|
|
30
|
+
return this._client
|
|
31
|
+
.request('delete', path `/api/v1/customer/${customerId}`, { options })
|
|
32
|
+
._thenUnwrap(data);
|
|
33
|
+
}
|
|
34
|
+
/** Adds or replaces a customer's KYC documents. */
|
|
35
|
+
updateKyc(customerId, params, options) {
|
|
36
|
+
return this._client
|
|
37
|
+
.request('patch', path `/api/v1/customer/${customerId}/kyc`, {
|
|
38
|
+
body: params,
|
|
39
|
+
options,
|
|
40
|
+
})
|
|
41
|
+
._thenUnwrap(data);
|
|
42
|
+
}
|
|
43
|
+
/** Verifies a customer's identity document. */
|
|
44
|
+
verify(customerId, params, options) {
|
|
45
|
+
return this._client
|
|
46
|
+
.request('post', path `/api/v1/customer/${customerId}/verify`, {
|
|
47
|
+
body: params,
|
|
48
|
+
options,
|
|
49
|
+
})
|
|
50
|
+
._thenUnwrap(data);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import { APIResource } from '../core/resource.js';
|
|
3
|
+
import type { Data, RequestOptions } from '../core/types.js';
|
|
4
|
+
import type { MediaUrlRequest } from '../generated/openapi.js';
|
|
5
|
+
export type UploadUrlParams = MediaUrlRequest;
|
|
6
|
+
export type UploadUrl = Data<'generatePresignedURL'>;
|
|
7
|
+
export interface UploadParams extends UploadUrlParams {
|
|
8
|
+
/** The file's contents. */
|
|
9
|
+
file: Blob | ArrayBuffer | Uint8Array;
|
|
10
|
+
/** Sent as the upload's `Content-Type`. */
|
|
11
|
+
contentType?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class Media extends APIResource {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a presigned URL for a file upload. PUT the file to `url`, then
|
|
16
|
+
* attach `key` to the request that needs the file. `upload()` does both.
|
|
17
|
+
*/
|
|
18
|
+
createUploadUrl(params: UploadUrlParams, options?: RequestOptions): APIPromise<UploadUrl>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets an upload URL and uploads the file to it. Returns the upload URL's
|
|
21
|
+
* details: attach its `key` to the request that needs the file.
|
|
22
|
+
*/
|
|
23
|
+
upload(params: UploadParams, options?: RequestOptions): Promise<UploadUrl>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AfriexError } from '../core/errors.js';
|
|
2
|
+
import { APIResource, data } from '../core/resource.js';
|
|
3
|
+
export class Media extends APIResource {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a presigned URL for a file upload. PUT the file to `url`, then
|
|
6
|
+
* attach `key` to the request that needs the file. `upload()` does both.
|
|
7
|
+
*/
|
|
8
|
+
createUploadUrl(params, options) {
|
|
9
|
+
return this._client
|
|
10
|
+
.request('post', '/api/v1/media/url', { body: params, options })
|
|
11
|
+
._thenUnwrap(data);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Gets an upload URL and uploads the file to it. Returns the upload URL's
|
|
15
|
+
* details: attach its `key` to the request that needs the file.
|
|
16
|
+
*/
|
|
17
|
+
async upload(params, options) {
|
|
18
|
+
const { file, contentType, ...urlParams } = params;
|
|
19
|
+
const upload = await this.createUploadUrl(urlParams, options);
|
|
20
|
+
if (!upload.url) {
|
|
21
|
+
throw new AfriexError('The API returned no upload URL.');
|
|
22
|
+
}
|
|
23
|
+
// The presigned URL carries its own authorization, and goes to the storage
|
|
24
|
+
// host, so it must not carry the API key.
|
|
25
|
+
const response = await this._client.fetchUnauthenticated(upload.url, {
|
|
26
|
+
method: 'PUT',
|
|
27
|
+
body: file,
|
|
28
|
+
headers: contentType ? { 'Content-Type': contentType } : {},
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new AfriexError(`Uploading the file failed with status ${response.status}.`);
|
|
32
|
+
}
|
|
33
|
+
return upload;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import type { PagePromise } from '../core/pagination.js';
|
|
3
|
+
import { APIResource } from '../core/resource.js';
|
|
4
|
+
import type { Body, Data, Item, Query, RequestOptions } from '../core/types.js';
|
|
5
|
+
import type { PaymentBatch } from '../generated/openapi.js';
|
|
6
|
+
export type { PaymentBatch };
|
|
7
|
+
export type PaymentBatchListParams = Query<'listPaymentBatches'>;
|
|
8
|
+
export type PaymentBatchCreateParams = Body<'createPaymentBatch'>;
|
|
9
|
+
export type PaymentBatchUpdateParams = Body<'updatePaymentBatch'>;
|
|
10
|
+
export type PaymentBatchRecipientListParams = Query<'listPaymentBatchRecipients'>;
|
|
11
|
+
export type PaymentBatchRecipientAddParams = Body<'addPaymentBatchRecipient'>;
|
|
12
|
+
export type PaymentBatchRecipientsAddParams = Body<'addPaymentBatchRecipients'>;
|
|
13
|
+
export type PaymentBatchRecipientUpdateParams = Body<'updatePaymentBatchRecipient'>;
|
|
14
|
+
export type PaymentBatchWithdrawParams = Query<'withdrawPaymentBatch'>;
|
|
15
|
+
export type PaymentBatchSessionListParams = Query<'listPaymentBatchSessions'>;
|
|
16
|
+
export declare class PaymentBatches extends APIResource {
|
|
17
|
+
/** Lists payment batches, newest first. Iterate the result with `for await` to walk every page. */
|
|
18
|
+
list(params?: PaymentBatchListParams, options?: RequestOptions): PagePromise<Item<'listPaymentBatches'>>;
|
|
19
|
+
/** Creates a payment batch. */
|
|
20
|
+
create(params: PaymentBatchCreateParams, options?: RequestOptions): APIPromise<Data<'createPaymentBatch'>>;
|
|
21
|
+
/** Retrieves a payment batch. */
|
|
22
|
+
get(batchId: string, options?: RequestOptions): APIPromise<Data<'getPaymentBatch'>>;
|
|
23
|
+
/** Updates a payment batch. */
|
|
24
|
+
update(batchId: string, params: PaymentBatchUpdateParams, options?: RequestOptions): APIPromise<Data<'updatePaymentBatch'>>;
|
|
25
|
+
/** Deletes a payment batch. */
|
|
26
|
+
delete(batchId: string, options?: RequestOptions): APIPromise<Data<'deletePaymentBatch'>>;
|
|
27
|
+
/** Lists a batch's recipients. Iterate the result with `for await` to walk every page. */
|
|
28
|
+
listRecipients(batchId: string, params?: PaymentBatchRecipientListParams, options?: RequestOptions): PagePromise<Item<'listPaymentBatchRecipients'>>;
|
|
29
|
+
/** Adds one recipient to a batch. */
|
|
30
|
+
addRecipient(batchId: string, params: PaymentBatchRecipientAddParams, options?: RequestOptions): APIPromise<Data<'addPaymentBatchRecipient'>>;
|
|
31
|
+
/** Adds several recipients to a batch in one request. */
|
|
32
|
+
addRecipients(batchId: string, params: PaymentBatchRecipientsAddParams, options?: RequestOptions): APIPromise<Data<'addPaymentBatchRecipients'>>;
|
|
33
|
+
/** Updates a recipient in a batch. */
|
|
34
|
+
updateRecipient(batchId: string, recipientId: string, params: PaymentBatchRecipientUpdateParams, options?: RequestOptions): APIPromise<Data<'updatePaymentBatchRecipient'>>;
|
|
35
|
+
/** Removes a recipient from a batch. */
|
|
36
|
+
removeRecipient(batchId: string, recipientId: string, options?: RequestOptions): APIPromise<Data<'removePaymentBatchRecipient'>>;
|
|
37
|
+
/** Pays out every recipient in a batch. */
|
|
38
|
+
withdraw(batchId: string, params?: PaymentBatchWithdrawParams, options?: RequestOptions): APIPromise<Data<'withdrawPaymentBatch'>>;
|
|
39
|
+
/** Lists a batch's payout sessions. Iterate the result with `for await` to walk every page. */
|
|
40
|
+
listSessions(batchId: string, params?: PaymentBatchSessionListParams, options?: RequestOptions): PagePromise<Item<'listPaymentBatchSessions'>>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { APIResource, data, path } from '../core/resource.js';
|
|
2
|
+
export class PaymentBatches extends APIResource {
|
|
3
|
+
/** Lists payment batches, newest first. Iterate the result with `for await` to walk every page. */
|
|
4
|
+
list(params = {}, options) {
|
|
5
|
+
return this._client.getPage('/api/v1/payment-batch', params, options);
|
|
6
|
+
}
|
|
7
|
+
/** Creates a payment batch. */
|
|
8
|
+
create(params, options) {
|
|
9
|
+
return this._client
|
|
10
|
+
.request('post', '/api/v1/payment-batch', { body: params, options })
|
|
11
|
+
._thenUnwrap(data);
|
|
12
|
+
}
|
|
13
|
+
/** Retrieves a payment batch. */
|
|
14
|
+
get(batchId, options) {
|
|
15
|
+
return this._client
|
|
16
|
+
.request('get', path `/api/v1/payment-batch/${batchId}`, { options })
|
|
17
|
+
._thenUnwrap(data);
|
|
18
|
+
}
|
|
19
|
+
/** Updates a payment batch. */
|
|
20
|
+
update(batchId, params, options) {
|
|
21
|
+
return this._client
|
|
22
|
+
.request('patch', path `/api/v1/payment-batch/${batchId}`, {
|
|
23
|
+
body: params,
|
|
24
|
+
options,
|
|
25
|
+
})
|
|
26
|
+
._thenUnwrap(data);
|
|
27
|
+
}
|
|
28
|
+
/** Deletes a payment batch. */
|
|
29
|
+
delete(batchId, options) {
|
|
30
|
+
return this._client
|
|
31
|
+
.request('delete', path `/api/v1/payment-batch/${batchId}`, { options })
|
|
32
|
+
._thenUnwrap(data);
|
|
33
|
+
}
|
|
34
|
+
/** Lists a batch's recipients. Iterate the result with `for await` to walk every page. */
|
|
35
|
+
listRecipients(batchId, params = {}, options) {
|
|
36
|
+
return this._client.getPage(path `/api/v1/payment-batch/${batchId}/recipients`, params, options);
|
|
37
|
+
}
|
|
38
|
+
/** Adds one recipient to a batch. */
|
|
39
|
+
addRecipient(batchId, params, options) {
|
|
40
|
+
return this._client
|
|
41
|
+
.request('post', path `/api/v1/payment-batch/${batchId}/recipients`, { body: params, options })
|
|
42
|
+
._thenUnwrap(data);
|
|
43
|
+
}
|
|
44
|
+
/** Adds several recipients to a batch in one request. */
|
|
45
|
+
addRecipients(batchId, params, options) {
|
|
46
|
+
return this._client
|
|
47
|
+
.request('post', path `/api/v1/payment-batch/${batchId}/recipients/bulk`, { body: params, options })
|
|
48
|
+
._thenUnwrap(data);
|
|
49
|
+
}
|
|
50
|
+
/** Updates a recipient in a batch. */
|
|
51
|
+
updateRecipient(batchId, recipientId, params, options) {
|
|
52
|
+
return this._client
|
|
53
|
+
.request('patch', path `/api/v1/payment-batch/${batchId}/recipients/${recipientId}`, { body: params, options })
|
|
54
|
+
._thenUnwrap(data);
|
|
55
|
+
}
|
|
56
|
+
/** Removes a recipient from a batch. */
|
|
57
|
+
removeRecipient(batchId, recipientId, options) {
|
|
58
|
+
return this._client
|
|
59
|
+
.request('delete', path `/api/v1/payment-batch/${batchId}/recipients/${recipientId}`, { options })
|
|
60
|
+
._thenUnwrap(data);
|
|
61
|
+
}
|
|
62
|
+
/** Pays out every recipient in a batch. */
|
|
63
|
+
withdraw(batchId, params = {}, options) {
|
|
64
|
+
return this._client
|
|
65
|
+
.request('post', path `/api/v1/payment-batch/${batchId}/withdraw`, { query: params, options })
|
|
66
|
+
._thenUnwrap(data);
|
|
67
|
+
}
|
|
68
|
+
/** Lists a batch's payout sessions. Iterate the result with `for await` to walk every page. */
|
|
69
|
+
listSessions(batchId, params = {}, options) {
|
|
70
|
+
return this._client.getPage(path `/api/v1/payment-batch/${batchId}/sessions`, params, options);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import type { PagePromise } from '../core/pagination.js';
|
|
3
|
+
import { APIResource } from '../core/resource.js';
|
|
4
|
+
import type { Body, Data, Item, Query, RequestOptions, Response } from '../core/types.js';
|
|
5
|
+
import type { PaymentMethod } from '../generated/openapi.js';
|
|
6
|
+
export type { PaymentMethod };
|
|
7
|
+
export type PaymentMethodCreateParams = Body<'createPaymentMethod'>;
|
|
8
|
+
export type PaymentMethodListParams = Query<'listPaymentMethods'>;
|
|
9
|
+
export type InstitutionListParams = Query<'listInstitutions'>;
|
|
10
|
+
export type InstitutionList = Response<'listInstitutions'>;
|
|
11
|
+
export type InstitutionCodeParams = Query<'resolveInstitutionCode'>;
|
|
12
|
+
export type InstitutionCodes = Data<'resolveInstitutionCode'>;
|
|
13
|
+
export type ResolveAccountParams = Query<'resolveRecipient'>;
|
|
14
|
+
export type ResolvedAccount = Data<'resolveRecipient'>;
|
|
15
|
+
export type CryptoWalletParams = Query<'getCryptoWallet'>;
|
|
16
|
+
export type CryptoWallet = Data<'getCryptoWallet'>;
|
|
17
|
+
export type VirtualAccountListParams = Query<'listVirtualAccounts'>;
|
|
18
|
+
export type VirtualAccountList = Response<'listVirtualAccounts'>;
|
|
19
|
+
export type VirtualAccountCreateParams = Body<'createVirtualAccount'>;
|
|
20
|
+
export type SimulateTransferParams = Body<'simulateVirtualAccountTransfer'>;
|
|
21
|
+
export type PoolAccountParams = Query<'getPoolAccount'>;
|
|
22
|
+
export declare class PaymentMethods extends APIResource {
|
|
23
|
+
/** Saves a payout destination, such as a bank account or mobile money wallet. */
|
|
24
|
+
create(params: PaymentMethodCreateParams, options?: RequestOptions): APIPromise<Data<'createPaymentMethod'>>;
|
|
25
|
+
/** Lists payment methods, most recently updated first. Iterate the result with `for await` to walk every page. */
|
|
26
|
+
list(params?: PaymentMethodListParams, options?: RequestOptions): PagePromise<Item<'listPaymentMethods'>>;
|
|
27
|
+
/** Retrieves a payment method. */
|
|
28
|
+
get(paymentMethodId: string, options?: RequestOptions): APIPromise<Data<'getPaymentMethod'>>;
|
|
29
|
+
/** Deletes a payment method. */
|
|
30
|
+
delete(paymentMethodId: string, options?: RequestOptions): APIPromise<Response<'deletePaymentMethod'>>;
|
|
31
|
+
/** Lists the banks or mobile money providers for a channel and country. The list is on `data`. */
|
|
32
|
+
getInstitutions(params: InstitutionListParams, options?: RequestOptions): APIPromise<InstitutionList>;
|
|
33
|
+
/** Looks up a SWIFT code or routing number. */
|
|
34
|
+
resolveInstitutionCode(params: InstitutionCodeParams, options?: RequestOptions): APIPromise<InstitutionCodes>;
|
|
35
|
+
/** Looks up the name on an account before you pay it. */
|
|
36
|
+
resolveAccount(params: ResolveAccountParams, options?: RequestOptions): APIPromise<ResolvedAccount>;
|
|
37
|
+
/** Retrieves the crypto deposit addresses for an asset. */
|
|
38
|
+
getCryptoWallet(params: CryptoWalletParams, options?: RequestOptions): APIPromise<CryptoWallet>;
|
|
39
|
+
/** Lists virtual bank accounts. The list is on `data`. */
|
|
40
|
+
listVirtualAccounts(params: VirtualAccountListParams, options?: RequestOptions): APIPromise<VirtualAccountList>;
|
|
41
|
+
/** Opens a virtual bank account. */
|
|
42
|
+
createVirtualAccount(params: VirtualAccountCreateParams, options?: RequestOptions): APIPromise<Data<'createVirtualAccount'>>;
|
|
43
|
+
/** Sandbox only: simulates a transfer into a virtual account. */
|
|
44
|
+
simulateTransfer(params: SimulateTransferParams, options?: RequestOptions): APIPromise<Data<'simulateVirtualAccountTransfer'>>;
|
|
45
|
+
/** Retrieves the pool account to pay into for a country. */
|
|
46
|
+
getPoolAccount(params: PoolAccountParams, options?: RequestOptions): APIPromise<Data<'getPoolAccount'>>;
|
|
47
|
+
/** @deprecated Use `getPoolAccount()`. Despite the name, it returns one account. */
|
|
48
|
+
listPoolAccounts(params: PoolAccountParams, options?: RequestOptions): APIPromise<Data<'getPoolAccount'>>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { APIResource, data, path } from '../core/resource.js';
|
|
2
|
+
export class PaymentMethods extends APIResource {
|
|
3
|
+
/** Saves a payout destination, such as a bank account or mobile money wallet. */
|
|
4
|
+
create(params, options) {
|
|
5
|
+
return this._client
|
|
6
|
+
.request('post', '/api/v1/payment-method', { body: params, options })
|
|
7
|
+
._thenUnwrap(data);
|
|
8
|
+
}
|
|
9
|
+
/** Lists payment methods, most recently updated first. Iterate the result with `for await` to walk every page. */
|
|
10
|
+
list(params = {}, options) {
|
|
11
|
+
return this._client.getPage('/api/v1/payment-method', params, options);
|
|
12
|
+
}
|
|
13
|
+
/** Retrieves a payment method. */
|
|
14
|
+
get(paymentMethodId, options) {
|
|
15
|
+
return this._client
|
|
16
|
+
.request('get', path `/api/v1/payment-method/${paymentMethodId}`, {
|
|
17
|
+
options,
|
|
18
|
+
})
|
|
19
|
+
._thenUnwrap(data);
|
|
20
|
+
}
|
|
21
|
+
/** Deletes a payment method. */
|
|
22
|
+
delete(paymentMethodId, options) {
|
|
23
|
+
return this._client.request('delete', path `/api/v1/payment-method/${paymentMethodId}`, { options });
|
|
24
|
+
}
|
|
25
|
+
/** Lists the banks or mobile money providers for a channel and country. The list is on `data`. */
|
|
26
|
+
getInstitutions(params, options) {
|
|
27
|
+
return this._client.request('get', '/api/v1/payment-method/institution', {
|
|
28
|
+
query: params,
|
|
29
|
+
options,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Looks up a SWIFT code or routing number. */
|
|
33
|
+
resolveInstitutionCode(params, options) {
|
|
34
|
+
return this._client
|
|
35
|
+
.request('get', '/api/v1/payment-method/institution/codes', {
|
|
36
|
+
query: params,
|
|
37
|
+
options,
|
|
38
|
+
})
|
|
39
|
+
._thenUnwrap(data);
|
|
40
|
+
}
|
|
41
|
+
/** Looks up the name on an account before you pay it. */
|
|
42
|
+
resolveAccount(params, options) {
|
|
43
|
+
return this._client
|
|
44
|
+
.request('get', '/api/v1/payment-method/resolve', { query: params, options })
|
|
45
|
+
._thenUnwrap(data);
|
|
46
|
+
}
|
|
47
|
+
/** Retrieves the crypto deposit addresses for an asset. */
|
|
48
|
+
getCryptoWallet(params, options) {
|
|
49
|
+
return this._client
|
|
50
|
+
.request('get', '/api/v1/payment-method/crypto-wallet', {
|
|
51
|
+
query: params,
|
|
52
|
+
options,
|
|
53
|
+
})
|
|
54
|
+
._thenUnwrap(data);
|
|
55
|
+
}
|
|
56
|
+
/** Lists virtual bank accounts. The list is on `data`. */
|
|
57
|
+
listVirtualAccounts(params, options) {
|
|
58
|
+
return this._client.request('get', '/api/v1/payment-method/virtual-account', {
|
|
59
|
+
query: params,
|
|
60
|
+
options,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Opens a virtual bank account. */
|
|
64
|
+
createVirtualAccount(params, options) {
|
|
65
|
+
return this._client
|
|
66
|
+
.request('post', '/api/v1/payment-method/virtual-account', {
|
|
67
|
+
body: params,
|
|
68
|
+
options,
|
|
69
|
+
})
|
|
70
|
+
._thenUnwrap(data);
|
|
71
|
+
}
|
|
72
|
+
/** Sandbox only: simulates a transfer into a virtual account. */
|
|
73
|
+
simulateTransfer(params, options) {
|
|
74
|
+
return this._client
|
|
75
|
+
.request('post', '/api/v1/payment-method/virtual-account/simulate-transfer', { body: params, options })
|
|
76
|
+
._thenUnwrap(data);
|
|
77
|
+
}
|
|
78
|
+
/** Retrieves the pool account to pay into for a country. */
|
|
79
|
+
getPoolAccount(params, options) {
|
|
80
|
+
return this._client
|
|
81
|
+
.request('get', '/api/v1/payment-method/pool-account', {
|
|
82
|
+
query: params,
|
|
83
|
+
options,
|
|
84
|
+
})
|
|
85
|
+
._thenUnwrap(data);
|
|
86
|
+
}
|
|
87
|
+
/** @deprecated Use `getPoolAccount()`. Despite the name, it returns one account. */
|
|
88
|
+
listPoolAccounts(params, options) {
|
|
89
|
+
return this.getPoolAccount(params, options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import { APIResource } from '../core/resource.js';
|
|
3
|
+
import type { Data, Query, RequestOptions } from '../core/types.js';
|
|
4
|
+
export type RatesParams = Query<'getRates'>;
|
|
5
|
+
export type ExchangeRates = Data<'getRates'>;
|
|
6
|
+
export declare class Rates extends APIResource {
|
|
7
|
+
/** Retrieves exchange rates between the currencies you name. */
|
|
8
|
+
getRates(params?: RatesParams, options?: RequestOptions): APIPromise<ExchangeRates>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { APIResource, data } from '../core/resource.js';
|
|
2
|
+
export class Rates extends APIResource {
|
|
3
|
+
/** Retrieves exchange rates between the currencies you name. */
|
|
4
|
+
getRates(params = {}, options) {
|
|
5
|
+
return this._client
|
|
6
|
+
.request('get', '/api/v1/org/rates', { query: params, options })
|
|
7
|
+
._thenUnwrap(data);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import { APIResource } from '../core/resource.js';
|
|
3
|
+
import type { Body, Data, RequestOptions } from '../core/types.js';
|
|
4
|
+
type Step<S> = Extract<Body<'smeRegistration'>, {
|
|
5
|
+
step: S;
|
|
6
|
+
}>['data'];
|
|
7
|
+
export type SmeRegistrationInitiateParams = Step<'INITIATE'>;
|
|
8
|
+
export type SmeRegistrationConfirmOtpParams = Step<'CONFIRM_OTP'>;
|
|
9
|
+
export type SmeRegistrationSubmitParams = Step<'SUBMIT'>;
|
|
10
|
+
export type SmeRegistrationResult = Data<'smeRegistration'>;
|
|
11
|
+
export type SmeRegistrationStatus = Data<'smeRegistrationStatus'>;
|
|
12
|
+
/** Registers your business for its own dedicated KES virtual accounts, in three steps. */
|
|
13
|
+
export declare class SmeRegistration extends APIResource {
|
|
14
|
+
#private;
|
|
15
|
+
/** Step 1: starts a registration and sends an OTP to the mobile number. */
|
|
16
|
+
initiate(data: SmeRegistrationInitiateParams, options?: RequestOptions): APIPromise<SmeRegistrationResult>;
|
|
17
|
+
/** Step 2: confirms the OTP. */
|
|
18
|
+
confirmOtp(data: SmeRegistrationConfirmOtpParams, options?: RequestOptions): APIPromise<SmeRegistrationResult>;
|
|
19
|
+
/** Step 3: submits the business details for review. */
|
|
20
|
+
submit(data: SmeRegistrationSubmitParams, options?: RequestOptions): APIPromise<SmeRegistrationResult>;
|
|
21
|
+
/** Retrieves where your registration stands. */
|
|
22
|
+
getStatus(options?: RequestOptions): APIPromise<SmeRegistrationStatus>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { APIResource, data } from '../core/resource.js';
|
|
2
|
+
/** Registers your business for its own dedicated KES virtual accounts, in three steps. */
|
|
3
|
+
export class SmeRegistration extends APIResource {
|
|
4
|
+
/** Step 1: starts a registration and sends an OTP to the mobile number. */
|
|
5
|
+
initiate(data, options) {
|
|
6
|
+
return this.#send({ step: 'INITIATE', data }, options);
|
|
7
|
+
}
|
|
8
|
+
/** Step 2: confirms the OTP. */
|
|
9
|
+
confirmOtp(data, options) {
|
|
10
|
+
return this.#send({ step: 'CONFIRM_OTP', data }, options);
|
|
11
|
+
}
|
|
12
|
+
/** Step 3: submits the business details for review. */
|
|
13
|
+
submit(data, options) {
|
|
14
|
+
return this.#send({ step: 'SUBMIT', data }, options);
|
|
15
|
+
}
|
|
16
|
+
/** Retrieves where your registration stands. */
|
|
17
|
+
getStatus(options) {
|
|
18
|
+
return this._client
|
|
19
|
+
.request('get', '/api/v1/sme-registration/status', { options })
|
|
20
|
+
._thenUnwrap(data);
|
|
21
|
+
}
|
|
22
|
+
#send(body, options) {
|
|
23
|
+
return this._client
|
|
24
|
+
.request('post', '/api/v1/sme-registration', { body, options })
|
|
25
|
+
._thenUnwrap(data);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { APIPromise } from '../core/api-promise.js';
|
|
2
|
+
import type { PagePromise } from '../core/pagination.js';
|
|
3
|
+
import { APIResource } from '../core/resource.js';
|
|
4
|
+
import type { Body, Data, Item, Query, RequestOptions } from '../core/types.js';
|
|
5
|
+
import type { Transaction, TransactionStatus } from '../generated/openapi.js';
|
|
6
|
+
export type { Transaction, TransactionStatus };
|
|
7
|
+
export type TransactionCreateParams = Body<'createTransaction'>;
|
|
8
|
+
export type TransactionListParams = Query<'listTransactions'>;
|
|
9
|
+
export type TransactionQuoteParams = Query<'getTransactionQuote'>;
|
|
10
|
+
export type TransactionQuote = Data<'getTransactionQuote'>;
|
|
11
|
+
export type TransactionAuthorizeParams = Body<'authorizeTransaction'>;
|
|
12
|
+
export type TransactionSimulateParams = Body<'simulateTransaction'>;
|
|
13
|
+
export type TransactionAdvice = Data<'getTransactionAdvice'>;
|
|
14
|
+
export type PoolAccountProofParams = Body<'submitPoolAccountPaymentProof'>;
|
|
15
|
+
export declare class Transactions extends APIResource {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a deposit, withdrawal or swap.
|
|
18
|
+
*
|
|
19
|
+
* `meta.idempotencyKey` makes this safe to send again, so the SDK retries it
|
|
20
|
+
* on timeouts and server errors with the same body. If a retry gets
|
|
21
|
+
* `409 DUPLICATE_REQUEST` (a `ConflictError`), the first attempt went
|
|
22
|
+
* through: look the transaction up by `meta.reference`.
|
|
23
|
+
*/
|
|
24
|
+
create(params: TransactionCreateParams, options?: RequestOptions): APIPromise<Data<'createTransaction'>>;
|
|
25
|
+
/** Lists transactions, newest first. Iterate the result with `for await` to walk every page. */
|
|
26
|
+
list(params?: TransactionListParams, options?: RequestOptions): PagePromise<Item<'listTransactions'>>;
|
|
27
|
+
/** Quotes a withdrawal: the rate, fee and amounts, without creating anything. */
|
|
28
|
+
quote(params: TransactionQuoteParams, options?: RequestOptions): APIPromise<TransactionQuote>;
|
|
29
|
+
/** Retrieves a transaction. */
|
|
30
|
+
get(transactionId: string, options?: RequestOptions): APIPromise<Data<'getTransaction'>>;
|
|
31
|
+
/** Authorizes a transaction that is waiting for it, for example with an OTP. */
|
|
32
|
+
authorize(transactionId: string, params: TransactionAuthorizeParams, options?: RequestOptions): APIPromise<Data<'authorizeTransaction'>>;
|
|
33
|
+
/** Sandbox only: moves a transaction to the outcome you choose. */
|
|
34
|
+
simulate(transactionId: string, params: TransactionSimulateParams, options?: RequestOptions): APIPromise<Data<'simulateTransaction'>>;
|
|
35
|
+
/** Retrieves the settlement advice for a completed transaction. */
|
|
36
|
+
getAdvice(transactionId: string, options?: RequestOptions): APIPromise<TransactionAdvice>;
|
|
37
|
+
/** Submits proof of a payment into a pool account. */
|
|
38
|
+
submitPoolAccountProof(params: PoolAccountProofParams, options?: RequestOptions): APIPromise<Data<'submitPoolAccountPaymentProof'>>;
|
|
39
|
+
}
|