|
| 1 | +/* |
| 2 | + * The version of the OpenAPI document: v2 |
| 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 | + |
| 11 | +import getJsonResponse from "../../helpers/getJsonResponse"; |
| 12 | +import Service from "../../service"; |
| 13 | +import Client from "../../client"; |
| 14 | +import { IRequest } from "../../typings/requestOptions"; |
| 15 | +import Resource from "../resource"; |
| 16 | + |
| 17 | +import { ObjectSerializer } from "../../typings/balancePlatform/objectSerializer"; |
| 18 | +import { ApproveTransferLimitRequest } from "../../typings/balancePlatform/models"; |
| 19 | +import { CreateTransferLimitRequest } from "../../typings/balancePlatform/models"; |
| 20 | +import { LimitStatus } from "../../typings/balancePlatform/models"; |
| 21 | +import { Scope } from "../../typings/balancePlatform/models"; |
| 22 | +import { TransferLimit } from "../../typings/balancePlatform/models"; |
| 23 | +import { TransferLimitListResponse } from "../../typings/balancePlatform/models"; |
| 24 | +import { TransferType } from "../../typings/balancePlatform/models"; |
| 25 | + |
| 26 | +/** |
| 27 | + * API handler for TransferLimitsBalanceAccountLevelApi |
| 28 | + */ |
| 29 | +export class TransferLimitsBalanceAccountLevelApi extends Service { |
| 30 | + |
| 31 | + private readonly API_BASEPATH: string = "https://balanceplatform-api-test.adyen.com/bcl/v2"; |
| 32 | + private baseUrl: string; |
| 33 | + |
| 34 | + public constructor(client: Client){ |
| 35 | + super(client); |
| 36 | + this.baseUrl = this.createBaseUrl(this.API_BASEPATH); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @summary Approve pending transfer limits |
| 41 | + * @param id {@link string } The unique identifier of the balance account. |
| 42 | + * @param approveTransferLimitRequest {@link ApproveTransferLimitRequest } |
| 43 | + * @param requestOptions {@link IRequest.Options } |
| 44 | + * @return {@link void } |
| 45 | + */ |
| 46 | + public async approvePendingTransferLimits(id: string, approveTransferLimitRequest: ApproveTransferLimitRequest, requestOptions?: IRequest.Options): Promise<void> { |
| 47 | + const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/approve` |
| 48 | + .replace("{" + "id" + "}", encodeURIComponent(String(id))); |
| 49 | + const resource = new Resource(this, endpoint); |
| 50 | + |
| 51 | + const request: ApproveTransferLimitRequest = ObjectSerializer.serialize(approveTransferLimitRequest, "ApproveTransferLimitRequest"); |
| 52 | + await getJsonResponse<ApproveTransferLimitRequest, void>( |
| 53 | + resource, |
| 54 | + request, |
| 55 | + { ...requestOptions, method: "POST" } |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * @summary Create a transfer limit |
| 61 | + * @param id {@link string } The unique identifier of the balance account. |
| 62 | + * @param createTransferLimitRequest {@link CreateTransferLimitRequest } |
| 63 | + * @param requestOptions {@link IRequest.Options } |
| 64 | + * @return {@link TransferLimit } |
| 65 | + */ |
| 66 | + public async createTransferLimit(id: string, createTransferLimitRequest: CreateTransferLimitRequest, requestOptions?: IRequest.Options): Promise<TransferLimit> { |
| 67 | + const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits` |
| 68 | + .replace("{" + "id" + "}", encodeURIComponent(String(id))); |
| 69 | + const resource = new Resource(this, endpoint); |
| 70 | + |
| 71 | + const request: CreateTransferLimitRequest = ObjectSerializer.serialize(createTransferLimitRequest, "CreateTransferLimitRequest"); |
| 72 | + const response = await getJsonResponse<CreateTransferLimitRequest, TransferLimit>( |
| 73 | + resource, |
| 74 | + request, |
| 75 | + { ...requestOptions, method: "POST" } |
| 76 | + ); |
| 77 | + |
| 78 | + return ObjectSerializer.deserialize(response, "TransferLimit"); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * @summary Delete a scheduled or pending transfer limit |
| 83 | + * @param transferLimitId {@link string } The unique identifier of the transfer limit. |
| 84 | + * @param id {@link string } The unique identifier of the balance account. |
| 85 | + * @param requestOptions {@link IRequest.Options } |
| 86 | + * @return {@link void } |
| 87 | + */ |
| 88 | + public async deletePendingTransferLimit(transferLimitId: string, id: string, requestOptions?: IRequest.Options): Promise<void> { |
| 89 | + const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/{transferLimitId}` |
| 90 | + .replace("{" + "transferLimitId" + "}", encodeURIComponent(String(transferLimitId))) |
| 91 | + .replace("{" + "id" + "}", encodeURIComponent(String(id))); |
| 92 | + const resource = new Resource(this, endpoint); |
| 93 | + |
| 94 | + await getJsonResponse<string, void>( |
| 95 | + resource, |
| 96 | + "", |
| 97 | + { ...requestOptions, method: "DELETE" } |
| 98 | + ); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * @summary Get all current transfer limits |
| 103 | + * @param id {@link string } The unique identifier of the balance account. |
| 104 | + * @param requestOptions {@link IRequest.Options } |
| 105 | + * @param scope {@link Scope } The scope to which the transfer limit applies. Possible values: * **perTransaction**: you set a maximum amount for each transfer made from the balance account or balance platform. * **perDay**: you set a maximum total amount for all transfers made from the balance account or balance platform in a day. |
| 106 | + * @param transferType {@link TransferType } The type of transfer to which the limit applies. Possible values: * **instant**: the limit applies to transfers with an **instant** priority. * **all**: the limit applies to all transfers, regardless of priority. |
| 107 | + * @return {@link TransferLimitListResponse } |
| 108 | + */ |
| 109 | + public async getCurrentTransferLimits(id: string, scope?: Scope, transferType?: TransferType, requestOptions?: IRequest.Options): Promise<TransferLimitListResponse> { |
| 110 | + const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/current` |
| 111 | + .replace("{" + "id" + "}", encodeURIComponent(String(id))); |
| 112 | + const resource = new Resource(this, endpoint); |
| 113 | + |
| 114 | + const hasDefinedQueryParams = scope ?? transferType; |
| 115 | + if(hasDefinedQueryParams) { |
| 116 | + if(!requestOptions) requestOptions = {}; |
| 117 | + if(!requestOptions.params) requestOptions.params = {}; |
| 118 | + if(scope) requestOptions.params["scope"] = scope; |
| 119 | + if(transferType) requestOptions.params["transferType"] = transferType; |
| 120 | + } |
| 121 | + const response = await getJsonResponse<string, TransferLimitListResponse>( |
| 122 | + resource, |
| 123 | + "", |
| 124 | + { ...requestOptions, method: "GET" } |
| 125 | + ); |
| 126 | + |
| 127 | + return ObjectSerializer.deserialize(response, "TransferLimitListResponse"); |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * @summary Get the details of a transfer limit |
| 132 | + * @param transferLimitId {@link string } The unique identifier of the transfer limit. |
| 133 | + * @param id {@link string } The unique identifier of the balance account. |
| 134 | + * @param requestOptions {@link IRequest.Options } |
| 135 | + * @return {@link TransferLimit } |
| 136 | + */ |
| 137 | + public async getSpecificTransferLimit(transferLimitId: string, id: string, requestOptions?: IRequest.Options): Promise<TransferLimit> { |
| 138 | + const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/{transferLimitId}` |
| 139 | + .replace("{" + "transferLimitId" + "}", encodeURIComponent(String(transferLimitId))) |
| 140 | + .replace("{" + "id" + "}", encodeURIComponent(String(id))); |
| 141 | + const resource = new Resource(this, endpoint); |
| 142 | + |
| 143 | + const response = await getJsonResponse<string, TransferLimit>( |
| 144 | + resource, |
| 145 | + "", |
| 146 | + { ...requestOptions, method: "GET" } |
| 147 | + ); |
| 148 | + |
| 149 | + return ObjectSerializer.deserialize(response, "TransferLimit"); |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * @summary Filter and view the transfer limits |
| 154 | + * @param id {@link string } The unique identifier of the balance account. |
| 155 | + * @param requestOptions {@link IRequest.Options } |
| 156 | + * @param scope {@link Scope } The scope to which the transfer limit applies. Possible values: * **perTransaction**: you set a maximum amount for each transfer made from the balance account or balance platform. * **perDay**: you set a maximum total amount for all transfers made from the balance account or balance platform in a day. |
| 157 | + * @param transferType {@link TransferType } The type of transfer to which the limit applies. Possible values: * **instant**: the limit applies to transfers with an **instant** priority. * **all**: the limit applies to all transfers, regardless of priority. |
| 158 | + * @param status {@link LimitStatus } The status of the transfer limit. Possible values: * **active**: the limit is currently active. * **inactive**: the limit is currently inactive. * **pendingSCA**: the limit is pending until your user performs SCA. * **scheduled**: the limit is scheduled to become active at a future date. |
| 159 | + * @return {@link TransferLimitListResponse } |
| 160 | + */ |
| 161 | + public async getTransferLimits(id: string, scope?: Scope, transferType?: TransferType, status?: LimitStatus, requestOptions?: IRequest.Options): Promise<TransferLimitListResponse> { |
| 162 | + const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits` |
| 163 | + .replace("{" + "id" + "}", encodeURIComponent(String(id))); |
| 164 | + const resource = new Resource(this, endpoint); |
| 165 | + |
| 166 | + const hasDefinedQueryParams = scope ?? transferType ?? status; |
| 167 | + if(hasDefinedQueryParams) { |
| 168 | + if(!requestOptions) requestOptions = {}; |
| 169 | + if(!requestOptions.params) requestOptions.params = {}; |
| 170 | + if(scope) requestOptions.params["scope"] = scope; |
| 171 | + if(transferType) requestOptions.params["transferType"] = transferType; |
| 172 | + if(status) requestOptions.params["status"] = status; |
| 173 | + } |
| 174 | + const response = await getJsonResponse<string, TransferLimitListResponse>( |
| 175 | + resource, |
| 176 | + "", |
| 177 | + { ...requestOptions, method: "GET" } |
| 178 | + ); |
| 179 | + |
| 180 | + return ObjectSerializer.deserialize(response, "TransferLimitListResponse"); |
| 181 | + } |
| 182 | + |
| 183 | +} |
0 commit comments