|
| 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 | + |
| 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/capital/objectSerializer"; |
| 18 | +import { Disbursement } from "../../typings/capital/models"; |
| 19 | +import { DisbursementInfoUpdate } from "../../typings/capital/models"; |
| 20 | +import { Disbursements } from "../../typings/capital/models"; |
| 21 | +import { Grant } from "../../typings/capital/models"; |
| 22 | +import { GrantInfo } from "../../typings/capital/models"; |
| 23 | +import { Grants } from "../../typings/capital/models"; |
| 24 | + |
| 25 | +/** |
| 26 | + * API handler for GrantsApi |
| 27 | + */ |
| 28 | +export class GrantsApi extends Service { |
| 29 | + |
| 30 | + private readonly API_BASEPATH: string = "https://balanceplatform-api-test.adyen.com/capital/v1"; |
| 31 | + private baseUrl: string; |
| 32 | + |
| 33 | + public constructor(client: Client){ |
| 34 | + super(client); |
| 35 | + this.baseUrl = this.createBaseUrl(this.API_BASEPATH); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @summary Get all the disbursements of a grant |
| 40 | + * @param grantId {@link string } The unique identifier of the grant reference. |
| 41 | + * @param requestOptions {@link IRequest.Options } |
| 42 | + * @return {@link Disbursements } |
| 43 | + */ |
| 44 | + public async getAllGrantDisbursements(grantId: string, requestOptions?: IRequest.Options): Promise<Disbursements> { |
| 45 | + const endpoint = `${this.baseUrl}/grants/{grantId}/disbursements` |
| 46 | + .replace("{" + "grantId" + "}", encodeURIComponent(String(grantId))); |
| 47 | + const resource = new Resource(this, endpoint); |
| 48 | + |
| 49 | + const response = await getJsonResponse<string, Disbursements>( |
| 50 | + resource, |
| 51 | + "", |
| 52 | + { ...requestOptions, method: "GET" } |
| 53 | + ); |
| 54 | + |
| 55 | + return ObjectSerializer.deserialize(response, "Disbursements"); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @summary Get all the grants of an account holder |
| 60 | + * @param requestOptions {@link IRequest.Options } |
| 61 | + * @param counterpartyAccountHolderId {@link string } (Required) The unique identifier of the account holder that received the grants. |
| 62 | + * @return {@link Grants } |
| 63 | + */ |
| 64 | + public async getAllGrants(counterpartyAccountHolderId: string, requestOptions?: IRequest.Options): Promise<Grants> { |
| 65 | + const endpoint = `${this.baseUrl}/grants`; |
| 66 | + const resource = new Resource(this, endpoint); |
| 67 | + |
| 68 | + const hasDefinedQueryParams = counterpartyAccountHolderId; |
| 69 | + if(hasDefinedQueryParams) { |
| 70 | + if(!requestOptions) requestOptions = {}; |
| 71 | + if(!requestOptions.params) requestOptions.params = {}; |
| 72 | + if(counterpartyAccountHolderId) requestOptions.params["counterpartyAccountHolderId"] = counterpartyAccountHolderId; |
| 73 | + } |
| 74 | + const response = await getJsonResponse<string, Grants>( |
| 75 | + resource, |
| 76 | + "", |
| 77 | + { ...requestOptions, method: "GET" } |
| 78 | + ); |
| 79 | + |
| 80 | + return ObjectSerializer.deserialize(response, "Grants"); |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * @summary Get the details of a grant |
| 85 | + * @param grantId {@link string } The unique identifier of the grant reference. |
| 86 | + * @param requestOptions {@link IRequest.Options } |
| 87 | + * @return {@link Grant } |
| 88 | + */ |
| 89 | + public async getGrant(grantId: string, requestOptions?: IRequest.Options): Promise<Grant> { |
| 90 | + const endpoint = `${this.baseUrl}/grants/{grantId}` |
| 91 | + .replace("{" + "grantId" + "}", encodeURIComponent(String(grantId))); |
| 92 | + const resource = new Resource(this, endpoint); |
| 93 | + |
| 94 | + const response = await getJsonResponse<string, Grant>( |
| 95 | + resource, |
| 96 | + "", |
| 97 | + { ...requestOptions, method: "GET" } |
| 98 | + ); |
| 99 | + |
| 100 | + return ObjectSerializer.deserialize(response, "Grant"); |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * @summary Get disbursement details |
| 105 | + * @param grantId {@link string } The unique identifier of the grant reference. |
| 106 | + * @param disbursementId {@link string } The unique identifier of the disbursement. |
| 107 | + * @param requestOptions {@link IRequest.Options } |
| 108 | + * @return {@link Disbursement } |
| 109 | + */ |
| 110 | + public async getGrantDisbursement(grantId: string, disbursementId: string, requestOptions?: IRequest.Options): Promise<Disbursement> { |
| 111 | + const endpoint = `${this.baseUrl}/grants/{grantId}/disbursements/{disbursementId}` |
| 112 | + .replace("{" + "grantId" + "}", encodeURIComponent(String(grantId))) |
| 113 | + .replace("{" + "disbursementId" + "}", encodeURIComponent(String(disbursementId))); |
| 114 | + const resource = new Resource(this, endpoint); |
| 115 | + |
| 116 | + const response = await getJsonResponse<string, Disbursement>( |
| 117 | + resource, |
| 118 | + "", |
| 119 | + { ...requestOptions, method: "GET" } |
| 120 | + ); |
| 121 | + |
| 122 | + return ObjectSerializer.deserialize(response, "Disbursement"); |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * @summary Make a request for a grant |
| 127 | + * @param grantInfo {@link GrantInfo } |
| 128 | + * @param requestOptions {@link IRequest.Options } |
| 129 | + * @return {@link Grant } |
| 130 | + */ |
| 131 | + public async requestGrant(grantInfo: GrantInfo, requestOptions?: IRequest.Options): Promise<Grant> { |
| 132 | + const endpoint = `${this.baseUrl}/grants`; |
| 133 | + const resource = new Resource(this, endpoint); |
| 134 | + |
| 135 | + const request: GrantInfo = ObjectSerializer.serialize(grantInfo, "GrantInfo"); |
| 136 | + const response = await getJsonResponse<GrantInfo, Grant>( |
| 137 | + resource, |
| 138 | + request, |
| 139 | + { ...requestOptions, method: "POST" } |
| 140 | + ); |
| 141 | + |
| 142 | + return ObjectSerializer.deserialize(response, "Grant"); |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * @summary Update the repayment configuration of a disbursement |
| 147 | + * @param grantId {@link string } The unique identifier of the grant reference. |
| 148 | + * @param disbursementId {@link string } The unique identifier of the disbursement. |
| 149 | + * @param disbursementInfoUpdate {@link DisbursementInfoUpdate } |
| 150 | + * @param requestOptions {@link IRequest.Options } |
| 151 | + * @return {@link Disbursement } |
| 152 | + */ |
| 153 | + public async updateGrantDisbursement(grantId: string, disbursementId: string, disbursementInfoUpdate: DisbursementInfoUpdate, requestOptions?: IRequest.Options): Promise<Disbursement> { |
| 154 | + const endpoint = `${this.baseUrl}/grants/{grantId}/disbursements/{disbursementId}` |
| 155 | + .replace("{" + "grantId" + "}", encodeURIComponent(String(grantId))) |
| 156 | + .replace("{" + "disbursementId" + "}", encodeURIComponent(String(disbursementId))); |
| 157 | + const resource = new Resource(this, endpoint); |
| 158 | + |
| 159 | + const request: DisbursementInfoUpdate = ObjectSerializer.serialize(disbursementInfoUpdate, "DisbursementInfoUpdate"); |
| 160 | + const response = await getJsonResponse<DisbursementInfoUpdate, Disbursement>( |
| 161 | + resource, |
| 162 | + request, |
| 163 | + { ...requestOptions, method: "PATCH" } |
| 164 | + ); |
| 165 | + |
| 166 | + return ObjectSerializer.deserialize(response, "Disbursement"); |
| 167 | + } |
| 168 | + |
| 169 | +} |
0 commit comments