Skip to content

Commit

Permalink
Generated Xendit go SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
xendit-devx-bot committed Oct 18, 2023
1 parent d6ef2b4 commit 14a8786
Show file tree
Hide file tree
Showing 179 changed files with 2,734 additions and 1,676 deletions.
4 changes: 2 additions & 2 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ docs/refund/CreateRefund403Response.md
docs/refund/CreateRefund404Response.md
docs/refund/CreateRefund409Response.md
docs/refund/CreateRefund503Response.md
docs/refund/CreateRefundDefaultResponse.md
docs/refund/GetAllRefundsDefaultResponse.md
docs/refund/Refund.md
docs/refund/RefundList.md
go.mod
Expand All @@ -27,7 +27,7 @@ refund/model_create_refund_403_response.go
refund/model_create_refund_404_response.go
refund/model_create_refund_409_response.go
refund/model_create_refund_503_response.go
refund/model_create_refund_default_response.go
refund/model_get_all_refunds_default_response.go
refund/model_refund.go
refund/model_refund_list.go
refund/nullable.go
Expand Down
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 Go SDK provides a simple and convenient way to call Xendit's REST API
in applications written in Go.

* Package version: 3.3.0
* Package version: 3.4.0

# Getting Started

Expand Down Expand Up @@ -42,14 +42,14 @@ xnd := xendit.NewClient("API-KEY")

Find detailed API information and examples for each of our product's by clicking the links below,

* [Balance](docs/BalanceApi.md)
* [Customer](docs/CustomerApi.md)
* [Invoice](docs/InvoiceApi.md)
* [PaymentMethod](docs/PaymentMethodApi.md)
* [PaymentRequest](docs/PaymentRequestApi.md)
* [Payout](docs/PayoutApi.md)
* [PaymentMethod](docs/PaymentMethodApi.md)
* [Refund](docs/RefundApi.md)
* [Balance](docs/BalanceApi.md)
* [Transaction](docs/TransactionApi.md)
* [Customer](docs/CustomerApi.md)
* [Payout](docs/PayoutApi.md)

All URIs are relative to *https://api.xendit.co*. For more information about our API, please refer to *https://developers.xendit.co/*.

Expand Down
224 changes: 112 additions & 112 deletions balance_and_transaction/api_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ import (

type TransactionApi interface {

/*
GetAllTransactions Get a list of transactions
Get a list of all transactions based on filter and search parameters.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiGetAllTransactionsRequest
*/
GetAllTransactions(ctx context.Context) ApiGetAllTransactionsRequest

// GetAllTransactionsExecute executes the request
// @return TransactionsResponse
GetAllTransactionsExecute(r ApiGetAllTransactionsRequest) (*TransactionsResponse, *http.Response, *common.XenditSdkError)

/*
GetTransactionByID Get a transaction based on its id
Expand All @@ -45,6 +31,20 @@ type TransactionApi interface {
// GetTransactionByIDExecute executes the request
// @return TransactionResponse
GetTransactionByIDExecute(r ApiGetTransactionByIDRequest) (*TransactionResponse, *http.Response, *common.XenditSdkError)

/*
GetAllTransactions Get a list of transactions
Get a list of all transactions based on filter and search parameters.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiGetAllTransactionsRequest
*/
GetAllTransactions(ctx context.Context) ApiGetAllTransactionsRequest

// GetAllTransactionsExecute executes the request
// @return TransactionsResponse
GetAllTransactionsExecute(r ApiGetAllTransactionsRequest) (*TransactionsResponse, *http.Response, *common.XenditSdkError)
}

// TransactionApiService TransactionApi service
Expand All @@ -60,6 +60,104 @@ func NewTransactionApi (client common.IClient) TransactionApi {
}


type ApiGetTransactionByIDRequest struct {
ctx context.Context
ApiService TransactionApi
id string
forUserId *string
}

// The sub-account user-id that you want to make this transaction for. This header is only used if you have access to xenPlatform. See xenPlatform for more information
func (r ApiGetTransactionByIDRequest) ForUserId(forUserId string) ApiGetTransactionByIDRequest {
r.forUserId = &forUserId
return r
}

func (r ApiGetTransactionByIDRequest) Execute() (*TransactionResponse, *http.Response, *common.XenditSdkError) {
return r.ApiService.GetTransactionByIDExecute(r)
}

/*
GetTransactionByID Get a transaction based on its id
Get single specific transaction by transaction id.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return ApiGetTransactionByIDRequest
*/
func (a *TransactionApiService) GetTransactionByID(ctx context.Context, id string) ApiGetTransactionByIDRequest {
return ApiGetTransactionByIDRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}

// Execute executes the request
// @return TransactionResponse
func (a *TransactionApiService) GetTransactionByIDExecute(r ApiGetTransactionByIDRequest) (*TransactionResponse, *http.Response, *common.XenditSdkError) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []common.FormFile
localVarReturnValue *TransactionResponse
)

