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 CHANGED
@@ -72,7 +72,7 @@ function testCreateOrder() {
72
72
  paymentMethods: [
73
73
  {
74
74
  type: 'MERCADO_PAGO',
75
- username: 'blas'
75
+ alias: 'blas'
76
76
  }
77
77
  ],
78
78
  creatorId: '7b74abef-f1b2-4431-aa95-ce565893d47c'
@@ -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 = 'WAITING_DEPOSIT' | '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 PaymentMethod {
4
- type: string;
5
- username: string;
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
- username: string;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b5-api-client",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Escrow Backend API client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/APITester.ts CHANGED
@@ -54,7 +54,7 @@ async function testCreateOrder() {
54
54
  paymentMethods: [
55
55
  {
56
56
  type: 'MERCADO_PAGO',
57
- username: 'blas'
57
+ alias: 'blas'
58
58
  }
59
59
  ],
60
60
  creatorId: '7b74abef-f1b2-4431-aa95-ce565893d47c'
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
- username: string;
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 {