b5-api-client 0.0.5 → 0.0.7
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/dist/APITester.js +1 -1
- package/dist/P2PMarketplaceAPIClient.d.ts +3 -1
- package/dist/P2PMarketplaceAPIClient.js +23 -0
- package/dist/types.d.ts +15 -5
- package/package.json +1 -1
- package/src/APITester.ts +1 -1
- package/src/types.ts +10 -7
package/dist/APITester.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateOrderRequest, CreateUserRequest, GetOrdersParams, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest } from './types';
|
|
1
|
+
import { CreateOrderRequest, CreateUserRequest, GetOrdersParams, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse } from './types';
|
|
2
2
|
declare class P2PMarketplaceAPIClient {
|
|
3
3
|
private readonly client;
|
|
4
4
|
private readonly defaultHeaders;
|
|
@@ -15,5 +15,7 @@ declare class P2PMarketplaceAPIClient {
|
|
|
15
15
|
updateOrder(updateRequest: UpdateOrderRequest, headers?: Record<string, string>): Promise<Order>;
|
|
16
16
|
testLockFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<void>;
|
|
17
17
|
testReleaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<void>;
|
|
18
|
+
releaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<string>;
|
|
19
|
+
getTransactionStatus(txHash: string, headers?: Record<string, string>): Promise<TransactionStatusResponse>;
|
|
18
20
|
}
|
|
19
21
|
export default P2PMarketplaceAPIClient;
|
|
@@ -174,6 +174,29 @@ class P2PMarketplaceAPIClient {
|
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
+
releaseFunds(order, testParams, headers) {
|
|
178
|
+
var _a;
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const body = {
|
|
181
|
+
orderId: (_a = order.id) !== null && _a !== void 0 ? _a : "",
|
|
182
|
+
isAdmin: true
|
|
183
|
+
};
|
|
184
|
+
const url = "api/orders/release";
|
|
185
|
+
try {
|
|
186
|
+
return yield this.post(url, body, headers);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
console.error("Error releasing funds:", error);
|
|
190
|
+
throw new Error("Failed to release funds");
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
getTransactionStatus(txHash, headers) {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
const url = `/api/blockchain/transactions/${txHash}`;
|
|
197
|
+
return this.get(url, headers);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
177
200
|
}
|
|
178
201
|
function toSnakeCase(obj) {
|
|
179
202
|
if (Array.isArray(obj)) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export type OrderType = 'SELL' | 'BUY';
|
|
2
|
-
export type OrderStatus = '
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export type OrderStatus = 'WAITING_PAYMENT' | 'WAITING_BUYER_ADDRESS' | 'PENDING' | 'ACTIVE' | 'FIAT_SENT' | 'RELEASED' | 'CLOSED' | 'DISPUTE' | 'CANCELED' | 'SUCCESS' | 'PAID_HOLD_INVOICE' | 'CANCELED_BY_ADMIN' | 'EXPIRED' | 'COMPLETED_BY_ADMIN';
|
|
3
|
+
export interface TransactionStatusResponse {
|
|
4
|
+
hash: string;
|
|
5
|
+
block_number: number | null;
|
|
6
|
+
status: 'PENDING' | 'SUCCESSFULL' | 'FAILED';
|
|
6
7
|
}
|
|
7
8
|
export interface Order {
|
|
8
9
|
type: OrderType;
|
|
@@ -31,7 +32,10 @@ export interface OrderResponse {
|
|
|
31
32
|
}
|
|
32
33
|
export interface PaymentMethod {
|
|
33
34
|
type: string;
|
|
34
|
-
|
|
35
|
+
alias?: string;
|
|
36
|
+
cbu?: string;
|
|
37
|
+
fullName?: string;
|
|
38
|
+
entity?: string;
|
|
35
39
|
}
|
|
36
40
|
export interface CreateOrderRequest {
|
|
37
41
|
type: OrderType;
|
|
@@ -69,6 +73,7 @@ export interface TakeBuyOrderRequest {
|
|
|
69
73
|
userId: string;
|
|
70
74
|
amount: string;
|
|
71
75
|
username?: string;
|
|
76
|
+
paymentMethod?: PaymentMethod[];
|
|
72
77
|
}
|
|
73
78
|
export interface CreateUserRequest {
|
|
74
79
|
username: string;
|
|
@@ -76,6 +81,11 @@ export interface CreateUserRequest {
|
|
|
76
81
|
export interface UpdateOrderRequest {
|
|
77
82
|
status: string;
|
|
78
83
|
orderId: string;
|
|
84
|
+
sellerId?: string;
|
|
85
|
+
takenAt?: string;
|
|
86
|
+
isLocked?: boolean;
|
|
87
|
+
txLock?: string;
|
|
88
|
+
txRelease?: string;
|
|
79
89
|
}
|
|
80
90
|
export interface OrderLockedEvent {
|
|
81
91
|
type: string;
|
package/package.json
CHANGED
package/src/APITester.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -16,12 +16,6 @@ export type OrderStatus =
|
|
|
16
16
|
'EXPIRED' |
|
|
17
17
|
'COMPLETED_BY_ADMIN';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
export interface PaymentMethod {
|
|
21
|
-
type: string;
|
|
22
|
-
username: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
19
|
export interface TransactionStatusResponse {
|
|
26
20
|
hash: string;
|
|
27
21
|
block_number: number | null;
|
|
@@ -57,7 +51,10 @@ export interface OrderResponse {
|
|
|
57
51
|
|
|
58
52
|
export interface PaymentMethod {
|
|
59
53
|
type: string;
|
|
60
|
-
|
|
54
|
+
alias?: string;
|
|
55
|
+
cbu?: string;
|
|
56
|
+
fullName?: string;
|
|
57
|
+
entity?: string;
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
export interface CreateOrderRequest {
|
|
@@ -100,6 +97,7 @@ export interface TakeBuyOrderRequest {
|
|
|
100
97
|
userId: string;
|
|
101
98
|
amount: string;
|
|
102
99
|
username?: string;
|
|
100
|
+
paymentMethod?: PaymentMethod[];
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
export interface CreateUserRequest {
|
|
@@ -109,6 +107,11 @@ export interface CreateUserRequest {
|
|
|
109
107
|
export interface UpdateOrderRequest {
|
|
110
108
|
status: string;
|
|
111
109
|
orderId: string;
|
|
110
|
+
sellerId?: string;
|
|
111
|
+
takenAt?: string;
|
|
112
|
+
isLocked?: boolean;
|
|
113
|
+
txLock?: string;
|
|
114
|
+
txRelease?: string;
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
export interface OrderLockedEvent {
|