b5-api-client 0.0.4 → 0.0.5
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/package.json +1 -1
- package/src/P2PMarketplaceAPIClient.ts +21 -1
- package/src/types.ts +6 -0
package/package.json
CHANGED
|
@@ -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 } from './types';
|
|
2
|
+
import { CreateOrderRequest, CreateUserRequest, GetOrdersParams, Order, OrderLockedEvent, OrderResponse, ReleaseOrderEvent as OrderReleasedEvent, TakeOrderRequest, TestEventParams, UpdateOrderRequest, TransactionStatusResponse } from './types';
|
|
3
3
|
import { isPlainObject, camelCase, snakeCase, transform } from 'lodash';
|
|
4
4
|
|
|
5
5
|
class P2PMarketplaceAPIClient {
|
|
@@ -157,6 +157,26 @@ class P2PMarketplaceAPIClient {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
public async releaseFunds(order: Order, testParams?: TestEventParams, headers?: Record<string, string>): Promise<string> {
|
|
161
|
+
const body = {
|
|
162
|
+
orderId: order.id ?? "",
|
|
163
|
+
isAdmin: true
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const url = "api/orders/release"
|
|
167
|
+
try {
|
|
168
|
+
return await this.post<string>(url, body, headers);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error("Error releasing funds:", error);
|
|
171
|
+
throw new Error("Failed to release funds");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public async getTransactionStatus(txHash: string, headers?: Record<string, string>): Promise<TransactionStatusResponse> {
|
|
176
|
+
const url = `/api/blockchain/transactions/${txHash}`;
|
|
177
|
+
return this.get<TransactionStatusResponse>(url, headers);
|
|
178
|
+
}
|
|
179
|
+
|
|
160
180
|
}
|
|
161
181
|
|
|
162
182
|
function toSnakeCase(obj: any): any {
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface PaymentMethod {
|
|
|
22
22
|
username: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export interface TransactionStatusResponse {
|
|
26
|
+
hash: string;
|
|
27
|
+
block_number: number | null;
|
|
28
|
+
status: 'PENDING' | 'SUCCESSFULL' | 'FAILED';
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
export interface Order {
|
|
26
32
|
type: OrderType;
|
|
27
33
|
id?: string;
|