Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 3c824d1

Browse files
authored
Add resource request (#5)
1 parent 34f1a08 commit 3c824d1

5 files changed

Lines changed: 82 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zai-payments",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Zai API Typescript/Javascript Bindings",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import walletAccounts from './resources/wallet_accounts';
1919
import tools from './resources/tools';
2020
import tokens from './resources/tokens';
2121
import users from './resources/users';
22+
import request from './resources/request';
2223

2324
export * from './types';
2425

@@ -62,6 +63,7 @@ export function createClient({
6263
walletAccounts: walletAccounts(client),
6364
transactions: transactions(client),
6465
tokenAuths: tokenAuths(client),
66+
request: request(client),
6567
};
6668
return api;
6769
}

src/resources/items.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
SingleUser,
1616
ListBatchTransactions,
1717
AccountIdRequestBody,
18-
SingleItem,
18+
SingleItem, AsyncMakePaymentBody,
1919
} from '../types';
2020

2121
export default (client: Client) => ({
@@ -237,6 +237,23 @@ export default (client: Client) => ({
237237
secure: true,
238238
}),
239239

240+
/**
241+
* @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.
242+
*
243+
* @tags Item Actions
244+
* @name AsyncMakePaymentBody
245+
* @summary Make Payment (async)
246+
* @request PATCH:/items/{id}/make_payment
247+
* @secure
248+
*/
249+
makeAsyncPayment: (id: string, data: AccountIdRequestBody) =>
250+
client.request<AsyncMakePaymentBody>({
251+
url: `/items/${id}/make_payment`,
252+
method: 'PATCH',
253+
data,
254+
secure: true,
255+
}),
256+
240257
/**
241258
* @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.
242259
*

src/resources/request.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Client } from '../client';
2+
3+
export default (client: Client) => ({
4+
/**
5+
* @description Show request status for async payment using a given `:id`.
6+
*
7+
* @tags Request
8+
* @name showRequestStatus
9+
* @summary Show request status for async payment
10+
* @request GET:/request/${id}/status
11+
* @secure
12+
*/
13+
showRequestStatus: (id: string) =>
14+
client.request<any>({
15+
url: `/request/${id}/status`,
16+
method: 'GET',
17+
secure: true,
18+
}),
19+
20+
/**
21+
* @description Show callbacks registered for async payment using a given `:id`.
22+
*
23+
* @tags Request
24+
* @name showRequestCallbacks
25+
* @summary Show callbacks for async payment
26+
* @request GET:/request/${id}/callbacks
27+
* @secure
28+
*/
29+
showRequestCallbacks: (id: string) =>
30+
client.request<any>({
31+
url: `/request/${id}/callbacks`,
32+
method: 'GET',
33+
secure: true,
34+
}),
35+
36+
/**
37+
* @description Used for checking zai callbacks with the path they provided`.
38+
*
39+
* @tags Request
40+
* @name showRequestCallbacks
41+
* @summary GET using the path provided
42+
* @request GET:/${path}
43+
* @secure
44+
*/
45+
getWithPath: (path: string) =>
46+
client.request<any>({
47+
url: path,
48+
method: 'GET',
49+
secure: true,
50+
}),
51+
});

src/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,3 +2209,13 @@ export interface ReleasePaymentRequestBody {
22092209
*/
22102210
flag_release?: boolean;
22112211
}
2212+
2213+
export interface AsyncMakePaymentBody {
2214+
last_updated?: string;
2215+
submission_count?: number;
2216+
message?: string;
2217+
links?: {
2218+
status?: string;
2219+
callbacks?: string;
2220+
}
2221+
}

0 commit comments

Comments
 (0)