b5-api-client 0.0.25 → 0.0.26
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, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse, GetOrdersParams, CreateDisputeRequest, DisputesResponse, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest } from './types';
|
|
1
|
+
import { CreateOrderRequest, CreateUserRequest, Order, OrderResponse, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse, RateUserRequest, OrderEventsResponse, PushNotificationsRegisterRequest, ConfigResponse, DashboardMetricsResponse, UsersResponse, GetOrdersParams, CreateDisputeRequest, DisputesResponse, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest, NotificationsResponse } from './types';
|
|
2
2
|
declare class P2PMarketplaceAPIClient {
|
|
3
3
|
private readonly client;
|
|
4
4
|
private readonly defaultHeaders;
|
|
@@ -17,6 +17,8 @@ declare class P2PMarketplaceAPIClient {
|
|
|
17
17
|
rateUser(rateUserRequest: RateUserRequest, headers?: Record<string, string>): Promise<any>;
|
|
18
18
|
updateUserSettings(request: UpdateUserSettingsRequest, headers?: Record<string, string>): Promise<UsersResponse>;
|
|
19
19
|
registerPushToken(registerRequest: PushNotificationsRegisterRequest, headers?: Record<string, string>): Promise<any>;
|
|
20
|
+
listNotifications(limit?: number, offset?: number, headers?: Record<string, string>): Promise<NotificationsResponse>;
|
|
21
|
+
markNotificationAsRead(notificationId: string, headers?: Record<string, string>): Promise<NotificationsResponse>;
|
|
20
22
|
getConfig<T>(): Promise<ConfigResponse<T>>;
|
|
21
23
|
getOrderEvents(id: string, headers?: Record<string, string>): Promise<OrderEventsResponse>;
|
|
22
24
|
getDashboardMetrics(headers?: Record<string, string>): Promise<DashboardMetricsResponse>;
|
|
@@ -163,6 +163,18 @@ class P2PMarketplaceAPIClient {
|
|
|
163
163
|
return this.post(url, registerRequest, headers);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
+
listNotifications(limit = 10, offset = 0, headers) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const url = `/api/notifications?limit=${limit}&offset=${offset}`;
|
|
169
|
+
return this.get(url, headers);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
markNotificationAsRead(notificationId, headers) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
const url = `/api/notifications/${notificationId}/read`;
|
|
175
|
+
return this.post(url, {}, headers);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
166
178
|
getConfig() {
|
|
167
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
180
|
const url = '/api/configuration';
|
package/dist/types.d.ts
CHANGED
|
@@ -339,3 +339,39 @@ export interface KioscoinOperationResponse {
|
|
|
339
339
|
error?: OperationError;
|
|
340
340
|
order?: Order;
|
|
341
341
|
}
|
|
342
|
+
export type MessageContentType = 'TEXT' | 'ACTION' | 'EVENT' | 'NOTIFICATION';
|
|
343
|
+
export interface MessageContentBase {
|
|
344
|
+
type: MessageContentType;
|
|
345
|
+
}
|
|
346
|
+
export interface MessageContentText extends MessageContentBase {
|
|
347
|
+
type: 'TEXT';
|
|
348
|
+
text: string;
|
|
349
|
+
}
|
|
350
|
+
export interface MessageContentAction extends MessageContentBase {
|
|
351
|
+
type: 'ACTION';
|
|
352
|
+
content: string;
|
|
353
|
+
}
|
|
354
|
+
export interface MessageContentEvent extends MessageContentBase {
|
|
355
|
+
type: 'EVENT';
|
|
356
|
+
event: OrderEvent;
|
|
357
|
+
}
|
|
358
|
+
export interface MessageContentNotification extends MessageContentBase {
|
|
359
|
+
type: 'NOTIFICATION';
|
|
360
|
+
notification: NotificationDto;
|
|
361
|
+
}
|
|
362
|
+
export type MessageContent = MessageContentText | MessageContentAction | MessageContentEvent | MessageContentNotification;
|
|
363
|
+
export interface Message {
|
|
364
|
+
sender: string;
|
|
365
|
+
timestamp: number;
|
|
366
|
+
content: MessageContent;
|
|
367
|
+
}
|
|
368
|
+
export interface NotificationDto {
|
|
369
|
+
id: string;
|
|
370
|
+
userId: string;
|
|
371
|
+
message: Message;
|
|
372
|
+
createdAt: string;
|
|
373
|
+
readAt?: string | null;
|
|
374
|
+
}
|
|
375
|
+
export interface NotificationsResponse {
|
|
376
|
+
notifications: NotificationDto[];
|
|
377
|
+
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
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, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest } from './types';
|
|
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, OrderOffersResponse, TransactionRequest, KioscoinOperationResponse, UpdateUserSettingsRequest, NotificationsResponse } from './types';
|
|
3
3
|
import { isPlainObject, camelCase, snakeCase, transform } from 'lodash';
|
|
4
4
|
|
|
5
5
|
class P2PMarketplaceAPIClient {
|
|
@@ -147,6 +147,16 @@ class P2PMarketplaceAPIClient {
|
|
|
147
147
|
return this.post<PushNotificationsRegisterRequest>(url, registerRequest, headers);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
public async listNotifications(limit: number = 10, offset: number = 0, headers?: Record<string, string>): Promise<NotificationsResponse> {
|
|
151
|
+
const url = `/api/notifications?limit=${limit}&offset=${offset}`;
|
|
152
|
+
return this.get<NotificationsResponse>(url, headers);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public async markNotificationAsRead(notificationId: string, headers?: Record<string, string>): Promise<NotificationsResponse> {
|
|
156
|
+
const url = `/api/notifications/${notificationId}/read`;
|
|
157
|
+
return this.post<any>(url, {}, headers);
|
|
158
|
+
}
|
|
159
|
+
|
|
150
160
|
public async getConfig<T>(): Promise<ConfigResponse<T>> {
|
|
151
161
|
const url = '/api/configuration';
|
|
152
162
|
return await this.get<ConfigResponse<T>>(url);
|
package/src/types.ts
CHANGED
|
@@ -406,3 +406,53 @@ export interface KioscoinOperationResponse {
|
|
|
406
406
|
error?: OperationError;
|
|
407
407
|
order?: Order;
|
|
408
408
|
}
|
|
409
|
+
|
|
410
|
+
export type MessageContentType = 'TEXT' | 'ACTION' | 'EVENT' | 'NOTIFICATION';
|
|
411
|
+
|
|
412
|
+
export interface MessageContentBase {
|
|
413
|
+
type: MessageContentType;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export interface MessageContentText extends MessageContentBase {
|
|
417
|
+
type: 'TEXT';
|
|
418
|
+
text: string;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export interface MessageContentAction extends MessageContentBase {
|
|
422
|
+
type: 'ACTION';
|
|
423
|
+
content: string;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface MessageContentEvent extends MessageContentBase {
|
|
427
|
+
type: 'EVENT';
|
|
428
|
+
event: OrderEvent;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface MessageContentNotification extends MessageContentBase {
|
|
432
|
+
type: 'NOTIFICATION';
|
|
433
|
+
notification: NotificationDto;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export type MessageContent =
|
|
437
|
+
| MessageContentText
|
|
438
|
+
| MessageContentAction
|
|
439
|
+
| MessageContentEvent
|
|
440
|
+
| MessageContentNotification;
|
|
441
|
+
|
|
442
|
+
export interface Message {
|
|
443
|
+
sender: string;
|
|
444
|
+
timestamp: number;
|
|
445
|
+
content: MessageContent;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface NotificationDto {
|
|
449
|
+
id: string;
|
|
450
|
+
userId: string;
|
|
451
|
+
message: Message;
|
|
452
|
+
createdAt: string;
|
|
453
|
+
readAt?: string | null;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export interface NotificationsResponse {
|
|
457
|
+
notifications: NotificationDto[];
|
|
458
|
+
}
|