localBasePath, err := a.client.GetConfig().ServerURLWithContext(r.ctx, "TransactionApiService.GetTransactionByID")
if err != nil {
return localVarReturnValue, nil, common.NewXenditSdkError(nil, "", "Error creating HTTP request: TransactionApiService.GetTransactionByIDExecute")
}

localVarPath := localBasePath + "/transactions/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(utils.ParameterValueToString(r.id, "id")), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHTTPContentTypes := []string{}

// set Content-Type header
localVarHTTPContentType := utils.SelectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}

// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}

// set Accept header
localVarHTTPHeaderAccept := utils.SelectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.forUserId != nil {
utils.ParameterAddToHeaderOrQuery(localVarHeaderParams, "for-user-id", r.forUserId, "")
}
req, err := a.client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, common.NewXenditSdkError(nil, "", "Error creating HTTP request: TransactionApiService.GetTransactionByIDExecute")
}

localVarHTTPResponse, err := a.client.CallAPI(req)

localVarBody, _ := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))

err = a.client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))

if err != nil || localVarHTTPResponse.StatusCode < 200 || localVarHTTPResponse.StatusCode >= 300 {
xenditSdkError := common.NewXenditSdkError(&localVarBody, strconv.Itoa(localVarHTTPResponse.StatusCode), localVarHTTPResponse.Status)

return localVarReturnValue, localVarHTTPResponse, xenditSdkError
}

return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiGetAllTransactionsRequest struct {
ctx context.Context
ApiService TransactionApi
Expand Down Expand Up @@ -304,101 +402,3 @@ func (a *TransactionApiService) GetAllTransactionsExecute(r ApiGetAllTransaction

return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiGetTransactionByIDRequest struct {
ctx context.Context
ApiService TransactionApi
id string
forUserId *string
}

// The sub-account user-id that you want to make this transaction for. This header is only used if you have access to xenPlatform. See xenPlatform for more information
func (r ApiGetTransactionByIDRequest) ForUserId(forUserId string) ApiGetTransactionByIDRequest {
r.forUserId = &forUserId
return r
}

func (r ApiGetTransactionByIDRequest) Execute() (*TransactionResponse, *http.Response, *common.XenditSdkError) {
return r.ApiService.GetTransactionByIDExecute(r)
}

/*
GetTransactionByID Get a transaction based on its id
Get single specific transaction by transaction id.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return ApiGetTransactionByIDRequest
*/
func (a *TransactionApiService) GetTransactionByID(ctx context.Context, id string) ApiGetTransactionByIDRequest {
return ApiGetTransactionByIDRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}

// Execute executes the request
// @return TransactionResponse
func (a *TransactionApiService) GetTransactionByIDExecute(r ApiGetTransactionByIDRequest) (*TransactionResponse, *http.Response, *common.XenditSdkError) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []common.FormFile
localVarReturnValue *TransactionResponse
)

localBasePath, err := a.client.GetConfig().ServerURLWithContext(r.ctx, "TransactionApiService.GetTransactionByID")
if err != nil {
return localVarReturnValue, nil, common.NewXenditSdkError(nil, "", "Error creating HTTP request: TransactionApiService.GetTransactionByIDExecute")
}

localVarPath := localBasePath + "/transactions/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(utils.ParameterValueToString(r.id, "id")), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHTTPContentTypes := []string{}

// set Content-Type header
localVarHTTPContentType := utils.SelectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}

// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}

// set Accept header
localVarHTTPHeaderAccept := utils.SelectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.forUserId != nil {
utils.ParameterAddToHeaderOrQuery(localVarHeaderParams, "for-user-id", r.forUserId, "")
}
req, err := a.client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, common.NewXenditSdkError(nil, "", "Error creating HTTP request: TransactionApiService.GetTransactionByIDExecute")
}

localVarHTTPResponse, err := a.client.CallAPI(req)

localVarBody, _ := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))

err = a.client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))

if err != nil || localVarHTTPResponse.StatusCode < 200 || localVarHTTPResponse.StatusCode >= 300 {
xenditSdkError := common.NewXenditSdkError(&localVarBody, strconv.Itoa(localVarHTTPResponse.StatusCode), localVarHTTPResponse.Status)

return localVarReturnValue, localVarHTTPResponse, xenditSdkError
}

return localVarReturnValue, localVarHTTPResponse, nil
}
5 changes: 4 additions & 1 deletion balance_and_transaction/model_channels_categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
CHANNELSCATEGORIES_XENPLATFORM ChannelsCategories = "XENPLATFORM"
CHANNELSCATEGORIES_DIRECT_BANK_TRANSFER ChannelsCategories = "DIRECT_BANK_TRANSFER"
CHANNELSCATEGORIES_OTHER ChannelsCategories = "OTHER"
CHANNELSCATEGORIES_XENDIT_ENUM_DEFAULT_FALLBACK ChannelsCategories = "UNKNOWN_ENUM_VALUE"
)

