@adyen/api-library
Version:
The Adyen API Library for NodeJS enables you to work with Adyen APIs.
122 lines • 6.38 kB
JavaScript
;
/*
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GrantsApi = void 0;
const getJsonResponse_1 = __importDefault(require("../../helpers/getJsonResponse"));
const service_1 = __importDefault(require("../../service"));
const resource_1 = __importDefault(require("../resource"));
const objectSerializer_1 = require("../../typings/capital/objectSerializer");
/**
* API handler for GrantsApi
*/
class GrantsApi extends service_1.default {
constructor(client) {
super(client);
this.API_BASEPATH = "https://balanceplatform-api-test.adyen.com/capital/v1";
this.baseUrl = this.createBaseUrl(this.API_BASEPATH);
}
/**
* @summary Get all the disbursements of a grant
* @param grantId {@link string } The unique identifier of the grant reference.
* @param requestOptions {@link IRequest.Options }
* @return {@link Disbursements }
*/
async getAllGrantDisbursements(grantId, requestOptions) {
const endpoint = `${this.baseUrl}/grants/{grantId}/disbursements`
.replace("{" + "grantId" + "}", encodeURIComponent(String(grantId)));
const resource = new resource_1.default(this, endpoint);
const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "Disbursements");
}
/**
* @summary Get all the grants of an account holder
* @param requestOptions {@link IRequest.Options }
* @param counterpartyAccountHolderId {@link string } (Required) The unique identifier of the account holder that received the grants.
* @return {@link Grants }
*/
async getAllGrants(counterpartyAccountHolderId, requestOptions) {
const endpoint = `${this.baseUrl}/grants`;
const resource = new resource_1.default(this, endpoint);
const hasDefinedQueryParams = counterpartyAccountHolderId;
if (hasDefinedQueryParams) {
if (!requestOptions)
requestOptions = {};
if (!requestOptions.params)
requestOptions.params = {};
if (counterpartyAccountHolderId)
requestOptions.params["counterpartyAccountHolderId"] = counterpartyAccountHolderId;
}
const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "Grants");
}
/**
* @summary Get the details of a grant
* @param grantId {@link string } The unique identifier of the grant reference.
* @param requestOptions {@link IRequest.Options }
* @return {@link Grant }
*/
async getGrant(grantId, requestOptions) {
const endpoint = `${this.baseUrl}/grants/{grantId}`
.replace("{" + "grantId" + "}", encodeURIComponent(String(grantId)));
const resource = new resource_1.default(this, endpoint);
const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "Grant");
}
/**
* @summary Get disbursement details
* @param grantId {@link string } The unique identifier of the grant reference.
* @param disbursementId {@link string } The unique identifier of the disbursement.
* @param requestOptions {@link IRequest.Options }
* @return {@link Disbursement }
*/
async getGrantDisbursement(grantId, disbursementId, requestOptions) {
const endpoint = `${this.baseUrl}/grants/{grantId}/disbursements/{disbursementId}`
.replace("{" + "grantId" + "}", encodeURIComponent(String(grantId)))
.replace("{" + "disbursementId" + "}", encodeURIComponent(String(disbursementId)));
const resource = new resource_1.default(this, endpoint);
const response = await (0, getJsonResponse_1.default)(resource, "", { ...requestOptions, method: "GET" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "Disbursement");
}
/**
* @summary Make a request for a grant
* @param grantInfo {@link GrantInfo }
* @param requestOptions {@link IRequest.Options }
* @return {@link Grant }
*/
async requestGrant(grantInfo, requestOptions) {
const endpoint = `${this.baseUrl}/grants`;
const resource = new resource_1.default(this, endpoint);
const request = objectSerializer_1.ObjectSerializer.serialize(grantInfo, "GrantInfo");
const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "POST" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "Grant");
}
/**
* @summary Update the repayment configuration of a disbursement
* @param grantId {@link string } The unique identifier of the grant reference.
* @param disbursementId {@link string } The unique identifier of the disbursement.
* @param disbursementInfoUpdate {@link DisbursementInfoUpdate }
* @param requestOptions {@link IRequest.Options }
* @return {@link Disbursement }
*/
async updateGrantDisbursement(grantId, disbursementId, disbursementInfoUpdate, requestOptions) {
const endpoint = `${this.baseUrl}/grants/{grantId}/disbursements/{disbursementId}`
.replace("{" + "grantId" + "}", encodeURIComponent(String(grantId)))
.replace("{" + "disbursementId" + "}", encodeURIComponent(String(disbursementId)));
const resource = new resource_1.default(this, endpoint);
const request = objectSerializer_1.ObjectSerializer.serialize(disbursementInfoUpdate, "DisbursementInfoUpdate");
const response = await (0, getJsonResponse_1.default)(resource, request, { ...requestOptions, method: "PATCH" });
return objectSerializer_1.ObjectSerializer.deserialize(response, "Disbursement");
}
}
exports.GrantsApi = GrantsApi;
//# sourceMappingURL=grantsApi.js.map