-
Notifications
You must be signed in to change notification settings - Fork 62
/
paymentsAppApi.ts
151 lines (142 loc) · 7.75 KB
/
paymentsAppApi.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* The version of the OpenAPI document: v1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit this class manually.
*/
import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
import Client from "../../client";
import {
BoardingTokenRequest,
BoardingTokenResponse,
PaymentsAppResponse,
ObjectSerializer
} from "../../typings/paymentsApp/models";
import { IRequest } from "../../typings/requestOptions";
import Resource from "../resource";
export class PaymentsAppApi extends Service {
private readonly API_BASEPATH: string = "https://management-live.adyen.com/v1";
private baseUrl: string;
public constructor(client: Client){
super(client);
this.baseUrl = this.createBaseUrl(this.API_BASEPATH);
}
/**
* @summary Create a boarding token - merchant level
* @param merchantId {@link string } The unique identifier of the merchant account.
* @param boardingTokenRequest {@link BoardingTokenRequest }
* @param requestOptions {@link IRequest.Options }
* @return {@link BoardingTokenResponse }
*/
public async generatePaymentsAppBoardingTokenForMerchant(merchantId: string, boardingTokenRequest: BoardingTokenRequest, requestOptions?: IRequest.Options): Promise<BoardingTokenResponse> {
const endpoint = `${this.baseUrl}/merchants/{merchantId}/generatePaymentsAppBoardingToken`
.replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId)));
const resource = new Resource(this, endpoint);
const request: BoardingTokenRequest = ObjectSerializer.serialize(boardingTokenRequest, "BoardingTokenRequest");
const response = await getJsonResponse<BoardingTokenRequest, BoardingTokenResponse>(
resource,
request,
{ ...requestOptions, method: "POST" }
);
return ObjectSerializer.deserialize(response, "BoardingTokenResponse");
}
/**
* @summary Create a boarding token - store level
* @param merchantId {@link string } The unique identifier of the merchant account.
* @param storeId {@link string } The unique identifier of the store.
* @param boardingTokenRequest {@link BoardingTokenRequest }
* @param requestOptions {@link IRequest.Options }
* @return {@link BoardingTokenResponse }
*/
public async generatePaymentsAppBoardingTokenForStore(merchantId: string, storeId: string, boardingTokenRequest: BoardingTokenRequest, requestOptions?: IRequest.Options): Promise<BoardingTokenResponse> {
const endpoint = `${this.baseUrl}/merchants/{merchantId}/stores/{storeId}/generatePaymentsAppBoardingToken`
.replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId)))
.replace("{" + "storeId" + "}", encodeURIComponent(String(storeId)));
const resource = new Resource(this, endpoint);
const request: BoardingTokenRequest = ObjectSerializer.serialize(boardingTokenRequest, "BoardingTokenRequest");
const response = await getJsonResponse<BoardingTokenRequest, BoardingTokenResponse>(
resource,
request,
{ ...requestOptions, method: "POST" }
);
return ObjectSerializer.deserialize(response, "BoardingTokenResponse");
}
/**
* @summary Get a list of Payments Apps - merchant level
* @param merchantId {@link string } The unique identifier of the merchant account.
* @param requestOptions {@link IRequest.Options }
* @param statuses {@link string } The status of the Payments App. Comma-separated list of one or more values. If no value is provided, the list returns all statuses. Possible values: * **BOARDED** * **REVOKED**
* @param limit {@link number } The number of items to return.
* @param offset {@link number } The number of items to skip.
* @return {@link PaymentsAppResponse }
*/
public async listPaymentsAppForMerchant(merchantId: string, statuses?: string, limit?: number, offset?: number, requestOptions?: IRequest.Options): Promise<PaymentsAppResponse> {
const endpoint = `${this.baseUrl}/merchants/{merchantId}/paymentsApps`
.replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId)));
const resource = new Resource(this, endpoint);
const hasDefinedQueryParams = statuses ?? limit ?? offset;
if(hasDefinedQueryParams) {
if(!requestOptions) requestOptions = {};
if(!requestOptions.params) requestOptions.params = {};
if(statuses) requestOptions.params["statuses"] = statuses;
if(limit) requestOptions.params["limit"] = limit;
if(offset) requestOptions.params["offset"] = offset;
}
const response = await getJsonResponse<string, PaymentsAppResponse>(
resource,
"",
{ ...requestOptions, method: "GET" }
);
return ObjectSerializer.deserialize(response, "PaymentsAppResponse");
}
/**
* @summary Get a list of Payments Apps - store level
* @param merchantId {@link string } The unique identifier of the merchant account.
* @param storeId {@link string } The unique identifier of the store.
* @param requestOptions {@link IRequest.Options }
* @param statuses {@link string } The status of the Payments App. Comma-separated list of one or more values. If no value is provided, the list returns all statuses. Possible values: * **BOARDED** * **REVOKED**
* @param limit {@link number } The number of items to return.
* @param offset {@link number } The number of items to skip.
* @return {@link PaymentsAppResponse }
*/
public async listPaymentsAppForStore(merchantId: string, storeId: string, statuses?: string, limit?: number, offset?: number, requestOptions?: IRequest.Options): Promise<PaymentsAppResponse> {
const endpoint = `${this.baseUrl}/merchants/{merchantId}/stores/{storeId}/paymentsApps`
.replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId)))
.replace("{" + "storeId" + "}", encodeURIComponent(String(storeId)));
const resource = new Resource(this, endpoint);
const hasDefinedQueryParams = statuses ?? limit ?? offset;
if(hasDefinedQueryParams) {
if(!requestOptions) requestOptions = {};
if(!requestOptions.params) requestOptions.params = {};
if(statuses) requestOptions.params["statuses"] = statuses;
if(limit) requestOptions.params["limit"] = limit;
if(offset) requestOptions.params["offset"] = offset;
}
const response = await getJsonResponse<string, PaymentsAppResponse>(
resource,
"",
{ ...requestOptions, method: "GET" }
);
return ObjectSerializer.deserialize(response, "PaymentsAppResponse");
}
/**
* @summary Revoke Payments App instance authentication
* @param merchantId {@link string } The unique identifier of the merchant account.
* @param installationId {@link string } The unique identifier of the Payments App instance on a device.
* @param requestOptions {@link IRequest.Options }
*/
public async revokePaymentsApp(merchantId: string, installationId: string, requestOptions?: IRequest.Options): Promise<void> {
const endpoint = `${this.baseUrl}/merchants/{merchantId}/paymentsApps/{installationId}/revoke`
.replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId)))
.replace("{" + "installationId" + "}", encodeURIComponent(String(installationId)));
const resource = new Resource(this, endpoint);
await getJsonResponse<string, void>(
resource,
"",
{ ...requestOptions, method: "POST" }
);
}
}