diff --git a/package.json b/package.json index 43d9fba..f72fd11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zai-payments", - "version": "0.2.2", + "version": "0.2.3", "description": "Zai API Typescript/Javascript Bindings", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 3091c28..a1e66e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,7 @@ import walletAccounts from './resources/wallet_accounts'; import tools from './resources/tools'; import tokens from './resources/tokens'; import users from './resources/users'; +import request from './resources/request'; export * from './types'; @@ -62,6 +63,7 @@ export function createClient({ walletAccounts: walletAccounts(client), transactions: transactions(client), tokenAuths: tokenAuths(client), + request: request(client), }; return api; } diff --git a/src/resources/items.ts b/src/resources/items.ts index d532f96..b00f240 100644 --- a/src/resources/items.ts +++ b/src/resources/items.ts @@ -15,7 +15,7 @@ import { SingleUser, ListBatchTransactions, AccountIdRequestBody, - SingleItem, + SingleItem, AsyncMakePaymentBody, } from '../types'; export default (client: Client) => ({ @@ -237,6 +237,23 @@ export default (client: Client) => ({ secure: true, }), + /** + * @description Make a payment for an **Item**. Pass the `:account_id` of a **Bank Account** or a **Card Account** associated with the **Item’s** buyer. The **Item** state will transition to one of `payment_held`, `payment_pending` or `completed` for an **Express** or **Approve** payment type. + * + * @tags Item Actions + * @name AsyncMakePaymentBody + * @summary Make Payment (async) + * @request PATCH:/items/{id}/make_payment + * @secure + */ + makeAsyncPayment: (id: string, data: AccountIdRequestBody) => + client.request({ + url: `/items/${id}/make_payment`, + method: 'PATCH', + data, + secure: true, + }), + /** * @description Cancel an **Item**. This will transition the **Item** state to `cancelled`. **Items** can only be cancelled if they haven’t been actioned in any other way. * diff --git a/src/resources/request.ts b/src/resources/request.ts new file mode 100644 index 0000000..ab2a8e7 --- /dev/null +++ b/src/resources/request.ts @@ -0,0 +1,51 @@ +import { Client } from '../client'; + +export default (client: Client) => ({ + /** + * @description Show request status for async payment using a given `:id`. + * + * @tags Request + * @name showRequestStatus + * @summary Show request status for async payment + * @request GET:/request/${id}/status + * @secure + */ + showRequestStatus: (id: string) => + client.request({ + url: `/request/${id}/status`, + method: 'GET', + secure: true, + }), + + /** + * @description Show callbacks registered for async payment using a given `:id`. + * + * @tags Request + * @name showRequestCallbacks + * @summary Show callbacks for async payment + * @request GET:/request/${id}/callbacks + * @secure + */ + showRequestCallbacks: (id: string) => + client.request({ + url: `/request/${id}/callbacks`, + method: 'GET', + secure: true, + }), + + /** + * @description Used for checking zai callbacks with the path they provided`. + * + * @tags Request + * @name showRequestCallbacks + * @summary GET using the path provided + * @request GET:/${path} + * @secure + */ + getWithPath: (path: string) => + client.request({ + url: path, + method: 'GET', + secure: true, + }), +}); diff --git a/src/types.ts b/src/types.ts index 21ea8c5..5d608cb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2209,3 +2209,13 @@ export interface ReleasePaymentRequestBody { */ flag_release?: boolean; } + +export interface AsyncMakePaymentBody { + last_updated?: string; + submission_count?: number; + message?: string; + links?: { + status?: string; + callbacks?: string; + } +} \ No newline at end of file