b5-api-client 0.0.16 → 0.0.18

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
@@ -103,6 +103,7 @@ function testTakeOrder() {
103
103
  function testCreateUser() {
104
104
  return __awaiter(this, void 0, void 0, function* () {
105
105
  const user = {
106
+ id: "123",
106
107
  username: "username_test"
107
108
  };
108
109
  const response = yield client.createUser(user);
@@ -1,4 +1,4 @@
1
- import { CreateOrderRequest, CreateUserRequest, GetOrdersParams, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse } from './types';
1
+ import { CreateOrderRequest, CreateUserRequest, GetOrdersParams, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse } from './types';
2
2
  declare class P2PMarketplaceAPIClient {
3
3
  private readonly client;
4
4
  private readonly defaultHeaders;
@@ -11,12 +11,14 @@ declare class P2PMarketplaceAPIClient {
11
11
  getOrderById(id: string, headers?: Record<string, string>): Promise<OrderResponse>;
12
12
  createOrder(order: CreateOrderRequest, headers?: Record<string, string>): Promise<OrderResponse>;
13
13
  takeOrder(order: TakeOrderRequest, headers?: Record<string, string>): Promise<OrderResponse>;
14
- createUser(user: CreateUserRequest, headers?: Record<string, string>): Promise<Order>;
15
14
  updateOrder(updateRequest: UpdateOrderRequest, headers?: Record<string, string>): Promise<Order>;
15
+ createUser(user: CreateUserRequest, headers?: Record<string, string>): Promise<UsersResponse>;
16
+ getUser(userId: string, headers?: Record<string, string>): Promise<UsersResponse>;
16
17
  rateUser(rateUserRequest: RateUserRequest, headers?: Record<string, string>): Promise<any>;
17
18
  registerPushToken(registerRequest: PushNotificationsRegisterRequest, headers?: Record<string, string>): Promise<any>;
18
19
  getConfig<T>(): Promise<ConfigResponse<T>>;
19
20
  getOrderEvents(id: string, headers?: Record<string, string>): Promise<OrderEventsResponse>;
21
+ getDashboardMetrics(headers?: Record<string, string>): Promise<DashboardMetricsResponse>;
20
22
  testLockFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<void>;
21
23
  testReleaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<void>;
22
24
  releaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<string>;
@@ -109,16 +109,22 @@ class P2PMarketplaceAPIClient {
109
109
  return this.post(url, order, headers);
110
110
  });
111
111
  }
112
+ updateOrder(updateRequest, headers) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ const url = '/api/orders/update';
115
+ return this.post(url, updateRequest, headers);
116
+ });
117
+ }
112
118
  createUser(user, headers) {
113
119
  return __awaiter(this, void 0, void 0, function* () {
114
120
  const url = '/api/users';
115
121
  return this.post(url, user, headers);
116
122
  });
117
123
  }
118
- updateOrder(updateRequest, headers) {
124
+ getUser(userId, headers) {
119
125
  return __awaiter(this, void 0, void 0, function* () {
120
- const url = '/api/orders/update';
121
- return this.post(url, updateRequest, headers);
126
+ const url = `/api/users/${userId}`;
127
+ return this.get(url, headers);
122
128
  });
123
129
  }
124
130
  rateUser(rateUserRequest, headers) {
@@ -145,6 +151,12 @@ class P2PMarketplaceAPIClient {
145
151
  return this.get(url, headers);
146
152
  });
147
153
  }
154
+ getDashboardMetrics(headers) {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ const url = '/api/dashboard/metrics';
157
+ return this.get(url, headers);
158
+ });
159
+ }
148
160
  testLockFunds(order, testParams, headers) {
149
161
  var _a, _b, _c, _d;
150
162
  return __awaiter(this, void 0, void 0, function* () {
package/dist/types.d.ts CHANGED
@@ -38,10 +38,14 @@ export interface Order {
38
38
  creatorRating: string;
39
39
  transactionsCount: number;
40
40
  chatId: string;
41
+ userMetrics?: UserMetrics[];
41
42
  }
42
43
  export interface OrderResponse {
43
44
  orders: Order[];
44
45
  }
46
+ export interface UsersResponse {
47
+ users: KioscoinUser[];
48
+ }
45
49
  export interface PaymentMethod {
46
50
  type: string;
47
51
  alias?: string;
@@ -92,6 +96,7 @@ export interface TakeBuyOrderRequest {
92
96
  hash?: string;
93
97
  }
94
98
  export interface CreateUserRequest {
99
+ id: string;
95
100
  username: string;
96
101
  }
97
102
  export interface UpdateOrderRequest {
@@ -147,8 +152,73 @@ export interface PushNotificationsRegisterRequest {
147
152
  token: string;
148
153
  userId: string;
149
154
  }
155
+ export interface DashboardMetricsResponse {
156
+ dashboardMetrics: DashboardMetrics;
157
+ }
158
+ export interface DashboardMetrics {
159
+ volumeTx: BlockchainVolumes[];
160
+ ordersPerBlockchain: OrdersPerBlockchain[];
161
+ ordersCompletedTx: number;
162
+ feesCollected: FeeCollected[];
163
+ durationInEscrowPerOrder: ReleasedOrderDuration[];
164
+ }
165
+ export interface BlockchainVolumes {
166
+ blockchainName: string;
167
+ volumes: TokenAmount;
168
+ }
169
+ export interface TokenAmount {
170
+ tokenCode: string;
171
+ amount: string;
172
+ }
173
+ export interface OrdersPerBlockchain {
174
+ blockchainName: string;
175
+ completedOrders: number;
176
+ }
177
+ export interface FeeCollected {
178
+ blockchainName: string;
179
+ fees: TokenAmount[];
180
+ }
181
+ export interface ReleasedOrderDuration {
182
+ orderId: string;
183
+ blockchain: string;
184
+ lockedAt: string;
185
+ releasedAt: string;
186
+ duration: number;
187
+ }
150
188
  export interface ConfigResponse<T = any> {
151
189
  config: T;
152
190
  }
153
191
  export interface TestEventParams {
154
192
  }
193
+ export interface UserMetrics {
194
+ userId: string;
195
+ avgTimeToLock: number;
196
+ avgTimeToRelease: number;
197
+ avgTimeToFiatSent: number;
198
+ }
199
+ export interface UserReview {
200
+ reviewId?: string;
201
+ rating?: number;
202
+ reviewedAt?: string;
203
+ }
204
+ export interface KioscoinUser {
205
+ id?: string;
206
+ username?: string;
207
+ lang?: string;
208
+ tradesCompleted?: number;
209
+ totalReviews?: number;
210
+ lastRating: string;
211
+ totalRating: string;
212
+ volumeTraded?: number;
213
+ admin?: boolean;
214
+ banned?: boolean;
215
+ showUsername?: boolean;
216
+ showVolumeTraded?: boolean;
217
+ lightningAddress?: string;
218
+ disputes?: number;
219
+ defaultCommunityId?: string;
220
+ timeToLock?: number;
221
+ timeToRelease?: number;
222
+ timeToFiatSent?: number;
223
+ reviews?: UserReview[];
224
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b5-api-client",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
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
@@ -85,6 +85,7 @@ async function testTakeOrder() {
85
85
 
86
86
  async function testCreateUser() {
87
87
  const user: CreateUserRequest = {
88
+ id: "123",
88
89
  username: "username_test"
89
90
  }
90
91
  const response = await client.createUser(user);
@@ -1,5 +1,5 @@
1
1
  import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
2
- import { CreateOrderRequest, CreateUserRequest, GetOrdersParams, Order, OrderLockedEvent, OrderResponse, ReleaseOrderEvent as OrderReleasedEvent, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse } from './types';
2
+ import { CreateOrderRequest, CreateUserRequest, GetOrdersParams, Order, OrderLockedEvent, OrderResponse, ReleaseOrderEvent as OrderReleasedEvent, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, KioscoinUser, UsersResponse } from './types';
3
3
  import { isPlainObject, camelCase, snakeCase, transform } from 'lodash';
4
4
 
5
5
  class P2PMarketplaceAPIClient {
@@ -96,16 +96,21 @@ class P2PMarketplaceAPIClient {
96
96
  return this.post<OrderResponse>(url, order, headers);
97
97
  }
98
98
 
99
- public async createUser(user: CreateUserRequest, headers?: Record<string, string>): Promise<Order> {
100
- const url = '/api/users';
101
- return this.post<Order>(url, user, headers);
102
- }
103
-
104
99
  public async updateOrder(updateRequest: UpdateOrderRequest, headers?: Record<string, string>): Promise<Order> {
105
100
  const url = '/api/orders/update';
106
101
  return this.post<Order>(url, updateRequest, headers);
107
102
  }
108
103
 
104
+ public async createUser(user: CreateUserRequest, headers?: Record<string, string>): Promise<UsersResponse> {
105
+ const url = '/api/users';
106
+ return this.post<UsersResponse>(url, user, headers);
107
+ }
108
+
109
+ public async getUser(userId: string, headers?: Record<string, string>): Promise<UsersResponse> {
110
+ const url = `/api/users/${userId}`;
111
+ return this.get<UsersResponse>(url, headers);
112
+ }
113
+
109
114
  public async rateUser(rateUserRequest: RateUserRequest, headers?: Record<string, string>): Promise<any> {
110
115
  const url = '/api/users/rate';
111
116
  return this.post<any>(url, rateUserRequest, headers);
@@ -126,6 +131,11 @@ class P2PMarketplaceAPIClient {
126
131
  return this.get<OrderEventsResponse>(url, headers);
127
132
  }
128
133
 
134
+ public async getDashboardMetrics(headers?: Record<string, string>): Promise<DashboardMetricsResponse> {
135
+ const url = '/api/dashboard/metrics';
136
+ return this.get<DashboardMetricsResponse>(url, headers);
137
+ }
138
+
129
139
  public async testLockFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>) {
130
140
  const orderEvent: OrderLockedEvent = {
131
141
  type: "LOCKED",
package/src/types.ts CHANGED
@@ -58,12 +58,17 @@ export interface Order {
58
58
  creatorRating: string;
59
59
  transactionsCount: number;
60
60
  chatId: string;
61
+ userMetrics?: UserMetrics[];
61
62
  }
62
63
 
63
64
  export interface OrderResponse {
64
65
  orders: Order[]
65
66
  }
66
67
 
68
+ export interface UsersResponse {
69
+ users: KioscoinUser[]
70
+ }
71
+
67
72
  export interface PaymentMethod {
68
73
  type: string;
69
74
  alias?: string;
@@ -120,6 +125,7 @@ export interface TakeBuyOrderRequest {
120
125
  }
121
126
 
122
127
  export interface CreateUserRequest {
128
+ id: string;
123
129
  username: string;
124
130
  }
125
131
 
@@ -184,10 +190,85 @@ export interface PushNotificationsRegisterRequest {
184
190
  userId: string;
185
191
  }
186
192
 
193
+ export interface DashboardMetricsResponse {
194
+ dashboardMetrics: DashboardMetrics;
195
+ }
196
+
197
+ export interface DashboardMetrics {
198
+ volumeTx: BlockchainVolumes[];
199
+ ordersPerBlockchain: OrdersPerBlockchain[];
200
+ ordersCompletedTx: number; // Total number of completed orders
201
+ feesCollected: FeeCollected[]; // Assuming this is defined elsewhere
202
+ durationInEscrowPerOrder: ReleasedOrderDuration[]; // Assuming this is defined elsewhere
203
+ }
204
+
205
+ export interface BlockchainVolumes {
206
+ blockchainName: string;
207
+ volumes: TokenAmount;
208
+ }
209
+
210
+ export interface TokenAmount {
211
+ tokenCode: string;
212
+ amount: string; // Assuming Amount is defined elsewhere
213
+ }
214
+
215
+ export interface OrdersPerBlockchain {
216
+ blockchainName: string;
217
+ completedOrders: number;
218
+ }
219
+
220
+ export interface FeeCollected {
221
+ blockchainName: string;
222
+ fees: TokenAmount[]
223
+ }
224
+
225
+ export interface ReleasedOrderDuration {
226
+ orderId: string
227
+ blockchain: string
228
+ lockedAt: string
229
+ releasedAt: string
230
+ duration: number
231
+ }
232
+
187
233
  export interface ConfigResponse<T = any> {
188
234
  config: T;
189
235
  }
190
236
 
191
237
  export interface TestEventParams {
192
238
 
239
+ }
240
+
241
+ export interface UserMetrics {
242
+ userId: string;
243
+ avgTimeToLock: number;
244
+ avgTimeToRelease: number;
245
+ avgTimeToFiatSent: number;
246
+ }
247
+
248
+ export interface UserReview {
249
+ reviewId?: string;
250
+ rating?: number;
251
+ reviewedAt?: string;
252
+ }
253
+
254
+ export interface KioscoinUser {
255
+ id?: string;
256
+ username?: string;
257
+ lang?: string;
258
+ tradesCompleted?: number;
259
+ totalReviews?: number;
260
+ lastRating: string;
261
+ totalRating: string;
262
+ volumeTraded?: number;
263
+ admin?: boolean;
264
+ banned?: boolean;
265
+ showUsername?: boolean;
266
+ showVolumeTraded?: boolean;
267
+ lightningAddress?: string;
268
+ disputes?: number;
269
+ defaultCommunityId?: string;
270
+ timeToLock?: number;
271
+ timeToRelease?: number;
272
+ timeToFiatSent?: number;
273
+ reviews?: UserReview[];
193
274
  }