Skip to content

Commit

Permalink
Generated Xendit node SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
xendit-devx-bot committed Oct 18, 2023
1 parent b86bdd3 commit 9548310
Show file tree
Hide file tree
Showing 115 changed files with 1,259 additions and 806 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The official Xendit Node SDK provides a simple and convenient way to call Xendit's REST API
in applications written in Node.

* Package version: 3.3.0
* Package version: 3.4.0

# Getting Started

Expand Down Expand Up @@ -49,14 +49,14 @@ const xenditClient = new Xendit({
# Documentation

Find detailed API information and examples for each of our product’s by clicking the links below,
* [Refund](docs/Refund.md)
* [Invoice](docs/Invoice.md)
* [Payout](docs/Payout.md)
* [PaymentMethod](docs/PaymentMethod.md)
* [PaymentRequest](docs/PaymentRequest.md)
* [Customer](docs/Customer.md)
* [PaymentMethod](docs/PaymentMethod.md)
* [Refund](docs/Refund.md)
* [Transaction](docs/Transaction.md)
* [Balance](docs/Balance.md)
* [Customer](docs/Customer.md)
* [Payout](docs/Payout.md)


Further Reading
Expand Down
5 changes: 0 additions & 5 deletions balance_and_transaction/apis/Balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface GetBalanceRequest {
accountType?: GetBalanceAccountTypeEnum;
currency?: string;
forUserId?: string;
idempotencyKey?: string;
}

/**
Expand Down Expand Up @@ -67,10 +66,6 @@ export class BalanceApi extends runtime.BaseAPI {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

const response = await this.request({
path: `/balance`,
method: 'GET',
Expand Down
94 changes: 42 additions & 52 deletions balance_and_transaction/apis/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ import {
ValidationErrorToJSON,
} from '../models';

export interface GetTransactionByIDRequest {
id: string;
forUserId?: string;
}

export interface GetAllTransactionsRequest {
forUserId?: string;
types?: Array<TransactionTypes>;
Expand All @@ -55,13 +60,6 @@ export interface GetAllTransactionsRequest {
limit?: number;
afterId?: string;
beforeId?: string;
idempotencyKey?: string;
}

export interface GetTransactionByIDRequest {
id: string;
forUserId?: string;
idempotencyKey?: string;
}

/**
Expand All @@ -80,6 +78,43 @@ export class TransactionApi extends runtime.BaseAPI {
this.secretKey = secretKey;
}

/**
* Get single specific transaction by transaction id.
* Get a transaction based on its id
*/
private async getTransactionByIDRaw(requestParameters: GetTransactionByIDRequest): Promise<runtime.ApiResponse<TransactionResponse>> {
if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling getTransactionByID.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};
headerParameters["Authorization"] = "Basic " + btoa(this.secretKey + ":");

if (requestParameters.forUserId !== undefined && requestParameters.forUserId !== null) {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

const response = await this.request({
path: `/transactions/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
});

return new runtime.JSONApiResponse(response, (jsonValue) => TransactionResponseFromJSON(jsonValue));
}

/**
* Get single specific transaction by transaction id.
* Get a transaction based on its id
*/
async getTransactionByID(requestParameters: GetTransactionByIDRequest): Promise<TransactionResponse> {
const response = await this.getTransactionByIDRaw(requestParameters);
return await response.value();
}

/**
* Get a list of all transactions based on filter and search parameters.
* Get a list of transactions
Expand Down Expand Up @@ -146,10 +181,6 @@ export class TransactionApi extends runtime.BaseAPI {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

const response = await this.request({
path: `/transactions`,
method: 'GET',
Expand All @@ -169,45 +200,4 @@ export class TransactionApi extends runtime.BaseAPI {
return await response.value();
}

/**
* Get single specific transaction by transaction id.
* Get a transaction based on its id
*/
private async getTransactionByIDRaw(requestParameters: GetTransactionByIDRequest): Promise<runtime.ApiResponse<TransactionResponse>> {
if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling getTransactionByID.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};
headerParameters["Authorization"] = "Basic " + btoa(this.secretKey + ":");

if (requestParameters.forUserId !== undefined && requestParameters.forUserId !== null) {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

const response = await this.request({
path: `/transactions/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
});

return new runtime.JSONApiResponse(response, (jsonValue) => TransactionResponseFromJSON(jsonValue));
}

/**
* Get single specific transaction by transaction id.
* Get a transaction based on its id
*/
async getTransactionByID(requestParameters: GetTransactionByIDRequest): Promise<TransactionResponse> {
const response = await this.getTransactionByIDRaw(requestParameters);
return await response.value();
}

}
8 changes: 7 additions & 1 deletion balance_and_transaction/models/ChannelsCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const ChannelsCategories = {
VirtualAccount: 'VIRTUAL_ACCOUNT',
Xenplatform: 'XENPLATFORM',
DirectBankTransfer: 'DIRECT_BANK_TRANSFER',
Other: 'OTHER'
Other: 'OTHER',
XenditEnumDefaultFallback: "UNKNOWN_ENUM_VALUE"
} as const;
export type ChannelsCategories = typeof ChannelsCategories[keyof typeof ChannelsCategories];

Expand All @@ -35,6 +36,11 @@ export function ChannelsCategoriesFromJSON(json: any): ChannelsCategories {
}

export function ChannelsCategoriesFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChannelsCategories {
if (json !== "" || json !== null) {
const key = Object.keys(ChannelsCategories)[Object.values(ChannelsCategories).indexOf(json)]
return ChannelsCategories[key] === undefined ?
ChannelsCategories['XenditEnumDefaultFallback'] : ChannelsCategories[key]
}
return json as ChannelsCategories;
}

Expand Down
8 changes: 7 additions & 1 deletion balance_and_transaction/models/Currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ export const Currency = {
Yer: 'YER',
Zar: 'ZAR',
Zmw: 'ZMW',
Zwd: 'ZWD'
Zwd: 'ZWD',
XenditEnumDefaultFallback: "UNKNOWN_ENUM_VALUE"
} as const;
export type Currency = typeof Currency[keyof typeof Currency];

Expand All @@ -183,6 +184,11 @@ export function CurrencyFromJSON(json: any): Currency {
}

export function CurrencyFromJSONTyped(json: any, ignoreDiscriminator: boolean): Currency {
if (json !== "" || json !== null) {
const key = Object.keys(Currency)[Object.values(Currency).indexOf(json)]
return Currency[key] === undefined ?
Currency['XenditEnumDefaultFallback'] : Currency[key]
}
return json as Currency;
}

Expand Down
8 changes: 7 additions & 1 deletion balance_and_transaction/models/TransactionStatuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const TransactionStatuses = {
Pending: 'PENDING',
Failed: 'FAILED',
Reversed: 'REVERSED',
Voided: 'VOIDED'
Voided: 'VOIDED',
XenditEnumDefaultFallback: "UNKNOWN_ENUM_VALUE"
} as const;
export type TransactionStatuses = typeof TransactionStatuses[keyof typeof TransactionStatuses];

Expand All @@ -26,6 +27,11 @@ export function TransactionStatusesFromJSON(json: any): TransactionStatuses {
}

export function TransactionStatusesFromJSONTyped(json: any, ignoreDiscriminator: boolean): TransactionStatuses {
if (json !== "" || json !== null) {
const key = Object.keys(TransactionStatuses)[Object.values(TransactionStatuses).indexOf(json)]
return TransactionStatuses[key] === undefined ?
TransactionStatuses['XenditEnumDefaultFallback'] : TransactionStatuses[key]
}
return json as TransactionStatuses;
}

Expand Down
8 changes: 7 additions & 1 deletion balance_and_transaction/models/TransactionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const TransactionTypes = {
Cashback: 'CASHBACK',
Topup: 'TOPUP',
Withdrawal: 'WITHDRAWAL',
Other: 'OTHER'
Other: 'OTHER',
XenditEnumDefaultFallback: "UNKNOWN_ENUM_VALUE"
} as const;
export type TransactionTypes = typeof TransactionTypes[keyof typeof TransactionTypes];

Expand All @@ -34,6 +35,11 @@ export function TransactionTypesFromJSON(json: any): TransactionTypes {
}

export function TransactionTypesFromJSONTyped(json: any, ignoreDiscriminator: boolean): TransactionTypes {
if (json !== "" || json !== null) {
const key = Object.keys(TransactionTypes)[Object.values(TransactionTypes).indexOf(json)]
return TransactionTypes[key] === undefined ?
TransactionTypes['XenditEnumDefaultFallback'] : TransactionTypes[key]
}
return json as TransactionTypes;
}

Expand Down
26 changes: 3 additions & 23 deletions customer/apis/Customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,24 @@ import {
} from '../models';

export interface CreateCustomerRequest {
iDEMPOTENCYKEY?: string;
forUserId?: string;
idempotencyKey?: string;
forUserId?: string;
data?: CustomerRequest;
}

export interface GetCustomerRequest {
id: string;
forUserId?: string;
idempotencyKey?: string;
}

export interface GetCustomerByReferenceIDRequest {
referenceId: string;
forUserId?: string;
idempotencyKey?: string;
}

export interface UpdateCustomerRequest {
id: string;
forUserId?: string;
idempotencyKey?: string;
data?: PatchCustomer;
}

Expand Down Expand Up @@ -91,18 +87,14 @@ export class CustomerApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';

if (requestParameters.iDEMPOTENCYKEY !== undefined && requestParameters.iDEMPOTENCYKEY !== null) {
headerParameters['IDEMPOTENCY-KEY'] = String(requestParameters.iDEMPOTENCYKEY);
if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

if (requestParameters.forUserId !== undefined && requestParameters.forUserId !== null) {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

const response = await this.request({
path: `/customers`,
method: 'POST',
Expand Down Expand Up @@ -141,10 +133,6 @@ export class CustomerApi extends runtime.BaseAPI {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

const response = await this.request({
path: `/customers/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'GET',
Expand Down Expand Up @@ -186,10 +174,6 @@ export class CustomerApi extends runtime.BaseAPI {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

const response = await this.request({
path: `/customers`,
method: 'GET',
Expand Down Expand Up @@ -229,10 +213,6 @@ export class CustomerApi extends runtime.BaseAPI {
headerParameters['for-user-id'] = String(requestParameters.forUserId);
}

if (requestParameters.idempotencyKey !== undefined && requestParameters.idempotencyKey !== null) {
headerParameters['idempotency-key'] = String(requestParameters.idempotencyKey);
}

const response = await this.request({
path: `/customers/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'PATCH',
Expand Down
8 changes: 7 additions & 1 deletion customer/models/AddressStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*/
export const AddressStatus = {
Active: 'ACTIVE',
Deleted: 'DELETED'
Deleted: 'DELETED',
XenditEnumDefaultFallback: "UNKNOWN_ENUM_VALUE"
} as const;
export type AddressStatus = typeof AddressStatus[keyof typeof AddressStatus];

Expand All @@ -23,6 +24,11 @@ export function AddressStatusFromJSON(json: any): AddressStatus {
}

export function AddressStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): AddressStatus {
if (json !== "" || json !== null) {
const key = Object.keys(AddressStatus)[Object.values(AddressStatus).indexOf(json)]
return AddressStatus[key] === undefined ?
AddressStatus['XenditEnumDefaultFallback'] : AddressStatus[key]
}
return json as AddressStatus;
}

Expand Down
8 changes: 7 additions & 1 deletion customer/models/EndCustomerStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const EndCustomerStatus = {
Inactive: 'INACTIVE',
Pending: 'PENDING',
Blocked: 'BLOCKED',
Deleted: 'DELETED'
Deleted: 'DELETED',
XenditEnumDefaultFallback: "UNKNOWN_ENUM_VALUE"
} as const;
export type EndCustomerStatus = typeof EndCustomerStatus[keyof typeof EndCustomerStatus];

Expand All @@ -26,6 +27,11 @@ export function EndCustomerStatusFromJSON(json: any): EndCustomerStatus {
}

export function EndCustomerStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): EndCustomerStatus {
if (json !== "" || json !== null) {
const key = Object.keys(EndCustomerStatus)[Object.values(EndCustomerStatus).indexOf(json)]
return EndCustomerStatus[key] === undefined ?
EndCustomerStatus['XenditEnumDefaultFallback'] : EndCustomerStatus[key]
}
return json as EndCustomerStatus;
}

Expand Down
Loading

0 comments on commit 9548310

Please sign in to comment.