// All allowed values of ChannelsCategories enum
Expand All @@ -52,6 +53,7 @@ var AllowedChannelsCategoriesEnumValues = []ChannelsCategories{
"XENPLATFORM",
"DIRECT_BANK_TRANSFER",
"OTHER",
"UNKNOWN_ENUM_VALUE",
}

func (v *ChannelsCategories) UnmarshalJSON(src []byte) error {
Expand All @@ -68,7 +70,8 @@ func (v *ChannelsCategories) UnmarshalJSON(src []byte) error {
}
}

return fmt.Errorf("%+v is not a valid ChannelsCategories", value)
*v = CHANNELSCATEGORIES_XENDIT_ENUM_DEFAULT_FALLBACK
return nil
}

// NewChannelsCategoriesFromValue returns a pointer to a valid ChannelsCategories
Expand Down
5 changes: 4 additions & 1 deletion balance_and_transaction/model_currency.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ const (
CURRENCY_ZAR Currency = "ZAR"
CURRENCY_ZMW Currency = "ZMW"
CURRENCY_ZWD Currency = "ZWD"
CURRENCY_XENDIT_ENUM_DEFAULT_FALLBACK Currency = "UNKNOWN_ENUM_VALUE"
)

// All allowed values of Currency enum
Expand Down Expand Up @@ -348,6 +349,7 @@ var AllowedCurrencyEnumValues = []Currency{
"ZAR",
"ZMW",
"ZWD",
"UNKNOWN_ENUM_VALUE",
}

func (v *Currency) UnmarshalJSON(src []byte) error {
Expand All @@ -364,7 +366,8 @@ func (v *Currency) UnmarshalJSON(src []byte) error {
}
}

return fmt.Errorf("%+v is not a valid Currency", value)
*v = CURRENCY_XENDIT_ENUM_DEFAULT_FALLBACK
return nil
}

// NewCurrencyFromValue returns a pointer to a valid Currency
Expand Down
5 changes: 4 additions & 1 deletion balance_and_transaction/model_transaction_statuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
TRANSACTIONSTATUSES_FAILED TransactionStatuses = "FAILED"
TRANSACTIONSTATUSES_REVERSED TransactionStatuses = "REVERSED"
TRANSACTIONSTATUSES_VOIDED TransactionStatuses = "VOIDED"
TRANSACTIONSTATUSES_XENDIT_ENUM_DEFAULT_FALLBACK TransactionStatuses = "UNKNOWN_ENUM_VALUE"
)

// All allowed values of TransactionStatuses enum
Expand All @@ -34,6 +35,7 @@ var AllowedTransactionStatusesEnumValues = []TransactionStatuses{
"FAILED",
"REVERSED",
"VOIDED",
"UNKNOWN_ENUM_VALUE",
}

func (v *TransactionStatuses) UnmarshalJSON(src []byte) error {
Expand All @@ -50,7 +52,8 @@ func (v *TransactionStatuses) UnmarshalJSON(src []byte) error {
}
}

return fmt.Errorf("%+v is not a valid TransactionStatuses", value)
*v = TRANSACTIONSTATUSES_XENDIT_ENUM_DEFAULT_FALLBACK
return nil
}

// NewTransactionStatusesFromValue returns a pointer to a valid TransactionStatuses
Expand Down
5 changes: 4 additions & 1 deletion balance_and_transaction/model_transaction_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
TRANSACTIONTYPES_TOPUP TransactionTypes = "TOPUP"
TRANSACTIONTYPES_WITHDRAWAL TransactionTypes = "WITHDRAWAL"
TRANSACTIONTYPES_OTHER TransactionTypes = "OTHER"
TRANSACTIONTYPES_XENDIT_ENUM_DEFAULT_FALLBACK TransactionTypes = "UNKNOWN_ENUM_VALUE"
)

// All allowed values of TransactionTypes enum
Expand All @@ -50,6 +51,7 @@ var AllowedTransactionTypesEnumValues = []TransactionTypes{
"TOPUP",
"WITHDRAWAL",
"OTHER",
"UNKNOWN_ENUM_VALUE",
}

func (v *TransactionTypes) UnmarshalJSON(src []byte) error {
Expand All @@ -66,7 +68,8 @@ func (v *TransactionTypes) UnmarshalJSON(src []byte) error {
}
}

return fmt.Errorf("%+v is not a valid TransactionTypes", value)
*v = TRANSACTIONTYPES_XENDIT_ENUM_DEFAULT_FALLBACK
return nil
}

// NewTransactionTypesFromValue returns a pointer to a valid TransactionTypes
Expand Down
Loading

0 comments on commit 14a8786

Please sign in to comment.