b5-api-client 0.0.18 → 0.0.20
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateOrderRequest, CreateUserRequest,
|
|
1
|
+
import { CreateOrderRequest, CreateUserRequest, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse, GetOrdersParams, CreateDisputeRequest, DisputesResponse } from './types';
|
|
2
2
|
declare class P2PMarketplaceAPIClient {
|
|
3
3
|
private readonly client;
|
|
4
4
|
private readonly defaultHeaders;
|
|
@@ -23,5 +23,6 @@ declare class P2PMarketplaceAPIClient {
|
|
|
23
23
|
testReleaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<void>;
|
|
24
24
|
releaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<string>;
|
|
25
25
|
getTransactionStatus(txHash: string, headers?: Record<string, string>): Promise<TransactionStatusResponse>;
|
|
26
|
+
createDispute(request: CreateDisputeRequest, headers?: Record<string, string>): Promise<DisputesResponse>;
|
|
26
27
|
}
|
|
27
28
|
export default P2PMarketplaceAPIClient;
|
|
@@ -79,14 +79,32 @@ class P2PMarketplaceAPIClient {
|
|
|
79
79
|
}
|
|
80
80
|
getOrders(props, headers) {
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const { status, user,
|
|
82
|
+
const { status, user, orderType, blockchain, tokenCode, paymentMethods, fiatCode, fiatAmountRange, dateRange, search } = props;
|
|
83
83
|
const params = new URLSearchParams();
|
|
84
84
|
if (status)
|
|
85
85
|
params.append('status', status.join(','));
|
|
86
86
|
if (user)
|
|
87
87
|
params.append('user', user);
|
|
88
|
-
if (
|
|
89
|
-
params.append('
|
|
88
|
+
if (orderType)
|
|
89
|
+
params.append('type', orderType.join(','));
|
|
90
|
+
if (blockchain)
|
|
91
|
+
params.append('blockchains', blockchain.join(','));
|
|
92
|
+
if (tokenCode)
|
|
93
|
+
params.append('tokens', tokenCode.join(','));
|
|
94
|
+
if (paymentMethods)
|
|
95
|
+
params.append('payments', paymentMethods.join(','));
|
|
96
|
+
if (fiatCode)
|
|
97
|
+
params.append('fiatCode', fiatCode.join(','));
|
|
98
|
+
if (fiatAmountRange === null || fiatAmountRange === void 0 ? void 0 : fiatAmountRange.min)
|
|
99
|
+
params.append('minFiatAmount', fiatAmountRange.min);
|
|
100
|
+
if (fiatAmountRange === null || fiatAmountRange === void 0 ? void 0 : fiatAmountRange.max)
|
|
101
|
+
params.append('maxFiatAmount', fiatAmountRange.max);
|
|
102
|
+
if (dateRange === null || dateRange === void 0 ? void 0 : dateRange.from)
|
|
103
|
+
params.append('fromDate', dateRange.from);
|
|
104
|
+
if (dateRange === null || dateRange === void 0 ? void 0 : dateRange.to)
|
|
105
|
+
params.append('toDate', dateRange.to);
|
|
106
|
+
if (search)
|
|
107
|
+
params.append('search', search);
|
|
90
108
|
const url = `/api/orders?${params.toString()}`;
|
|
91
109
|
return this.get(url, headers);
|
|
92
110
|
});
|
|
@@ -233,6 +251,12 @@ class P2PMarketplaceAPIClient {
|
|
|
233
251
|
return this.get(url, headers);
|
|
234
252
|
});
|
|
235
253
|
}
|
|
254
|
+
createDispute(request, headers) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
const url = '/api/disputes';
|
|
257
|
+
return this.post(url, request, headers);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
236
260
|
}
|
|
237
261
|
function toSnakeCase(obj) {
|
|
238
262
|
if (Array.isArray(obj)) {
|
package/dist/types.d.ts
CHANGED
|
@@ -72,9 +72,23 @@ export interface CreateOrderRequest {
|
|
|
72
72
|
sellerHash?: string;
|
|
73
73
|
}
|
|
74
74
|
export interface GetOrdersParams {
|
|
75
|
-
status?:
|
|
75
|
+
status?: string[];
|
|
76
76
|
user?: string;
|
|
77
77
|
buyer?: string;
|
|
78
|
+
orderType?: string[];
|
|
79
|
+
blockchain?: string[];
|
|
80
|
+
tokenCode?: string[];
|
|
81
|
+
paymentMethods?: PaymentMethod[];
|
|
82
|
+
fiatCode?: string[];
|
|
83
|
+
fiatAmountRange?: {
|
|
84
|
+
min?: string;
|
|
85
|
+
max?: string;
|
|
86
|
+
};
|
|
87
|
+
dateRange?: {
|
|
88
|
+
from?: string;
|
|
89
|
+
to?: string;
|
|
90
|
+
};
|
|
91
|
+
search?: string;
|
|
78
92
|
}
|
|
79
93
|
export type TakeOrderRequest = TakeSellOrderRequest | TakeBuyOrderRequest;
|
|
80
94
|
export interface TakeSellOrderRequest {
|
|
@@ -222,3 +236,23 @@ export interface KioscoinUser {
|
|
|
222
236
|
timeToFiatSent?: number;
|
|
223
237
|
reviews?: UserReview[];
|
|
224
238
|
}
|
|
239
|
+
export type DisputeReason = 'SELLER_NOT_LOCKING' | 'BUYER_FIAT_NOT_SENT' | 'SELLER_NOT_RELEASING';
|
|
240
|
+
export interface CreateDisputeRequest {
|
|
241
|
+
orderId: string;
|
|
242
|
+
creatorId: string;
|
|
243
|
+
reason: DisputeReason;
|
|
244
|
+
}
|
|
245
|
+
export interface Dispute {
|
|
246
|
+
id?: string;
|
|
247
|
+
orderId: string;
|
|
248
|
+
buyerId?: string;
|
|
249
|
+
sellerId?: string;
|
|
250
|
+
orderType: OrderType;
|
|
251
|
+
creatorId: string;
|
|
252
|
+
status: 'OPEN' | 'CANCELED' | 'COMPLETED' | 'REFUND_FAILED';
|
|
253
|
+
resolution?: 'BUYER_REFUNDED' | 'SELLER_REFUNDED';
|
|
254
|
+
reason: DisputeReason;
|
|
255
|
+
}
|
|
256
|
+
export interface DisputesResponse {
|
|
257
|
+
disputes: Dispute[];
|
|
258
|
+
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { CreateOrderRequest, CreateUserRequest,
|
|
2
|
+
import { CreateOrderRequest, CreateUserRequest, Order, OrderLockedEvent, OrderResponse, ReleaseOrderEvent as OrderReleasedEvent, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, KioscoinUser, UsersResponse, PaymentMethod, GetOrdersParams, CreateDisputeRequest, DisputesResponse } from './types';
|
|
3
3
|
import { isPlainObject, camelCase, snakeCase, transform } from 'lodash';
|
|
4
4
|
|
|
5
5
|
class P2PMarketplaceAPIClient {
|
|
@@ -71,11 +71,32 @@ class P2PMarketplaceAPIClient {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
public async getOrders(props: GetOrdersParams, headers?: Record<string, string>): Promise<OrderResponse> {
|
|
74
|
-
const {
|
|
74
|
+
const {
|
|
75
|
+
status,
|
|
76
|
+
user,
|
|
77
|
+
orderType,
|
|
78
|
+
blockchain,
|
|
79
|
+
tokenCode,
|
|
80
|
+
paymentMethods,
|
|
81
|
+
fiatCode,
|
|
82
|
+
fiatAmountRange,
|
|
83
|
+
dateRange,
|
|
84
|
+
search
|
|
85
|
+
} = props;
|
|
86
|
+
|
|
75
87
|
const params = new URLSearchParams();
|
|
76
88
|
if (status) params.append('status', status.join(','));
|
|
77
89
|
if (user) params.append('user', user);
|
|
78
|
-
if (
|
|
90
|
+
if (orderType) params.append('type', orderType.join(','));
|
|
91
|
+
if (blockchain) params.append('blockchains', blockchain.join(','));
|
|
92
|
+
if (tokenCode) params.append('tokens', tokenCode.join(','));
|
|
93
|
+
if (paymentMethods) params.append('payments', paymentMethods.join(','));
|
|
94
|
+
if (fiatCode) params.append('fiatCode', fiatCode.join(','));
|
|
95
|
+
if (fiatAmountRange?.min) params.append('minFiatAmount', fiatAmountRange.min);
|
|
96
|
+
if (fiatAmountRange?.max) params.append('maxFiatAmount', fiatAmountRange.max);
|
|
97
|
+
if (dateRange?.from) params.append('fromDate', dateRange.from);
|
|
98
|
+
if (dateRange?.to) params.append('toDate', dateRange.to);
|
|
99
|
+
if (search) params.append('search', search);
|
|
79
100
|
|
|
80
101
|
const url = `/api/orders?${params.toString()}`;
|
|
81
102
|
return this.get<OrderResponse>(url, headers);
|
|
@@ -207,6 +228,11 @@ class P2PMarketplaceAPIClient {
|
|
|
207
228
|
return this.get<TransactionStatusResponse>(url, headers);
|
|
208
229
|
}
|
|
209
230
|
|
|
231
|
+
public async createDispute(request: CreateDisputeRequest, headers?: Record<string, string>): Promise<DisputesResponse> {
|
|
232
|
+
const url = '/api/disputes';
|
|
233
|
+
return this.post<DisputesResponse>(url, request, headers);
|
|
234
|
+
}
|
|
235
|
+
|
|
210
236
|
}
|
|
211
237
|
|
|
212
238
|
function toSnakeCase(obj: any): any {
|
|
@@ -231,4 +257,4 @@ function toCamelCase(obj: any): any {
|
|
|
231
257
|
return obj;
|
|
232
258
|
}
|
|
233
259
|
|
|
234
|
-
export default P2PMarketplaceAPIClient;
|
|
260
|
+
export default P2PMarketplaceAPIClient;
|
package/src/types.ts
CHANGED
|
@@ -97,9 +97,23 @@ export interface CreateOrderRequest {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export interface GetOrdersParams {
|
|
100
|
-
status?:
|
|
100
|
+
status?: string[];
|
|
101
101
|
user?: string;
|
|
102
102
|
buyer?: string;
|
|
103
|
+
orderType?: string[];
|
|
104
|
+
blockchain?: string[];
|
|
105
|
+
tokenCode?: string[];
|
|
106
|
+
paymentMethods?: PaymentMethod[];
|
|
107
|
+
fiatCode?: string[];
|
|
108
|
+
fiatAmountRange?: {
|
|
109
|
+
min?: string;
|
|
110
|
+
max?: string;
|
|
111
|
+
};
|
|
112
|
+
dateRange?: {
|
|
113
|
+
from?: string;
|
|
114
|
+
to?: string;
|
|
115
|
+
};
|
|
116
|
+
search?: string;
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
export type TakeOrderRequest = TakeSellOrderRequest | TakeBuyOrderRequest;
|
|
@@ -271,4 +285,28 @@ export interface KioscoinUser {
|
|
|
271
285
|
timeToRelease?: number;
|
|
272
286
|
timeToFiatSent?: number;
|
|
273
287
|
reviews?: UserReview[];
|
|
274
|
-
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type DisputeReason = 'SELLER_NOT_LOCKING' | 'BUYER_FIAT_NOT_SENT' | 'SELLER_NOT_RELEASING';
|
|
291
|
+
|
|
292
|
+
export interface CreateDisputeRequest {
|
|
293
|
+
orderId: string;
|
|
294
|
+
creatorId: string;
|
|
295
|
+
reason: DisputeReason;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface Dispute {
|
|
299
|
+
id?: string;
|
|
300
|
+
orderId: string;
|
|
301
|
+
buyerId?: string;
|
|
302
|
+
sellerId?: string;
|
|
303
|
+
orderType: OrderType;
|
|
304
|
+
creatorId: string;
|
|
305
|
+
status: 'OPEN' | 'CANCELED' | 'COMPLETED' | 'REFUND_FAILED';
|
|
306
|
+
resolution?: 'BUYER_REFUNDED' | 'SELLER_REFUNDED';
|
|
307
|
+
reason: DisputeReason;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export interface DisputesResponse {
|
|
311
|
+
disputes: Dispute[];
|
|
312
|
+
}
|