b5-api-client 0.0.30 → 0.0.32
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/P2PMarketplaceAPIClient.d.ts +13 -1
- package/dist/P2PMarketplaceAPIClient.js +30 -0
- package/dist/types.d.ts +39 -0
- package/package.json +1 -1
- package/src/P2PMarketplaceAPIClient.ts +29 -1
- package/src/types.ts +41 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { CreateOrderRequest, CreateUserRequest, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse, GetOrdersParams, CreateDisputeRequest, DisputesResponse, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest, NotificationsResponse, VerifyEmailRequest, CreateSessionRequest, CreateSessionResponse } from './types';
|
|
2
|
+
import { CreateOrderRequest, CreateUserRequest, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse, GetOrdersParams, CreateDisputeRequest, DisputesResponse, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest, NotificationsResponse, VerifyEmailRequest, CreateSessionRequest, CreateSessionResponse, SaveOpsLogRequest, SaveOpsLogResponse } from './types';
|
|
3
3
|
import { AuthTokenProvider } from './auth/AuthTokenProvider';
|
|
4
4
|
export interface RequestConfigWithRetry extends AxiosRequestConfig {
|
|
5
5
|
_retry?: boolean;
|
|
@@ -37,6 +37,18 @@ declare class P2PMarketplaceAPIClient {
|
|
|
37
37
|
releaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<string>;
|
|
38
38
|
getTransactionStatus(txHash: string, headers?: Record<string, string>): Promise<TransactionStatusResponse>;
|
|
39
39
|
createDispute(request: CreateDisputeRequest, headers?: Record<string, string>): Promise<DisputesResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Cancel/delete an order by its ID
|
|
42
|
+
* Only allowed for orders in PENDING or WAITING_PAYMENT status
|
|
43
|
+
*/
|
|
44
|
+
cancelOrder(orderId: string, headers?: Record<string, string>): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Save a UserOperation receipt to the database
|
|
47
|
+
* @param request - The SaveOpsLogRequest containing chainId, userOp, and optional orderId/opsType
|
|
48
|
+
* @param headers - Optional custom headers
|
|
49
|
+
* @returns SaveOpsLogResponse with the saved log id and success status
|
|
50
|
+
*/
|
|
51
|
+
saveOpsLog(request: SaveOpsLogRequest, headers?: Record<string, string>): Promise<SaveOpsLogResponse>;
|
|
40
52
|
/**
|
|
41
53
|
* Create or refresh a session with Firebase ID token
|
|
42
54
|
* Sets a session cookie that will be used for WebSocket authentication
|
|
@@ -308,6 +308,36 @@ class P2PMarketplaceAPIClient {
|
|
|
308
308
|
return this.post(url, request, headers);
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Cancel/delete an order by its ID
|
|
313
|
+
* Only allowed for orders in PENDING or WAITING_PAYMENT status
|
|
314
|
+
*/
|
|
315
|
+
cancelOrder(orderId, headers) {
|
|
316
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
317
|
+
const url = `/api/orders/${orderId}`;
|
|
318
|
+
const config = this.createConfig(headers);
|
|
319
|
+
try {
|
|
320
|
+
yield this.client.delete(url, config);
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
console.error(`DELETE request to ${url} failed:`, error);
|
|
324
|
+
throw error;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
// OpsLog
|
|
329
|
+
/**
|
|
330
|
+
* Save a UserOperation receipt to the database
|
|
331
|
+
* @param request - The SaveOpsLogRequest containing chainId, userOp, and optional orderId/opsType
|
|
332
|
+
* @param headers - Optional custom headers
|
|
333
|
+
* @returns SaveOpsLogResponse with the saved log id and success status
|
|
334
|
+
*/
|
|
335
|
+
saveOpsLog(request, headers) {
|
|
336
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
+
const url = '/api/ops/log';
|
|
338
|
+
return this.post(url, request, headers);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
311
341
|
// Session Management
|
|
312
342
|
/**
|
|
313
343
|
* Create or refresh a session with Firebase ID token
|
package/dist/types.d.ts
CHANGED
|
@@ -179,6 +179,34 @@ export interface ReleaseOrderEvent {
|
|
|
179
179
|
adminAction: boolean;
|
|
180
180
|
timestamp: string;
|
|
181
181
|
}
|
|
182
|
+
export interface OrderCanceledEvent {
|
|
183
|
+
type: string;
|
|
184
|
+
orderId: string;
|
|
185
|
+
buyerAddress: string;
|
|
186
|
+
amount?: string;
|
|
187
|
+
transaction?: {
|
|
188
|
+
hash: string;
|
|
189
|
+
} | null;
|
|
190
|
+
tokenContractAddress: string;
|
|
191
|
+
cancelCreatorId: string;
|
|
192
|
+
previousStatus: string;
|
|
193
|
+
timestamp: string;
|
|
194
|
+
blockchain?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface OrderDisputedEvent {
|
|
197
|
+
type: string;
|
|
198
|
+
orderId: string;
|
|
199
|
+
buyerAddress: string;
|
|
200
|
+
amount?: string;
|
|
201
|
+
transaction?: {
|
|
202
|
+
hash: string;
|
|
203
|
+
} | null;
|
|
204
|
+
tokenContractAddress: string;
|
|
205
|
+
disputeCreatorId: string;
|
|
206
|
+
reason: string;
|
|
207
|
+
timestamp: string;
|
|
208
|
+
blockchain?: string;
|
|
209
|
+
}
|
|
182
210
|
export interface OrderEvent {
|
|
183
211
|
orderId: string;
|
|
184
212
|
timestamp: string;
|
|
@@ -387,3 +415,14 @@ export interface NotificationDto {
|
|
|
387
415
|
export interface NotificationsResponse {
|
|
388
416
|
notifications: NotificationDto[];
|
|
389
417
|
}
|
|
418
|
+
export type OpsType = 'LOCK' | 'RELEASE' | 'TRANSFER';
|
|
419
|
+
export interface SaveOpsLogRequest {
|
|
420
|
+
chainId: number;
|
|
421
|
+
userOp: Record<string, unknown>;
|
|
422
|
+
orderId?: string;
|
|
423
|
+
opsType?: OpsType;
|
|
424
|
+
}
|
|
425
|
+
export interface SaveOpsLogResponse {
|
|
426
|
+
id: string;
|
|
427
|
+
success: boolean;
|
|
428
|
+
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { CreateOrderRequest, CreateUserRequest, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse, GetOrdersParams, CreateDisputeRequest, DisputesResponse, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest, NotificationsResponse, VerifyEmailRequest, CreateSessionRequest, CreateSessionResponse } from './types';
|
|
2
|
+
import { CreateOrderRequest, CreateUserRequest, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse, GetOrdersParams, CreateDisputeRequest, DisputesResponse, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest, NotificationsResponse, VerifyEmailRequest, CreateSessionRequest, CreateSessionResponse, SaveOpsLogRequest, SaveOpsLogResponse } from './types';
|
|
3
3
|
import { AuthTokenProvider } from './auth/AuthTokenProvider';
|
|
4
4
|
import { isPlainObject, camelCase, snakeCase, transform } from 'lodash';
|
|
5
5
|
|
|
@@ -291,6 +291,34 @@ class P2PMarketplaceAPIClient {
|
|
|
291
291
|
return this.post<DisputesResponse>(url, request, headers);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Cancel/delete an order by its ID
|
|
296
|
+
* Only allowed for orders in PENDING or WAITING_PAYMENT status
|
|
297
|
+
*/
|
|
298
|
+
public async cancelOrder(orderId: string, headers?: Record<string, string>): Promise<void> {
|
|
299
|
+
const url = `/api/orders/${orderId}`;
|
|
300
|
+
const config = this.createConfig(headers);
|
|
301
|
+
try {
|
|
302
|
+
await this.client.delete(url, config);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
console.error(`DELETE request to ${url} failed:`, error);
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// OpsLog
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Save a UserOperation receipt to the database
|
|
313
|
+
* @param request - The SaveOpsLogRequest containing chainId, userOp, and optional orderId/opsType
|
|
314
|
+
* @param headers - Optional custom headers
|
|
315
|
+
* @returns SaveOpsLogResponse with the saved log id and success status
|
|
316
|
+
*/
|
|
317
|
+
public async saveOpsLog(request: SaveOpsLogRequest, headers?: Record<string, string>): Promise<SaveOpsLogResponse> {
|
|
318
|
+
const url = '/api/ops/log';
|
|
319
|
+
return this.post<SaveOpsLogResponse>(url, request, headers);
|
|
320
|
+
}
|
|
321
|
+
|
|
294
322
|
// Session Management
|
|
295
323
|
|
|
296
324
|
/**
|
package/src/types.ts
CHANGED
|
@@ -221,6 +221,32 @@ export interface ReleaseOrderEvent {
|
|
|
221
221
|
timestamp: string;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
export interface OrderCanceledEvent {
|
|
225
|
+
type: string;
|
|
226
|
+
orderId: string;
|
|
227
|
+
buyerAddress: string;
|
|
228
|
+
amount?: string;
|
|
229
|
+
transaction?: { hash: string } | null;
|
|
230
|
+
tokenContractAddress: string;
|
|
231
|
+
cancelCreatorId: string;
|
|
232
|
+
previousStatus: string;
|
|
233
|
+
timestamp: string;
|
|
234
|
+
blockchain?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface OrderDisputedEvent {
|
|
238
|
+
type: string;
|
|
239
|
+
orderId: string;
|
|
240
|
+
buyerAddress: string;
|
|
241
|
+
amount?: string;
|
|
242
|
+
transaction?: { hash: string } | null;
|
|
243
|
+
tokenContractAddress: string;
|
|
244
|
+
disputeCreatorId: string;
|
|
245
|
+
reason: string;
|
|
246
|
+
timestamp: string;
|
|
247
|
+
blockchain?: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
224
250
|
export interface OrderEvent {
|
|
225
251
|
orderId: string;
|
|
226
252
|
timestamp: string;
|
|
@@ -473,3 +499,18 @@ export interface NotificationDto {
|
|
|
473
499
|
export interface NotificationsResponse {
|
|
474
500
|
notifications: NotificationDto[];
|
|
475
501
|
}
|
|
502
|
+
|
|
503
|
+
// OpsLog types
|
|
504
|
+
export type OpsType = 'LOCK' | 'RELEASE' | 'TRANSFER';
|
|
505
|
+
|
|
506
|
+
export interface SaveOpsLogRequest {
|
|
507
|
+
chainId: number;
|
|
508
|
+
userOp: Record<string, unknown>;
|
|
509
|
+
orderId?: string;
|
|
510
|
+
opsType?: OpsType;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export interface SaveOpsLogResponse {
|
|
514
|
+
id: string;
|
|
515
|
+
success: boolean;
|
|
516
|
+
}
|