|
| 1 | +/* |
| 2 | + * The version of the OpenAPI document: v1 |
| 3 | + * |
| 4 | + * |
| 5 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 6 | + * https://openapi-generator.tech |
| 7 | + * Do not edit this class manually. |
| 8 | + */ |
| 9 | + |
| 10 | +import getJsonResponse from "../../helpers/getJsonResponse"; |
| 11 | +import Service from "../../service"; |
| 12 | +import Client from "../../client"; |
| 13 | +import { |
| 14 | + BoardingTokenRequest, |
| 15 | + BoardingTokenResponse, |
| 16 | + PaymentsAppResponse, |
| 17 | + ObjectSerializer |
| 18 | +} from "../../typings/paymentsApp/models"; |
| 19 | +import { IRequest } from "../../typings/requestOptions"; |
| 20 | +import Resource from "../resource"; |
| 21 | + |
| 22 | +export class PaymentsAppApi extends Service { |
| 23 | + |
| 24 | + private readonly API_BASEPATH: string = "https://management-live.adyen.com/v1"; |
| 25 | + private baseUrl: string; |
| 26 | + |
| 27 | + public constructor(client: Client){ |
| 28 | + super(client); |
| 29 | + this.baseUrl = this.createBaseUrl(this.API_BASEPATH); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @summary Create a boarding token - merchant level |
| 34 | + * @param merchantId {@link string } The unique identifier of the merchant account. |
| 35 | + * @param boardingTokenRequest {@link BoardingTokenRequest } |
| 36 | + * @param requestOptions {@link IRequest.Options } |
| 37 | + * @return {@link BoardingTokenResponse } |
| 38 | + */ |
| 39 | + public async generatePaymentsAppBoardingTokenForMerchant(merchantId: string, boardingTokenRequest: BoardingTokenRequest, requestOptions?: IRequest.Options): Promise<BoardingTokenResponse> { |
| 40 | + const endpoint = `${this.baseUrl}/merchants/{merchantId}/generatePaymentsAppBoardingToken` |
| 41 | + .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))); |
| 42 | + const resource = new Resource(this, endpoint); |
| 43 | + const request: BoardingTokenRequest = ObjectSerializer.serialize(boardingTokenRequest, "BoardingTokenRequest"); |
| 44 | + const response = await getJsonResponse<BoardingTokenRequest, BoardingTokenResponse>( |
| 45 | + resource, |
| 46 | + request, |
| 47 | + { ...requestOptions, method: "POST" } |
| 48 | + ); |
| 49 | + return ObjectSerializer.deserialize(response, "BoardingTokenResponse"); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @summary Create a boarding token - store level |
| 54 | + * @param merchantId {@link string } The unique identifier of the merchant account. |
| 55 | + * @param storeId {@link string } The unique identifier of the store. |
| 56 | + * @param boardingTokenRequest {@link BoardingTokenRequest } |
| 57 | + * @param requestOptions {@link IRequest.Options } |
| 58 | + * @return {@link BoardingTokenResponse } |
| 59 | + */ |
| 60 | + public async generatePaymentsAppBoardingTokenForStore(merchantId: string, storeId: string, boardingTokenRequest: BoardingTokenRequest, requestOptions?: IRequest.Options): Promise<BoardingTokenResponse> { |
| 61 | + const endpoint = `${this.baseUrl}/merchants/{merchantId}/stores/{storeId}/generatePaymentsAppBoardingToken` |
| 62 | + .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) |
| 63 | + .replace("{" + "storeId" + "}", encodeURIComponent(String(storeId))); |
| 64 | + const resource = new Resource(this, endpoint); |
| 65 | + const request: BoardingTokenRequest = ObjectSerializer.serialize(boardingTokenRequest, "BoardingTokenRequest"); |
| 66 | + const response = await getJsonResponse<BoardingTokenRequest, BoardingTokenResponse>( |
| 67 | + resource, |
| 68 | + request, |
| 69 | + { ...requestOptions, method: "POST" } |
| 70 | + ); |
| 71 | + return ObjectSerializer.deserialize(response, "BoardingTokenResponse"); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * @summary Get a list of Payments Apps - merchant level |
| 76 | + * @param merchantId {@link string } The unique identifier of the merchant account. |
| 77 | + * @param requestOptions {@link IRequest.Options } |
| 78 | + * @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** |
| 79 | + * @param limit {@link number } The number of items to return. |
| 80 | + * @param offset {@link number } The number of items to skip. |
| 81 | + * @return {@link PaymentsAppResponse } |
| 82 | + */ |
| 83 | + public async listPaymentsAppForMerchant(merchantId: string, statuses?: string, limit?: number, offset?: number, requestOptions?: IRequest.Options): Promise<PaymentsAppResponse> { |
| 84 | + const endpoint = `${this.baseUrl}/merchants/{merchantId}/paymentsApps` |
| 85 | + .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))); |
| 86 | + const resource = new Resource(this, endpoint); |
| 87 | + const hasDefinedQueryParams = statuses ?? limit ?? offset; |
| 88 | + if(hasDefinedQueryParams) { |
| 89 | + if(!requestOptions) requestOptions = {}; |
| 90 | + if(!requestOptions.params) requestOptions.params = {}; |
| 91 | + if(statuses) requestOptions.params["statuses"] = statuses; |
| 92 | + if(limit) requestOptions.params["limit"] = limit; |
| 93 | + if(offset) requestOptions.params["offset"] = offset; |
| 94 | + } |
| 95 | + const response = await getJsonResponse<string, PaymentsAppResponse>( |
| 96 | + resource, |
| 97 | + "", |
| 98 | + { ...requestOptions, method: "GET" } |
| 99 | + ); |
| 100 | + return ObjectSerializer.deserialize(response, "PaymentsAppResponse"); |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * @summary Get a list of Payments Apps - store level |
| 105 | + * @param merchantId {@link string } The unique identifier of the merchant account. |
| 106 | + * @param storeId {@link string } The unique identifier of the store. |
| 107 | + * @param requestOptions {@link IRequest.Options } |
| 108 | + * @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** |
| 109 | + * @param limit {@link number } The number of items to return. |
| 110 | + * @param offset {@link number } The number of items to skip. |
| 111 | + * @return {@link PaymentsAppResponse } |
| 112 | + */ |
| 113 | + public async listPaymentsAppForStore(merchantId: string, storeId: string, statuses?: string, limit?: number, offset?: number, requestOptions?: IRequest.Options): Promise<PaymentsAppResponse> { |
| 114 | + const endpoint = `${this.baseUrl}/merchants/{merchantId}/stores/{storeId}/paymentsApps` |
| 115 | + .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) |
| 116 | + .replace("{" + "storeId" + "}", encodeURIComponent(String(storeId))); |
| 117 | + const resource = new Resource(this, endpoint); |
| 118 | + const hasDefinedQueryParams = statuses ?? limit ?? offset; |
| 119 | + if(hasDefinedQueryParams) { |
| 120 | + if(!requestOptions) requestOptions = {}; |
| 121 | + if(!requestOptions.params) requestOptions.params = {}; |
| 122 | + if(statuses) requestOptions.params["statuses"] = statuses; |
| 123 | + if(limit) requestOptions.params["limit"] = limit; |
| 124 | + if(offset) requestOptions.params["offset"] = offset; |
| 125 | + } |
| 126 | + const response = await getJsonResponse<string, PaymentsAppResponse>( |
| 127 | + resource, |
| 128 | + "", |
| 129 | + { ...requestOptions, method: "GET" } |
| 130 | + ); |
| 131 | + return ObjectSerializer.deserialize(response, "PaymentsAppResponse"); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * @summary Revoke Payments App instance authentication |
| 136 | + * @param merchantId {@link string } The unique identifier of the merchant account. |
| 137 | + * @param installationId {@link string } The unique identifier of the Payments App instance on a device. |
| 138 | + * @param requestOptions {@link IRequest.Options } |
| 139 | + */ |
| 140 | + public async revokePaymentsApp(merchantId: string, installationId: string, requestOptions?: IRequest.Options): Promise<void> { |
| 141 | + const endpoint = `${this.baseUrl}/merchants/{merchantId}/paymentsApps/{installationId}/revoke` |
| 142 | + .replace("{" + "merchantId" + "}", encodeURIComponent(String(merchantId))) |
| 143 | + .replace("{" + "installationId" + "}", encodeURIComponent(String(installationId))); |
| 144 | + const resource = new Resource(this, endpoint); |
| 145 | + await getJsonResponse<string, void>( |
| 146 | + resource, |
| 147 | + "", |
| 148 | + { ...requestOptions, method: "POST" } |
| 149 | + ); |
| 150 | + } |
| 151 | +} |
0 commit comments