-
Notifications
You must be signed in to change notification settings - Fork 5
/
PayByLinkApiAdapter.ts
36 lines (27 loc) · 1.3 KB
/
PayByLinkApiAdapter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {ClientCreationOptions} from '../lib/HttpClient';
import CreateProductRequest from '../request/CreateProductRequest';
import SearchProductsRequest from '../request/SearchProductsRequest';
import UpdateProductRequest from '../request/UpdateProductRequest';
import DataResponse from '../response/DataResponse';
import ProductResponse from '../response/ProductResponse';
import BaseAdapter from './BaseAdapter';
export default class PayByLinkApiAdapter extends BaseAdapter {
constructor(options: ClientCreationOptions) {
super(options);
}
async createProduct(request: CreateProductRequest): Promise<ProductResponse> {
return this._client.post('/craftlink/v1/products', request);
}
async updateProduct(productId: number, request: UpdateProductRequest): Promise<ProductResponse> {
return this._client.put(`/craftlink/v1/products/${productId}`, request);
}
async retrieveProduct(productId: number): Promise<ProductResponse> {
return this._client.get(`/craftlink/v1/products/${productId}`);
}
async deleteProduct(productId: number): Promise<void> {
await this._client.delete(`/craftlink/v1/products/${productId}`);
}
async searchProducts(request: SearchProductsRequest): Promise<DataResponse<ProductResponse>> {
return this._client.get(`/craftlink/v1/products`, request);
}
}