From bf7ea8b5f35843c8fe2ea60c6e2f44fee0750242 Mon Sep 17 00:00:00 2001 From: Michael Paul Date: Wed, 14 Jun 2023 15:29:11 +0200 Subject: [PATCH] ITT-593: Implement RestServiceError for other services (#218) * ITT-593: Unify templates * ITT-593: Balance platform error handling * ITT-593: Transfers error handling --- Makefile | 7 +- src/balanceplatform/api_account_holders.go | 190 +++++++ src/balanceplatform/api_balance_accounts.go | 425 ++++++++++++++++ .../api_bank_account_validation.go | 40 ++ src/balanceplatform/api_grant_accounts.go | 49 ++ src/balanceplatform/api_grant_offers.go | 96 ++++ .../api_payment_instrument_groups.go | 143 ++++++ .../api_payment_instruments.go | 237 +++++++++ src/balanceplatform/api_platform.go | 96 ++++ src/balanceplatform/api_transaction_rules.go | 190 +++++++ src/balanceplatform/model_account_holder.go | 37 ++ .../model_account_holder_capability.go | 28 +- .../model_account_holder_info.go | 37 ++ src/balanceplatform/model_balance_account.go | 37 ++ .../model_balance_account_base.go | 37 ++ .../model_balance_account_info.go | 37 ++ .../model_balance_account_update_request.go | 37 ++ .../model_capability_settings.go | 282 +++++++++++ .../model_cron_sweep_schedule.go | 2 +- ...address_2.go => model_delivery_address.go} | 98 ++-- src/balanceplatform/model_delivery_contact.go | 12 +- .../model_payment_instrument.go | 4 +- .../model_payment_instrument_info.go | 4 +- ...model_payment_instrument_update_request.go | 2 +- src/balanceplatform/model_sweep_schedule.go | 2 +- .../model_update_payment_instrument.go | 4 +- src/management/api_account_company_level.go | 8 +- src/transfers/api_transactions.go | 78 +++ src/transfers/api_transfers.go | 40 ++ src/transfers/model_transfer.go | 2 +- src/transfers/model_transfer_info.go | 2 +- templates/custom/api.mustache | 41 ++ templates/rest/api.mustache | 155 ------ templates/rest/client.mustache | 42 -- templates/rest/model.mustache | 21 - templates/rest/model_oneof.mustache | 144 ------ templates/rest/model_simple.mustache | 466 ------------------ templates/rest/partial_header.mustache | 11 - tests/balanceplatform_test.go | 15 +- tests/transfers_test.go | 5 + 40 files changed, 2231 insertions(+), 932 deletions(-) create mode 100644 src/balanceplatform/model_capability_settings.go rename src/balanceplatform/{model_address_2.go => model_delivery_address.go} (72%) delete mode 100644 templates/rest/api.mustache delete mode 100644 templates/rest/client.mustache delete mode 100644 templates/rest/model.mustache delete mode 100644 templates/rest/model_oneof.mustache delete mode 100644 templates/rest/model_simple.mustache delete mode 100644 templates/rest/partial_header.mustache diff --git a/Makefile b/Makefile index e8ab4b7f0..f5b5ec419 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ models: $(services) balanceplatform: spec=BalancePlatformService-v2 balanceplatform: serviceName=BalancePlatform +balanceplatform: hasRestServiceError=true configurationwebhook: spec=BalancePlatformConfigurationNotification-v1 reportwebhook: spec=BalancePlatformReportNotification-v1 transferwebhook: spec=BalancePlatformTransferNotification-v3 @@ -45,9 +46,10 @@ storedvalue: spec=StoredValueService-v46 storedvalue: serviceName=StoredValue transfers: spec=TransferService-v3 transfers: serviceName=Transfers +transfers: hasRestServiceError=true management: spec=ManagementService-v1 management: serviceName=Management -management: templates=templates/rest +management: hasRestServiceError=true posterminalmanagement: spec=TfmAPIService-v1 posterminalmanagement: serviceName=PosTerminalManagementApi @@ -68,7 +70,8 @@ $(services): schema $(openapi-generator-jar) $(goimports) --skip-validate-spec \ --enable-post-process-file \ --inline-schema-name-mappings PaymentDonationRequest_paymentMethod=CheckoutPaymentMethod \ - --additional-properties=serviceName=$(serviceName) + --additional-properties=serviceName=$(serviceName) \ + --additional-properties=$(if $(hasRestServiceError),hasRestServiceError=true) rm -rf $(output)/$(@)/go.{mod,sum} rm -rf $(output)/$(@)/.openapi-generator/FILES diff --git a/src/balanceplatform/api_account_holders.go b/src/balanceplatform/api_account_holders.go index 30bf3f85f..5f1db2559 100644 --- a/src/balanceplatform/api_account_holders.go +++ b/src/balanceplatform/api_account_holders.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -66,6 +68,53 @@ func (a *AccountHoldersApi) CreateAccountHolder(ctx context.Context, r AccountHo headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -111,6 +160,53 @@ func (a *AccountHoldersApi) GetAccountHolder(ctx context.Context, r AccountHolde headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -178,6 +274,53 @@ func (a *AccountHoldersApi) GetAllBalanceAccountsOfAccountHolder(ctx context.Con headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -229,5 +372,52 @@ func (a *AccountHoldersApi) UpdateAccountHolder(ctx context.Context, r AccountHo headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_balance_accounts.go b/src/balanceplatform/api_balance_accounts.go index faebfcf86..43d21cc80 100644 --- a/src/balanceplatform/api_balance_accounts.go +++ b/src/balanceplatform/api_balance_accounts.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -64,6 +66,53 @@ func (a *BalanceAccountsApi) CreateBalanceAccount(ctx context.Context, r Balance headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -117,6 +166,53 @@ func (a *BalanceAccountsApi) CreateSweep(ctx context.Context, r BalanceAccountsA headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -165,6 +261,53 @@ func (a *BalanceAccountsApi) DeleteSweep(ctx context.Context, r BalanceAccountsA headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return httpRes, decodeError + } + return httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return httpRes, decodeError + } + return httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return httpRes, decodeError + } + return httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return httpRes, decodeError + } + return httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return httpRes, decodeError + } + return httpRes, serviceError + } + return httpRes, err } @@ -232,6 +375,53 @@ func (a *BalanceAccountsApi) GetAllPaymentInstrumentsForBalanceAccount(ctx conte headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -299,6 +489,53 @@ func (a *BalanceAccountsApi) GetAllSweepsForBalanceAccount(ctx context.Context, headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -344,6 +581,53 @@ func (a *BalanceAccountsApi) GetBalanceAccount(ctx context.Context, r BalanceAcc headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -392,6 +676,53 @@ func (a *BalanceAccountsApi) GetSweep(ctx context.Context, r BalanceAccountsApiG headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -443,6 +774,53 @@ func (a *BalanceAccountsApi) UpdateBalanceAccount(ctx context.Context, r Balance headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -497,5 +875,52 @@ func (a *BalanceAccountsApi) UpdateSweep(ctx context.Context, r BalanceAccountsA headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_bank_account_validation.go b/src/balanceplatform/api_bank_account_validation.go index 2c4ce5fc3..ac57aa187 100644 --- a/src/balanceplatform/api_bank_account_validation.go +++ b/src/balanceplatform/api_bank_account_validation.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" @@ -63,5 +65,43 @@ func (a *BankAccountValidationApi) ValidateBankAccountIdentification(ctx context headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_grant_accounts.go b/src/balanceplatform/api_grant_accounts.go index d2ea4fc92..7d71304d3 100644 --- a/src/balanceplatform/api_grant_accounts.go +++ b/src/balanceplatform/api_grant_accounts.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -62,5 +64,52 @@ func (a *GrantAccountsApi) GetGrantAccount(ctx context.Context, r GrantAccountsA headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_grant_offers.go b/src/balanceplatform/api_grant_offers.go index fad7878c0..d6f48a1f2 100644 --- a/src/balanceplatform/api_grant_offers.go +++ b/src/balanceplatform/api_grant_offers.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -68,6 +70,53 @@ func (a *GrantOffersApi) GetAllAvailableGrantOffers(ctx context.Context, r Grant headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -113,5 +162,52 @@ func (a *GrantOffersApi) GetGrantOffer(ctx context.Context, r GrantOffersApiGetG headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_payment_instrument_groups.go b/src/balanceplatform/api_payment_instrument_groups.go index 9697f31d0..222c0d46d 100644 --- a/src/balanceplatform/api_payment_instrument_groups.go +++ b/src/balanceplatform/api_payment_instrument_groups.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -64,6 +66,53 @@ func (a *PaymentInstrumentGroupsApi) CreatePaymentInstrumentGroup(ctx context.Co headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -109,6 +158,53 @@ func (a *PaymentInstrumentGroupsApi) GetAllTransactionRulesForPaymentInstrumentG headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -154,5 +250,52 @@ func (a *PaymentInstrumentGroupsApi) GetPaymentInstrumentGroup(ctx context.Conte headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_payment_instruments.go b/src/balanceplatform/api_payment_instruments.go index 64401b241..f89ab5f93 100644 --- a/src/balanceplatform/api_payment_instruments.go +++ b/src/balanceplatform/api_payment_instruments.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -66,6 +68,53 @@ func (a *PaymentInstrumentsApi) CreatePaymentInstrument(ctx context.Context, r P headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -111,6 +160,53 @@ func (a *PaymentInstrumentsApi) GetAllTransactionRulesForPaymentInstrument(ctx c headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -160,6 +256,53 @@ func (a *PaymentInstrumentsApi) GetPanOfPaymentInstrument(ctx context.Context, r headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -205,6 +348,53 @@ func (a *PaymentInstrumentsApi) GetPaymentInstrument(ctx context.Context, r Paym headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -256,5 +446,52 @@ func (a *PaymentInstrumentsApi) UpdatePaymentInstrument(ctx context.Context, r P headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_platform.go b/src/balanceplatform/api_platform.go index 99c2ae0bc..281f7d7ee 100644 --- a/src/balanceplatform/api_platform.go +++ b/src/balanceplatform/api_platform.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -84,6 +86,53 @@ func (a *PlatformApi) GetAllAccountHoldersUnderBalancePlatform(ctx context.Conte headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -129,5 +178,52 @@ func (a *PlatformApi) GetBalancePlatform(ctx context.Context, r PlatformApiGetBa headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/api_transaction_rules.go b/src/balanceplatform/api_transaction_rules.go index a851496bd..197a497e5 100644 --- a/src/balanceplatform/api_transaction_rules.go +++ b/src/balanceplatform/api_transaction_rules.go @@ -10,6 +10,8 @@ package balanceplatform import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -64,6 +66,53 @@ func (a *TransactionRulesApi) CreateTransactionRule(ctx context.Context, r Trans headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -109,6 +158,53 @@ func (a *TransactionRulesApi) DeleteTransactionRule(ctx context.Context, r Trans headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -154,6 +250,53 @@ func (a *TransactionRulesApi) GetTransactionRule(ctx context.Context, r Transact headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -209,5 +352,52 @@ func (a *TransactionRulesApi) UpdateTransactionRule(ctx context.Context, r Trans headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 400 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/balanceplatform/model_account_holder.go b/src/balanceplatform/model_account_holder.go index f8f69239c..633e0f0a1 100644 --- a/src/balanceplatform/model_account_holder.go +++ b/src/balanceplatform/model_account_holder.go @@ -30,6 +30,8 @@ type AccountHolder struct { Id string `json:"id"` // The unique identifier of the [legal entity](https://docs.adyen.com/api-explorer/legalentity/latest/post/legalEntities#responses-200-id) associated with the account holder. Adyen performs a verification process against the legal entity of the account holder. LegalEntityId string `json:"legalEntityId"` + // A set of key and value pairs for general use by the merchant. The keys do not have specific names and may be used for storing miscellaneous data as desired. > Note that during an update of metadata, the omission of existing key-value pairs will result in the deletion of those key-value pairs. + Metadata *map[string]string `json:"metadata,omitempty"` // The ID of the account holder's primary balance account. By default, this is set to the first balance account that you create for the account holder. To assign a different balance account, send a PATCH request. PrimaryBalanceAccount *string `json:"primaryBalanceAccount,omitempty"` // Your reference for the account holder, maximum 150 characters. @@ -237,6 +239,38 @@ func (o *AccountHolder) SetLegalEntityId(v string) { o.LegalEntityId = v } +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *AccountHolder) GetMetadata() map[string]string { + if o == nil || common.IsNil(o.Metadata) { + var ret map[string]string + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AccountHolder) GetMetadataOk() (*map[string]string, bool) { + if o == nil || common.IsNil(o.Metadata) { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *AccountHolder) HasMetadata() bool { + if o != nil && !common.IsNil(o.Metadata) { + return true + } + + return false +} + +// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. +func (o *AccountHolder) SetMetadata(v map[string]string) { + o.Metadata = &v +} + // GetPrimaryBalanceAccount returns the PrimaryBalanceAccount field value if set, zero value otherwise. func (o *AccountHolder) GetPrimaryBalanceAccount() string { if o == nil || common.IsNil(o.PrimaryBalanceAccount) { @@ -421,6 +455,9 @@ func (o AccountHolder) ToMap() (map[string]interface{}, error) { } toSerialize["id"] = o.Id toSerialize["legalEntityId"] = o.LegalEntityId + if !common.IsNil(o.Metadata) { + toSerialize["metadata"] = o.Metadata + } if !common.IsNil(o.PrimaryBalanceAccount) { toSerialize["primaryBalanceAccount"] = o.PrimaryBalanceAccount } diff --git a/src/balanceplatform/model_account_holder_capability.go b/src/balanceplatform/model_account_holder_capability.go index 04a59ed8d..c612c19cc 100644 --- a/src/balanceplatform/model_account_holder_capability.go +++ b/src/balanceplatform/model_account_holder_capability.go @@ -22,8 +22,8 @@ type AccountHolderCapability struct { // Indicates whether the capability is allowed. Adyen sets this to **true** if the verification is successful and the account holder is permitted to use the capability. Allowed *bool `json:"allowed,omitempty"` // The capability level that is allowed for the account holder. Possible values: **notApplicable**, **low**, **medium**, **high**. - AllowedLevel *string `json:"allowedLevel,omitempty"` - AllowedSettings *JSONObject `json:"allowedSettings,omitempty"` + AllowedLevel *string `json:"allowedLevel,omitempty"` + AllowedSettings *CapabilitySettings `json:"allowedSettings,omitempty"` // Indicates whether the capability is enabled. If **false**, the capability is temporarily disabled for the account holder. Enabled *bool `json:"enabled,omitempty"` // Contains verification errors and the actions that you can take to resolve them. @@ -31,8 +31,8 @@ type AccountHolderCapability struct { // Indicates whether the capability is requested. To check whether the account holder is permitted to use the capability, refer to the `allowed` field. Requested *bool `json:"requested,omitempty"` // The requested level of the capability. Some capabilities, such as those used in [card issuing](https://docs.adyen.com/issuing/add-capabilities#capability-levels), have different levels. Levels increase the capability, but also require additional checks and increased monitoring. Possible values: **notApplicable**, **low**, **medium**, **high**. - RequestedLevel *string `json:"requestedLevel,omitempty"` - RequestedSettings *JSONObject `json:"requestedSettings,omitempty"` + RequestedLevel *string `json:"requestedLevel,omitempty"` + RequestedSettings *CapabilitySettings `json:"requestedSettings,omitempty"` // Contains the status of the transfer instruments associated with this capability. TransferInstruments []AccountSupportingEntityCapability `json:"transferInstruments,omitempty"` // The status of the verification checks for the capability. Possible values: * **pending**: Adyen is running the verification. * **invalid**: The verification failed. Check if the `errors` array contains more information. * **valid**: The verification has been successfully completed. * **rejected**: Adyen has verified the information, but found reasons to not allow the capability. @@ -121,9 +121,9 @@ func (o *AccountHolderCapability) SetAllowedLevel(v string) { } // GetAllowedSettings returns the AllowedSettings field value if set, zero value otherwise. -func (o *AccountHolderCapability) GetAllowedSettings() JSONObject { +func (o *AccountHolderCapability) GetAllowedSettings() CapabilitySettings { if o == nil || common.IsNil(o.AllowedSettings) { - var ret JSONObject + var ret CapabilitySettings return ret } return *o.AllowedSettings @@ -131,7 +131,7 @@ func (o *AccountHolderCapability) GetAllowedSettings() JSONObject { // GetAllowedSettingsOk returns a tuple with the AllowedSettings field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *AccountHolderCapability) GetAllowedSettingsOk() (*JSONObject, bool) { +func (o *AccountHolderCapability) GetAllowedSettingsOk() (*CapabilitySettings, bool) { if o == nil || common.IsNil(o.AllowedSettings) { return nil, false } @@ -147,8 +147,8 @@ func (o *AccountHolderCapability) HasAllowedSettings() bool { return false } -// SetAllowedSettings gets a reference to the given JSONObject and assigns it to the AllowedSettings field. -func (o *AccountHolderCapability) SetAllowedSettings(v JSONObject) { +// SetAllowedSettings gets a reference to the given CapabilitySettings and assigns it to the AllowedSettings field. +func (o *AccountHolderCapability) SetAllowedSettings(v CapabilitySettings) { o.AllowedSettings = &v } @@ -281,9 +281,9 @@ func (o *AccountHolderCapability) SetRequestedLevel(v string) { } // GetRequestedSettings returns the RequestedSettings field value if set, zero value otherwise. -func (o *AccountHolderCapability) GetRequestedSettings() JSONObject { +func (o *AccountHolderCapability) GetRequestedSettings() CapabilitySettings { if o == nil || common.IsNil(o.RequestedSettings) { - var ret JSONObject + var ret CapabilitySettings return ret } return *o.RequestedSettings @@ -291,7 +291,7 @@ func (o *AccountHolderCapability) GetRequestedSettings() JSONObject { // GetRequestedSettingsOk returns a tuple with the RequestedSettings field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *AccountHolderCapability) GetRequestedSettingsOk() (*JSONObject, bool) { +func (o *AccountHolderCapability) GetRequestedSettingsOk() (*CapabilitySettings, bool) { if o == nil || common.IsNil(o.RequestedSettings) { return nil, false } @@ -307,8 +307,8 @@ func (o *AccountHolderCapability) HasRequestedSettings() bool { return false } -// SetRequestedSettings gets a reference to the given JSONObject and assigns it to the RequestedSettings field. -func (o *AccountHolderCapability) SetRequestedSettings(v JSONObject) { +// SetRequestedSettings gets a reference to the given CapabilitySettings and assigns it to the RequestedSettings field. +func (o *AccountHolderCapability) SetRequestedSettings(v CapabilitySettings) { o.RequestedSettings = &v } diff --git a/src/balanceplatform/model_account_holder_info.go b/src/balanceplatform/model_account_holder_info.go index edd5b14c3..9faa2d4b7 100644 --- a/src/balanceplatform/model_account_holder_info.go +++ b/src/balanceplatform/model_account_holder_info.go @@ -28,6 +28,8 @@ type AccountHolderInfo struct { Description *string `json:"description,omitempty"` // The unique identifier of the [legal entity](https://docs.adyen.com/api-explorer/legalentity/latest/post/legalEntities#responses-200-id) associated with the account holder. Adyen performs a verification process against the legal entity of the account holder. LegalEntityId string `json:"legalEntityId"` + // A set of key and value pairs for general use by the merchant. The keys do not have specific names and may be used for storing miscellaneous data as desired. > Note that during an update of metadata, the omission of existing key-value pairs will result in the deletion of those key-value pairs. + Metadata *map[string]string `json:"metadata,omitempty"` // Your reference for the account holder, maximum 150 characters. Reference *string `json:"reference,omitempty"` // The time zone of the account holder. For example, **Europe/Amsterdam**. Defaults to the time zone of the balance platform if no time zone is set. For possible values, see the [list of time zone codes](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). @@ -204,6 +206,38 @@ func (o *AccountHolderInfo) SetLegalEntityId(v string) { o.LegalEntityId = v } +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *AccountHolderInfo) GetMetadata() map[string]string { + if o == nil || common.IsNil(o.Metadata) { + var ret map[string]string + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AccountHolderInfo) GetMetadataOk() (*map[string]string, bool) { + if o == nil || common.IsNil(o.Metadata) { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *AccountHolderInfo) HasMetadata() bool { + if o != nil && !common.IsNil(o.Metadata) { + return true + } + + return false +} + +// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. +func (o *AccountHolderInfo) SetMetadata(v map[string]string) { + o.Metadata = &v +} + // GetReference returns the Reference field value if set, zero value otherwise. func (o *AccountHolderInfo) GetReference() string { if o == nil || common.IsNil(o.Reference) { @@ -291,6 +325,9 @@ func (o AccountHolderInfo) ToMap() (map[string]interface{}, error) { toSerialize["description"] = o.Description } toSerialize["legalEntityId"] = o.LegalEntityId + if !common.IsNil(o.Metadata) { + toSerialize["metadata"] = o.Metadata + } if !common.IsNil(o.Reference) { toSerialize["reference"] = o.Reference } diff --git a/src/balanceplatform/model_balance_account.go b/src/balanceplatform/model_balance_account.go index ce1b5b7d3..9a6e3695e 100644 --- a/src/balanceplatform/model_balance_account.go +++ b/src/balanceplatform/model_balance_account.go @@ -29,6 +29,8 @@ type BalanceAccount struct { Description *string `json:"description,omitempty"` // The unique identifier of the balance account. Id string `json:"id"` + // A set of key and value pairs for general use by the merchant. The keys do not have specific names and may be used for storing miscellaneous data as desired. > Note that during an update of metadata, the omission of existing key-value pairs will result in the deletion of those key-value pairs. + Metadata *map[string]string `json:"metadata,omitempty"` // Your reference for the balance account, maximum 150 characters. Reference *string `json:"reference,omitempty"` // The status of the balance account, set to **active** by default. @@ -200,6 +202,38 @@ func (o *BalanceAccount) SetId(v string) { o.Id = v } +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *BalanceAccount) GetMetadata() map[string]string { + if o == nil || common.IsNil(o.Metadata) { + var ret map[string]string + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BalanceAccount) GetMetadataOk() (*map[string]string, bool) { + if o == nil || common.IsNil(o.Metadata) { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *BalanceAccount) HasMetadata() bool { + if o != nil && !common.IsNil(o.Metadata) { + return true + } + + return false +} + +// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. +func (o *BalanceAccount) SetMetadata(v map[string]string) { + o.Metadata = &v +} + // GetReference returns the Reference field value if set, zero value otherwise. func (o *BalanceAccount) GetReference() string { if o == nil || common.IsNil(o.Reference) { @@ -317,6 +351,9 @@ func (o BalanceAccount) ToMap() (map[string]interface{}, error) { toSerialize["description"] = o.Description } toSerialize["id"] = o.Id + if !common.IsNil(o.Metadata) { + toSerialize["metadata"] = o.Metadata + } if !common.IsNil(o.Reference) { toSerialize["reference"] = o.Reference } diff --git a/src/balanceplatform/model_balance_account_base.go b/src/balanceplatform/model_balance_account_base.go index b07896336..b727a85a4 100644 --- a/src/balanceplatform/model_balance_account_base.go +++ b/src/balanceplatform/model_balance_account_base.go @@ -27,6 +27,8 @@ type BalanceAccountBase struct { Description *string `json:"description,omitempty"` // The unique identifier of the balance account. Id string `json:"id"` + // A set of key and value pairs for general use by the merchant. The keys do not have specific names and may be used for storing miscellaneous data as desired. > Note that during an update of metadata, the omission of existing key-value pairs will result in the deletion of those key-value pairs. + Metadata *map[string]string `json:"metadata,omitempty"` // Your reference for the balance account, maximum 150 characters. Reference *string `json:"reference,omitempty"` // The status of the balance account, set to **active** by default. @@ -166,6 +168,38 @@ func (o *BalanceAccountBase) SetId(v string) { o.Id = v } +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *BalanceAccountBase) GetMetadata() map[string]string { + if o == nil || common.IsNil(o.Metadata) { + var ret map[string]string + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BalanceAccountBase) GetMetadataOk() (*map[string]string, bool) { + if o == nil || common.IsNil(o.Metadata) { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *BalanceAccountBase) HasMetadata() bool { + if o != nil && !common.IsNil(o.Metadata) { + return true + } + + return false +} + +// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. +func (o *BalanceAccountBase) SetMetadata(v map[string]string) { + o.Metadata = &v +} + // GetReference returns the Reference field value if set, zero value otherwise. func (o *BalanceAccountBase) GetReference() string { if o == nil || common.IsNil(o.Reference) { @@ -280,6 +314,9 @@ func (o BalanceAccountBase) ToMap() (map[string]interface{}, error) { toSerialize["description"] = o.Description } toSerialize["id"] = o.Id + if !common.IsNil(o.Metadata) { + toSerialize["metadata"] = o.Metadata + } if !common.IsNil(o.Reference) { toSerialize["reference"] = o.Reference } diff --git a/src/balanceplatform/model_balance_account_info.go b/src/balanceplatform/model_balance_account_info.go index 65ba10e70..3cce75659 100644 --- a/src/balanceplatform/model_balance_account_info.go +++ b/src/balanceplatform/model_balance_account_info.go @@ -25,6 +25,8 @@ type BalanceAccountInfo struct { DefaultCurrencyCode *string `json:"defaultCurrencyCode,omitempty"` // A human-readable description of the balance account, maximum 300 characters. You can use this parameter to distinguish between multiple balance accounts under an account holder. Description *string `json:"description,omitempty"` + // A set of key and value pairs for general use by the merchant. The keys do not have specific names and may be used for storing miscellaneous data as desired. > Note that during an update of metadata, the omission of existing key-value pairs will result in the deletion of those key-value pairs. + Metadata *map[string]string `json:"metadata,omitempty"` // Your reference for the balance account, maximum 150 characters. Reference *string `json:"reference,omitempty"` // The time zone of the balance account. For example, **Europe/Amsterdam**. Defaults to the time zone of the account holder if no time zone is set. For possible values, see the [list of time zone codes](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). @@ -137,6 +139,38 @@ func (o *BalanceAccountInfo) SetDescription(v string) { o.Description = &v } +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *BalanceAccountInfo) GetMetadata() map[string]string { + if o == nil || common.IsNil(o.Metadata) { + var ret map[string]string + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BalanceAccountInfo) GetMetadataOk() (*map[string]string, bool) { + if o == nil || common.IsNil(o.Metadata) { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *BalanceAccountInfo) HasMetadata() bool { + if o != nil && !common.IsNil(o.Metadata) { + return true + } + + return false +} + +// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. +func (o *BalanceAccountInfo) SetMetadata(v map[string]string) { + o.Metadata = &v +} + // GetReference returns the Reference field value if set, zero value otherwise. func (o *BalanceAccountInfo) GetReference() string { if o == nil || common.IsNil(o.Reference) { @@ -218,6 +252,9 @@ func (o BalanceAccountInfo) ToMap() (map[string]interface{}, error) { if !common.IsNil(o.Description) { toSerialize["description"] = o.Description } + if !common.IsNil(o.Metadata) { + toSerialize["metadata"] = o.Metadata + } if !common.IsNil(o.Reference) { toSerialize["reference"] = o.Reference } diff --git a/src/balanceplatform/model_balance_account_update_request.go b/src/balanceplatform/model_balance_account_update_request.go index 03f707660..433a13a30 100644 --- a/src/balanceplatform/model_balance_account_update_request.go +++ b/src/balanceplatform/model_balance_account_update_request.go @@ -25,6 +25,8 @@ type BalanceAccountUpdateRequest struct { DefaultCurrencyCode *string `json:"defaultCurrencyCode,omitempty"` // A human-readable description of the balance account, maximum 300 characters. You can use this parameter to distinguish between multiple balance accounts under an account holder. Description *string `json:"description,omitempty"` + // A set of key and value pairs for general use by the merchant. The keys do not have specific names and may be used for storing miscellaneous data as desired. > Note that during an update of metadata, the omission of existing key-value pairs will result in the deletion of those key-value pairs. + Metadata *map[string]string `json:"metadata,omitempty"` // Your reference to the balance account, maximum 150 characters. Reference *string `json:"reference,omitempty"` // The status of the balance account. Payment instruments linked to the balance account can only be used if the balance account status is **active**. Possible values: **active**, **inactive**, **closed**, **suspended**. @@ -146,6 +148,38 @@ func (o *BalanceAccountUpdateRequest) SetDescription(v string) { o.Description = &v } +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *BalanceAccountUpdateRequest) GetMetadata() map[string]string { + if o == nil || common.IsNil(o.Metadata) { + var ret map[string]string + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *BalanceAccountUpdateRequest) GetMetadataOk() (*map[string]string, bool) { + if o == nil || common.IsNil(o.Metadata) { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *BalanceAccountUpdateRequest) HasMetadata() bool { + if o != nil && !common.IsNil(o.Metadata) { + return true + } + + return false +} + +// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. +func (o *BalanceAccountUpdateRequest) SetMetadata(v map[string]string) { + o.Metadata = &v +} + // GetReference returns the Reference field value if set, zero value otherwise. func (o *BalanceAccountUpdateRequest) GetReference() string { if o == nil || common.IsNil(o.Reference) { @@ -261,6 +295,9 @@ func (o BalanceAccountUpdateRequest) ToMap() (map[string]interface{}, error) { if !common.IsNil(o.Description) { toSerialize["description"] = o.Description } + if !common.IsNil(o.Metadata) { + toSerialize["metadata"] = o.Metadata + } if !common.IsNil(o.Reference) { toSerialize["reference"] = o.Reference } diff --git a/src/balanceplatform/model_capability_settings.go b/src/balanceplatform/model_capability_settings.go new file mode 100644 index 000000000..b99e9bca1 --- /dev/null +++ b/src/balanceplatform/model_capability_settings.go @@ -0,0 +1,282 @@ +/* +Configuration API + +API version: 2 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package balanceplatform + +import ( + "encoding/json" + + "github.com/adyen/adyen-go-api-library/v7/src/common" +) + +// checks if the CapabilitySettings type satisfies the MappedNullable interface at compile time +var _ common.MappedNullable = &CapabilitySettings{} + +// CapabilitySettings struct for CapabilitySettings +type CapabilitySettings struct { + // + AmountPerIndustry *map[string]Amount `json:"amountPerIndustry,omitempty"` + // + AuthorizedCardUsers *bool `json:"authorizedCardUsers,omitempty"` + // + FundingSource []string `json:"fundingSource,omitempty"` + // + Interval *string `json:"interval,omitempty"` + MaxAmount *Amount `json:"maxAmount,omitempty"` +} + +// NewCapabilitySettings instantiates a new CapabilitySettings object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCapabilitySettings() *CapabilitySettings { + this := CapabilitySettings{} + return &this +} + +// NewCapabilitySettingsWithDefaults instantiates a new CapabilitySettings object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCapabilitySettingsWithDefaults() *CapabilitySettings { + this := CapabilitySettings{} + return &this +} + +// GetAmountPerIndustry returns the AmountPerIndustry field value if set, zero value otherwise. +func (o *CapabilitySettings) GetAmountPerIndustry() map[string]Amount { + if o == nil || common.IsNil(o.AmountPerIndustry) { + var ret map[string]Amount + return ret + } + return *o.AmountPerIndustry +} + +// GetAmountPerIndustryOk returns a tuple with the AmountPerIndustry field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CapabilitySettings) GetAmountPerIndustryOk() (*map[string]Amount, bool) { + if o == nil || common.IsNil(o.AmountPerIndustry) { + return nil, false + } + return o.AmountPerIndustry, true +} + +// HasAmountPerIndustry returns a boolean if a field has been set. +func (o *CapabilitySettings) HasAmountPerIndustry() bool { + if o != nil && !common.IsNil(o.AmountPerIndustry) { + return true + } + + return false +} + +// SetAmountPerIndustry gets a reference to the given map[string]Amount and assigns it to the AmountPerIndustry field. +func (o *CapabilitySettings) SetAmountPerIndustry(v map[string]Amount) { + o.AmountPerIndustry = &v +} + +// GetAuthorizedCardUsers returns the AuthorizedCardUsers field value if set, zero value otherwise. +func (o *CapabilitySettings) GetAuthorizedCardUsers() bool { + if o == nil || common.IsNil(o.AuthorizedCardUsers) { + var ret bool + return ret + } + return *o.AuthorizedCardUsers +} + +// GetAuthorizedCardUsersOk returns a tuple with the AuthorizedCardUsers field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CapabilitySettings) GetAuthorizedCardUsersOk() (*bool, bool) { + if o == nil || common.IsNil(o.AuthorizedCardUsers) { + return nil, false + } + return o.AuthorizedCardUsers, true +} + +// HasAuthorizedCardUsers returns a boolean if a field has been set. +func (o *CapabilitySettings) HasAuthorizedCardUsers() bool { + if o != nil && !common.IsNil(o.AuthorizedCardUsers) { + return true + } + + return false +} + +// SetAuthorizedCardUsers gets a reference to the given bool and assigns it to the AuthorizedCardUsers field. +func (o *CapabilitySettings) SetAuthorizedCardUsers(v bool) { + o.AuthorizedCardUsers = &v +} + +// GetFundingSource returns the FundingSource field value if set, zero value otherwise. +func (o *CapabilitySettings) GetFundingSource() []string { + if o == nil || common.IsNil(o.FundingSource) { + var ret []string + return ret + } + return o.FundingSource +} + +// GetFundingSourceOk returns a tuple with the FundingSource field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CapabilitySettings) GetFundingSourceOk() ([]string, bool) { + if o == nil || common.IsNil(o.FundingSource) { + return nil, false + } + return o.FundingSource, true +} + +// HasFundingSource returns a boolean if a field has been set. +func (o *CapabilitySettings) HasFundingSource() bool { + if o != nil && !common.IsNil(o.FundingSource) { + return true + } + + return false +} + +// SetFundingSource gets a reference to the given []string and assigns it to the FundingSource field. +func (o *CapabilitySettings) SetFundingSource(v []string) { + o.FundingSource = v +} + +// GetInterval returns the Interval field value if set, zero value otherwise. +func (o *CapabilitySettings) GetInterval() string { + if o == nil || common.IsNil(o.Interval) { + var ret string + return ret + } + return *o.Interval +} + +// GetIntervalOk returns a tuple with the Interval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CapabilitySettings) GetIntervalOk() (*string, bool) { + if o == nil || common.IsNil(o.Interval) { + return nil, false + } + return o.Interval, true +} + +// HasInterval returns a boolean if a field has been set. +func (o *CapabilitySettings) HasInterval() bool { + if o != nil && !common.IsNil(o.Interval) { + return true + } + + return false +} + +// SetInterval gets a reference to the given string and assigns it to the Interval field. +func (o *CapabilitySettings) SetInterval(v string) { + o.Interval = &v +} + +// GetMaxAmount returns the MaxAmount field value if set, zero value otherwise. +func (o *CapabilitySettings) GetMaxAmount() Amount { + if o == nil || common.IsNil(o.MaxAmount) { + var ret Amount + return ret + } + return *o.MaxAmount +} + +// GetMaxAmountOk returns a tuple with the MaxAmount field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CapabilitySettings) GetMaxAmountOk() (*Amount, bool) { + if o == nil || common.IsNil(o.MaxAmount) { + return nil, false + } + return o.MaxAmount, true +} + +// HasMaxAmount returns a boolean if a field has been set. +func (o *CapabilitySettings) HasMaxAmount() bool { + if o != nil && !common.IsNil(o.MaxAmount) { + return true + } + + return false +} + +// SetMaxAmount gets a reference to the given Amount and assigns it to the MaxAmount field. +func (o *CapabilitySettings) SetMaxAmount(v Amount) { + o.MaxAmount = &v +} + +func (o CapabilitySettings) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o CapabilitySettings) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !common.IsNil(o.AmountPerIndustry) { + toSerialize["amountPerIndustry"] = o.AmountPerIndustry + } + if !common.IsNil(o.AuthorizedCardUsers) { + toSerialize["authorizedCardUsers"] = o.AuthorizedCardUsers + } + if !common.IsNil(o.FundingSource) { + toSerialize["fundingSource"] = o.FundingSource + } + if !common.IsNil(o.Interval) { + toSerialize["interval"] = o.Interval + } + if !common.IsNil(o.MaxAmount) { + toSerialize["maxAmount"] = o.MaxAmount + } + return toSerialize, nil +} + +type NullableCapabilitySettings struct { + value *CapabilitySettings + isSet bool +} + +func (v NullableCapabilitySettings) Get() *CapabilitySettings { + return v.value +} + +func (v *NullableCapabilitySettings) Set(val *CapabilitySettings) { + v.value = val + v.isSet = true +} + +func (v NullableCapabilitySettings) IsSet() bool { + return v.isSet +} + +func (v *NullableCapabilitySettings) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCapabilitySettings(val *CapabilitySettings) *NullableCapabilitySettings { + return &NullableCapabilitySettings{value: val, isSet: true} +} + +func (v NullableCapabilitySettings) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCapabilitySettings) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +func (o *CapabilitySettings) isValidInterval() bool { + var allowedEnumValues = []string{"daily", "monthly", "weekly"} + for _, allowed := range allowedEnumValues { + if o.GetInterval() == allowed { + return true + } + } + return false +} diff --git a/src/balanceplatform/model_cron_sweep_schedule.go b/src/balanceplatform/model_cron_sweep_schedule.go index f953b1869..3023cce00 100644 --- a/src/balanceplatform/model_cron_sweep_schedule.go +++ b/src/balanceplatform/model_cron_sweep_schedule.go @@ -21,7 +21,7 @@ var _ common.MappedNullable = &CronSweepSchedule{} type CronSweepSchedule struct { // A [cron expression](https://en.wikipedia.org/wiki/Cron#CRON_expression) that is used to set the sweep schedule. The schedule uses the time zone of the balance account. For example, **30 17 * * MON** schedules a sweep every Monday at 17:30. The expression must have five values separated by a single space in the following order: * Minute: **0-59** * Hour: **0-23** * Day of the month: **1-31** * Month: **1-12** or **JAN-DEC** * Day of the week: **0-7** (0 and 7 are Sunday) or **MON-SUN**. The following non-standard characters are supported: *****, **L**, **#**, **W** and **_/_**. See [crontab guru](https://crontab.guru/) for more examples. CronExpression string `json:"cronExpression"` - // The schedule type. Possible values: * **cron**: push out funds based on a cron expression. * **daily**: push out funds daily at 07:00 AM CET. * **weekly**: push out funds every Monday at 07:00 AM CET. * **monthly**: push out funds every first of the month at 07:00 AM CET. * **balance**: pull in funds instantly if the balance is less than or equal to the `triggerAmount`. You can only use this for sweeps of `type` **pull** and when the source is a `merchantAccount` or `transferInstrument`. + // The schedule type. Possible values: * **cron**: push out funds based on a cron expression. * **daily**: push out funds daily at 07:00 AM CET. * **weekly**: push out funds every Monday at 07:00 AM CET. * **monthly**: push out funds every first of the month at 07:00 AM CET. * **balance**: pull in funds instantly if the balance is less than or equal to the `triggerAmount`. You can only use this for sweeps of `type` **pull** and when the source is a `merchantAccount` or `transferInstrument`.If the source is transferInstrument, merchant account identifier is still required, with which you want to process the transaction. Type *string `json:"type,omitempty"` } diff --git a/src/balanceplatform/model_address_2.go b/src/balanceplatform/model_delivery_address.go similarity index 72% rename from src/balanceplatform/model_address_2.go rename to src/balanceplatform/model_delivery_address.go index 920a4e214..55b0d8fba 100644 --- a/src/balanceplatform/model_address_2.go +++ b/src/balanceplatform/model_delivery_address.go @@ -14,11 +14,11 @@ import ( "github.com/adyen/adyen-go-api-library/v7/src/common" ) -// checks if the Address2 type satisfies the MappedNullable interface at compile time -var _ common.MappedNullable = &Address2{} +// checks if the DeliveryAddress type satisfies the MappedNullable interface at compile time +var _ common.MappedNullable = &DeliveryAddress{} -// Address2 struct for Address2 -type Address2 struct { +// DeliveryAddress struct for DeliveryAddress +type DeliveryAddress struct { // The name of the city. City *string `json:"city,omitempty"` // The two-character ISO-3166-1 alpha-2 country code. For example, **US**. >If you don't know the country or are not collecting the country from the shopper, provide `country` as `ZZ`. @@ -35,26 +35,26 @@ type Address2 struct { StateOrProvince *string `json:"stateOrProvince,omitempty"` } -// NewAddress2 instantiates a new Address2 object +// NewDeliveryAddress instantiates a new DeliveryAddress object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewAddress2(country string) *Address2 { - this := Address2{} +func NewDeliveryAddress(country string) *DeliveryAddress { + this := DeliveryAddress{} this.Country = country return &this } -// NewAddress2WithDefaults instantiates a new Address2 object +// NewDeliveryAddressWithDefaults instantiates a new DeliveryAddress object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set -func NewAddress2WithDefaults() *Address2 { - this := Address2{} +func NewDeliveryAddressWithDefaults() *DeliveryAddress { + this := DeliveryAddress{} return &this } // GetCity returns the City field value if set, zero value otherwise. -func (o *Address2) GetCity() string { +func (o *DeliveryAddress) GetCity() string { if o == nil || common.IsNil(o.City) { var ret string return ret @@ -64,7 +64,7 @@ func (o *Address2) GetCity() string { // GetCityOk returns a tuple with the City field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Address2) GetCityOk() (*string, bool) { +func (o *DeliveryAddress) GetCityOk() (*string, bool) { if o == nil || common.IsNil(o.City) { return nil, false } @@ -72,7 +72,7 @@ func (o *Address2) GetCityOk() (*string, bool) { } // HasCity returns a boolean if a field has been set. -func (o *Address2) HasCity() bool { +func (o *DeliveryAddress) HasCity() bool { if o != nil && !common.IsNil(o.City) { return true } @@ -81,12 +81,12 @@ func (o *Address2) HasCity() bool { } // SetCity gets a reference to the given string and assigns it to the City field. -func (o *Address2) SetCity(v string) { +func (o *DeliveryAddress) SetCity(v string) { o.City = &v } // GetCountry returns the Country field value -func (o *Address2) GetCountry() string { +func (o *DeliveryAddress) GetCountry() string { if o == nil { var ret string return ret @@ -97,7 +97,7 @@ func (o *Address2) GetCountry() string { // GetCountryOk returns a tuple with the Country field value // and a boolean to check if the value has been set. -func (o *Address2) GetCountryOk() (*string, bool) { +func (o *DeliveryAddress) GetCountryOk() (*string, bool) { if o == nil { return nil, false } @@ -105,12 +105,12 @@ func (o *Address2) GetCountryOk() (*string, bool) { } // SetCountry sets field value -func (o *Address2) SetCountry(v string) { +func (o *DeliveryAddress) SetCountry(v string) { o.Country = v } // GetLine1 returns the Line1 field value if set, zero value otherwise. -func (o *Address2) GetLine1() string { +func (o *DeliveryAddress) GetLine1() string { if o == nil || common.IsNil(o.Line1) { var ret string return ret @@ -120,7 +120,7 @@ func (o *Address2) GetLine1() string { // GetLine1Ok returns a tuple with the Line1 field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Address2) GetLine1Ok() (*string, bool) { +func (o *DeliveryAddress) GetLine1Ok() (*string, bool) { if o == nil || common.IsNil(o.Line1) { return nil, false } @@ -128,7 +128,7 @@ func (o *Address2) GetLine1Ok() (*string, bool) { } // HasLine1 returns a boolean if a field has been set. -func (o *Address2) HasLine1() bool { +func (o *DeliveryAddress) HasLine1() bool { if o != nil && !common.IsNil(o.Line1) { return true } @@ -137,12 +137,12 @@ func (o *Address2) HasLine1() bool { } // SetLine1 gets a reference to the given string and assigns it to the Line1 field. -func (o *Address2) SetLine1(v string) { +func (o *DeliveryAddress) SetLine1(v string) { o.Line1 = &v } // GetLine2 returns the Line2 field value if set, zero value otherwise. -func (o *Address2) GetLine2() string { +func (o *DeliveryAddress) GetLine2() string { if o == nil || common.IsNil(o.Line2) { var ret string return ret @@ -152,7 +152,7 @@ func (o *Address2) GetLine2() string { // GetLine2Ok returns a tuple with the Line2 field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Address2) GetLine2Ok() (*string, bool) { +func (o *DeliveryAddress) GetLine2Ok() (*string, bool) { if o == nil || common.IsNil(o.Line2) { return nil, false } @@ -160,7 +160,7 @@ func (o *Address2) GetLine2Ok() (*string, bool) { } // HasLine2 returns a boolean if a field has been set. -func (o *Address2) HasLine2() bool { +func (o *DeliveryAddress) HasLine2() bool { if o != nil && !common.IsNil(o.Line2) { return true } @@ -169,12 +169,12 @@ func (o *Address2) HasLine2() bool { } // SetLine2 gets a reference to the given string and assigns it to the Line2 field. -func (o *Address2) SetLine2(v string) { +func (o *DeliveryAddress) SetLine2(v string) { o.Line2 = &v } // GetLine3 returns the Line3 field value if set, zero value otherwise. -func (o *Address2) GetLine3() string { +func (o *DeliveryAddress) GetLine3() string { if o == nil || common.IsNil(o.Line3) { var ret string return ret @@ -184,7 +184,7 @@ func (o *Address2) GetLine3() string { // GetLine3Ok returns a tuple with the Line3 field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Address2) GetLine3Ok() (*string, bool) { +func (o *DeliveryAddress) GetLine3Ok() (*string, bool) { if o == nil || common.IsNil(o.Line3) { return nil, false } @@ -192,7 +192,7 @@ func (o *Address2) GetLine3Ok() (*string, bool) { } // HasLine3 returns a boolean if a field has been set. -func (o *Address2) HasLine3() bool { +func (o *DeliveryAddress) HasLine3() bool { if o != nil && !common.IsNil(o.Line3) { return true } @@ -201,12 +201,12 @@ func (o *Address2) HasLine3() bool { } // SetLine3 gets a reference to the given string and assigns it to the Line3 field. -func (o *Address2) SetLine3(v string) { +func (o *DeliveryAddress) SetLine3(v string) { o.Line3 = &v } // GetPostalCode returns the PostalCode field value if set, zero value otherwise. -func (o *Address2) GetPostalCode() string { +func (o *DeliveryAddress) GetPostalCode() string { if o == nil || common.IsNil(o.PostalCode) { var ret string return ret @@ -216,7 +216,7 @@ func (o *Address2) GetPostalCode() string { // GetPostalCodeOk returns a tuple with the PostalCode field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Address2) GetPostalCodeOk() (*string, bool) { +func (o *DeliveryAddress) GetPostalCodeOk() (*string, bool) { if o == nil || common.IsNil(o.PostalCode) { return nil, false } @@ -224,7 +224,7 @@ func (o *Address2) GetPostalCodeOk() (*string, bool) { } // HasPostalCode returns a boolean if a field has been set. -func (o *Address2) HasPostalCode() bool { +func (o *DeliveryAddress) HasPostalCode() bool { if o != nil && !common.IsNil(o.PostalCode) { return true } @@ -233,12 +233,12 @@ func (o *Address2) HasPostalCode() bool { } // SetPostalCode gets a reference to the given string and assigns it to the PostalCode field. -func (o *Address2) SetPostalCode(v string) { +func (o *DeliveryAddress) SetPostalCode(v string) { o.PostalCode = &v } // GetStateOrProvince returns the StateOrProvince field value if set, zero value otherwise. -func (o *Address2) GetStateOrProvince() string { +func (o *DeliveryAddress) GetStateOrProvince() string { if o == nil || common.IsNil(o.StateOrProvince) { var ret string return ret @@ -248,7 +248,7 @@ func (o *Address2) GetStateOrProvince() string { // GetStateOrProvinceOk returns a tuple with the StateOrProvince field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Address2) GetStateOrProvinceOk() (*string, bool) { +func (o *DeliveryAddress) GetStateOrProvinceOk() (*string, bool) { if o == nil || common.IsNil(o.StateOrProvince) { return nil, false } @@ -256,7 +256,7 @@ func (o *Address2) GetStateOrProvinceOk() (*string, bool) { } // HasStateOrProvince returns a boolean if a field has been set. -func (o *Address2) HasStateOrProvince() bool { +func (o *DeliveryAddress) HasStateOrProvince() bool { if o != nil && !common.IsNil(o.StateOrProvince) { return true } @@ -265,11 +265,11 @@ func (o *Address2) HasStateOrProvince() bool { } // SetStateOrProvince gets a reference to the given string and assigns it to the StateOrProvince field. -func (o *Address2) SetStateOrProvince(v string) { +func (o *DeliveryAddress) SetStateOrProvince(v string) { o.StateOrProvince = &v } -func (o Address2) MarshalJSON() ([]byte, error) { +func (o DeliveryAddress) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { return []byte{}, err @@ -277,7 +277,7 @@ func (o Address2) MarshalJSON() ([]byte, error) { return json.Marshal(toSerialize) } -func (o Address2) ToMap() (map[string]interface{}, error) { +func (o DeliveryAddress) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if !common.IsNil(o.City) { toSerialize["city"] = o.City @@ -301,38 +301,38 @@ func (o Address2) ToMap() (map[string]interface{}, error) { return toSerialize, nil } -type NullableAddress2 struct { - value *Address2 +type NullableDeliveryAddress struct { + value *DeliveryAddress isSet bool } -func (v NullableAddress2) Get() *Address2 { +func (v NullableDeliveryAddress) Get() *DeliveryAddress { return v.value } -func (v *NullableAddress2) Set(val *Address2) { +func (v *NullableDeliveryAddress) Set(val *DeliveryAddress) { v.value = val v.isSet = true } -func (v NullableAddress2) IsSet() bool { +func (v NullableDeliveryAddress) IsSet() bool { return v.isSet } -func (v *NullableAddress2) Unset() { +func (v *NullableDeliveryAddress) Unset() { v.value = nil v.isSet = false } -func NewNullableAddress2(val *Address2) *NullableAddress2 { - return &NullableAddress2{value: val, isSet: true} +func NewNullableDeliveryAddress(val *DeliveryAddress) *NullableDeliveryAddress { + return &NullableDeliveryAddress{value: val, isSet: true} } -func (v NullableAddress2) MarshalJSON() ([]byte, error) { +func (v NullableDeliveryAddress) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } -func (v *NullableAddress2) UnmarshalJSON(src []byte) error { +func (v *NullableDeliveryAddress) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) } diff --git a/src/balanceplatform/model_delivery_contact.go b/src/balanceplatform/model_delivery_contact.go index 74eb42dd4..935ea44f0 100644 --- a/src/balanceplatform/model_delivery_contact.go +++ b/src/balanceplatform/model_delivery_contact.go @@ -19,7 +19,7 @@ var _ common.MappedNullable = &DeliveryContact{} // DeliveryContact struct for DeliveryContact type DeliveryContact struct { - Address Address2 `json:"address"` + Address DeliveryAddress `json:"address"` // The email address of the contact. Email *string `json:"email,omitempty"` // The full phone number of the contact provided as a single string. It will be handled as a landline phone. **Examples:** \"0031 6 11 22 33 44\", \"+316/1122-3344\", \"(0031) 611223344\" @@ -34,7 +34,7 @@ type DeliveryContact struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewDeliveryContact(address Address2, name Name) *DeliveryContact { +func NewDeliveryContact(address DeliveryAddress, name Name) *DeliveryContact { this := DeliveryContact{} this.Address = address this.Name = name @@ -50,9 +50,9 @@ func NewDeliveryContactWithDefaults() *DeliveryContact { } // GetAddress returns the Address field value -func (o *DeliveryContact) GetAddress() Address2 { +func (o *DeliveryContact) GetAddress() DeliveryAddress { if o == nil { - var ret Address2 + var ret DeliveryAddress return ret } @@ -61,7 +61,7 @@ func (o *DeliveryContact) GetAddress() Address2 { // GetAddressOk returns a tuple with the Address field value // and a boolean to check if the value has been set. -func (o *DeliveryContact) GetAddressOk() (*Address2, bool) { +func (o *DeliveryContact) GetAddressOk() (*DeliveryAddress, bool) { if o == nil { return nil, false } @@ -69,7 +69,7 @@ func (o *DeliveryContact) GetAddressOk() (*Address2, bool) { } // SetAddress sets field value -func (o *DeliveryContact) SetAddress(v Address2) { +func (o *DeliveryContact) SetAddress(v DeliveryAddress) { o.Address = v } diff --git a/src/balanceplatform/model_payment_instrument.go b/src/balanceplatform/model_payment_instrument.go index b33e34dc5..7309ca8f0 100644 --- a/src/balanceplatform/model_payment_instrument.go +++ b/src/balanceplatform/model_payment_instrument.go @@ -35,7 +35,7 @@ type PaymentInstrument struct { Reference *string `json:"reference,omitempty"` // The status of the payment instrument. If a status is not specified when creating a payment instrument, it is set to **active** by default. However, there can be exceptions for cards based on the `card.formFactor` and the `issuingCountryCode`. For example, when issuing physical cards in the US, the default status is **inactive**. Possible values: * **active**: The payment instrument is active and can be used to make payments. * **inactive**: The payment instrument is inactive and cannot be used to make payments. * **suspended**: The payment instrument is suspended, either because it was stolen or lost. * **closed**: The payment instrument is permanently closed. This action cannot be undone. Status *string `json:"status,omitempty"` - // The reason for updating the status of the payment instrument. Possible values: **lost**, **stolen**, **damaged**, **suspectedFraud**, **expired**, **endOfLife**, **accountClosure**, **other**. If the reason is **other**, you must also send the `statusComment` parameter describing the status change. + // The reason for the status of the payment instrument. Possible values: **accountClosure**, **damaged**, **endOfLife**, **expired**, **lost**, **stolen**, **suspectedFraud**, **transactionRule**, **other**. If the reason is **other**, you must also send the `statusComment` parameter describing the status change. StatusReason *string `json:"statusReason,omitempty"` // Type of payment instrument. Possible value: **card**, **bankAccount**. Type string `json:"type"` @@ -466,7 +466,7 @@ func (o *PaymentInstrument) isValidStatus() bool { return false } func (o *PaymentInstrument) isValidStatusReason() bool { - var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud"} + var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud", "transactionRule"} for _, allowed := range allowedEnumValues { if o.GetStatusReason() == allowed { return true diff --git a/src/balanceplatform/model_payment_instrument_info.go b/src/balanceplatform/model_payment_instrument_info.go index eb6154c41..867f84e0f 100644 --- a/src/balanceplatform/model_payment_instrument_info.go +++ b/src/balanceplatform/model_payment_instrument_info.go @@ -32,7 +32,7 @@ type PaymentInstrumentInfo struct { Reference *string `json:"reference,omitempty"` // The status of the payment instrument. If a status is not specified when creating a payment instrument, it is set to **active** by default. However, there can be exceptions for cards based on the `card.formFactor` and the `issuingCountryCode`. For example, when issuing physical cards in the US, the default status is **inactive**. Possible values: * **active**: The payment instrument is active and can be used to make payments. * **inactive**: The payment instrument is inactive and cannot be used to make payments. * **suspended**: The payment instrument is suspended, either because it was stolen or lost. * **closed**: The payment instrument is permanently closed. This action cannot be undone. Status *string `json:"status,omitempty"` - // The reason for updating the status of the payment instrument. Possible values: **lost**, **stolen**, **damaged**, **suspectedFraud**, **expired**, **endOfLife**, **accountClosure**, **other**. If the reason is **other**, you must also send the `statusComment` parameter describing the status change. + // The reason for the status of the payment instrument. Possible values: **accountClosure**, **damaged**, **endOfLife**, **expired**, **lost**, **stolen**, **suspectedFraud**, **transactionRule**, **other**. If the reason is **other**, you must also send the `statusComment` parameter describing the status change. StatusReason *string `json:"statusReason,omitempty"` // Type of payment instrument. Possible value: **card**, **bankAccount**. Type string `json:"type"` @@ -402,7 +402,7 @@ func (o *PaymentInstrumentInfo) isValidStatus() bool { return false } func (o *PaymentInstrumentInfo) isValidStatusReason() bool { - var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud"} + var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud", "transactionRule"} for _, allowed := range allowedEnumValues { if o.GetStatusReason() == allowed { return true diff --git a/src/balanceplatform/model_payment_instrument_update_request.go b/src/balanceplatform/model_payment_instrument_update_request.go index f7357aa73..8aaa87918 100644 --- a/src/balanceplatform/model_payment_instrument_update_request.go +++ b/src/balanceplatform/model_payment_instrument_update_request.go @@ -281,7 +281,7 @@ func (o *PaymentInstrumentUpdateRequest) isValidStatus() bool { return false } func (o *PaymentInstrumentUpdateRequest) isValidStatusReason() bool { - var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud"} + var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud", "transactionRule"} for _, allowed := range allowedEnumValues { if o.GetStatusReason() == allowed { return true diff --git a/src/balanceplatform/model_sweep_schedule.go b/src/balanceplatform/model_sweep_schedule.go index d2f4ecaa4..52b5654bc 100644 --- a/src/balanceplatform/model_sweep_schedule.go +++ b/src/balanceplatform/model_sweep_schedule.go @@ -19,7 +19,7 @@ var _ common.MappedNullable = &SweepSchedule{} // SweepSchedule struct for SweepSchedule type SweepSchedule struct { - // The schedule type. Possible values: * **cron**: push out funds based on a cron expression. * **daily**: push out funds daily at 07:00 AM CET. * **weekly**: push out funds every Monday at 07:00 AM CET. * **monthly**: push out funds every first of the month at 07:00 AM CET. * **balance**: pull in funds instantly if the balance is less than or equal to the `triggerAmount`. You can only use this for sweeps of `type` **pull** and when the source is a `merchantAccount` or `transferInstrument`. + // The schedule type. Possible values: * **cron**: push out funds based on a cron expression. * **daily**: push out funds daily at 07:00 AM CET. * **weekly**: push out funds every Monday at 07:00 AM CET. * **monthly**: push out funds every first of the month at 07:00 AM CET. * **balance**: pull in funds instantly if the balance is less than or equal to the `triggerAmount`. You can only use this for sweeps of `type` **pull** and when the source is a `merchantAccount` or `transferInstrument`.If the source is transferInstrument, merchant account identifier is still required, with which you want to process the transaction. Type *string `json:"type,omitempty"` } diff --git a/src/balanceplatform/model_update_payment_instrument.go b/src/balanceplatform/model_update_payment_instrument.go index 8b2c0a79c..1cc5dfeb2 100644 --- a/src/balanceplatform/model_update_payment_instrument.go +++ b/src/balanceplatform/model_update_payment_instrument.go @@ -37,7 +37,7 @@ type UpdatePaymentInstrument struct { Status *string `json:"status,omitempty"` // Comment for the status of the payment instrument. Required if `statusReason` is **other**. StatusComment *string `json:"statusComment,omitempty"` - // The reason for updating the status of the payment instrument. Possible values: **lost**, **stolen**, **damaged**, **suspectedFraud**, **expired**, **endOfLife**, **accountClosure**, **other**. If the reason is **other**, you must also send the `statusComment` parameter describing the status change. + // The reason for the status of the payment instrument. Possible values: **accountClosure**, **damaged**, **endOfLife**, **expired**, **lost**, **stolen**, **suspectedFraud**, **transactionRule**, **other**. If the reason is **other**, you must also send the `statusComment` parameter describing the status change. StatusReason *string `json:"statusReason,omitempty"` // Type of payment instrument. Possible value: **card**, **bankAccount**. Type string `json:"type"` @@ -503,7 +503,7 @@ func (o *UpdatePaymentInstrument) isValidStatus() bool { return false } func (o *UpdatePaymentInstrument) isValidStatusReason() bool { - var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud"} + var allowedEnumValues = []string{"accountClosure", "damaged", "endOfLife", "expired", "lost", "other", "stolen", "suspectedFraud", "transactionRule"} for _, allowed := range allowedEnumValues { if o.GetStatusReason() == allowed { return true diff --git a/src/management/api_account_company_level.go b/src/management/api_account_company_level.go index fa624cb5e..0e4a5bb3d 100644 --- a/src/management/api_account_company_level.go +++ b/src/management/api_account_company_level.go @@ -85,14 +85,18 @@ func (a *AccountCompanyLevelApi) GetCompanyAccount(ctx context.Context, r Accoun return *res, httpRes, decodeError } return *res, httpRes, serviceError - } else if httpRes.StatusCode == 403 { + } + + if httpRes.StatusCode == 403 { body, _ := ioutil.ReadAll(httpRes.Body) decodeError := json.Unmarshal([]byte(body), &serviceError) if decodeError != nil { return *res, httpRes, decodeError } return *res, httpRes, serviceError - } else if httpRes.StatusCode == 422 { + } + + if httpRes.StatusCode == 422 { body, _ := ioutil.ReadAll(httpRes.Body) decodeError := json.Unmarshal([]byte(body), &serviceError) if decodeError != nil { diff --git a/src/transfers/api_transactions.go b/src/transfers/api_transactions.go index 2056af0e9..3fda89faa 100644 --- a/src/transfers/api_transactions.go +++ b/src/transfers/api_transactions.go @@ -10,6 +10,8 @@ package transfers import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" "strings" @@ -141,6 +143,44 @@ func (a *TransactionsApi) GetAllTransactions(ctx context.Context, r Transactions headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } @@ -186,5 +226,43 @@ func (a *TransactionsApi) GetTransaction(ctx context.Context, r TransactionsApiG headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/transfers/api_transfers.go b/src/transfers/api_transfers.go index 4e6f1e486..e5b71474c 100644 --- a/src/transfers/api_transfers.go +++ b/src/transfers/api_transfers.go @@ -10,6 +10,8 @@ package transfers import ( "context" + "encoding/json" + "io/ioutil" "net/http" "net/url" @@ -65,5 +67,43 @@ func (a *TransfersApi) TransferFunds(ctx context.Context, r TransfersApiTransfer headerParams, ) + var serviceError common.RestServiceError + + if httpRes.StatusCode == 401 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 403 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 422 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + + if httpRes.StatusCode == 500 { + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return *res, httpRes, decodeError + } + return *res, httpRes, serviceError + } + return *res, httpRes, err } diff --git a/src/transfers/model_transfer.go b/src/transfers/model_transfer.go index 38a2000b0..535e2076b 100644 --- a/src/transfers/model_transfer.go +++ b/src/transfers/model_transfer.go @@ -44,7 +44,7 @@ type Transfer struct { Reason *string `json:"reason,omitempty"` // Your reference for the transfer, used internally within your platform. If you don't provide this in the request, Adyen generates a unique reference. Reference *string `json:"reference,omitempty"` - // A reference that is sent to the recipient. This reference is also sent in all notification webhooks related to the transfer, so you can use it to track statuses for both the source and recipient of funds. Supported characters: **a-z**, **A-Z**, **0-9**. The maximum length depends on the `category`. - **internal**: 80 characters - **bank**: 35 characters when transferring to an IBAN, 15 characters for others. + // A reference that is sent to the recipient. This reference is also sent in all webhooks related to the transfer, so you can use it to track statuses for both the source and recipient of funds. Supported characters: **a-z**, **A-Z**, **0-9**. The maximum length depends on the `category`. - **internal**: 80 characters - **bank**: 35 characters when transferring to an IBAN, 15 characters for others. ReferenceForBeneficiary *string `json:"referenceForBeneficiary,omitempty"` // The result of the transfer. For example, **authorised**, **refused**, or **error**. Status string `json:"status"` diff --git a/src/transfers/model_transfer_info.go b/src/transfers/model_transfer_info.go index c199e1db8..0c40da45f 100644 --- a/src/transfers/model_transfer_info.go +++ b/src/transfers/model_transfer_info.go @@ -35,7 +35,7 @@ type TransferInfo struct { Priority *string `json:"priority,omitempty"` // Your reference for the transfer, used internally within your platform. If you don't provide this in the request, Adyen generates a unique reference. Reference *string `json:"reference,omitempty"` - // A reference that is sent to the recipient. This reference is also sent in all notification webhooks related to the transfer, so you can use it to track statuses for both the source and recipient of funds. Supported characters: **a-z**, **A-Z**, **0-9**. The maximum length depends on the `category`. - **internal**: 80 characters - **bank**: 35 characters when transferring to an IBAN, 15 characters for others. + // A reference that is sent to the recipient. This reference is also sent in all webhooks related to the transfer, so you can use it to track statuses for both the source and recipient of funds. Supported characters: **a-z**, **A-Z**, **0-9**. The maximum length depends on the `category`. - **internal**: 80 characters - **bank**: 35 characters when transferring to an IBAN, 15 characters for others. ReferenceForBeneficiary *string `json:"referenceForBeneficiary,omitempty"` UltimateParty *UltimatePartyIdentification `json:"ultimateParty,omitempty"` } diff --git a/templates/custom/api.mustache b/templates/custom/api.mustache index c1002aafc..696d4c7dc 100644 --- a/templates/custom/api.mustache +++ b/templates/custom/api.mustache @@ -109,6 +109,47 @@ func (a *{{{classname}}}) {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecas headerParams, ) +{{#hasRestServiceError}} +{{#responses}} + {{#-first}}var serviceError common.RestServiceError{{/-first}} + {{#dataType}} + + {{^is1xx}} + {{^is2xx}} + {{#range}} + + {{#is3xx}} + + if httpRes.StatusCode >= 300 && httpRes.StatusCode < 400 { + {{/is3xx}} + {{#is4xx}} + if httpRes.StatusCode >= 400 && httpRes.StatusCode < 500 { + {{/is4xx}} + {{#is5xx}} + if httpRes.StatusCode >= 500 { + {{/is5xx}} + {{/range}} + {{^range}} + + {{^wildcard}} + if httpRes.StatusCode == {{{code}}} { + {{/wildcard}} + {{/range}} + body, _ := ioutil.ReadAll(httpRes.Body) + decodeError := json.Unmarshal([]byte(body), &serviceError) + if decodeError != nil { + return {{#returnType}}*res, {{/returnType}}httpRes, decodeError + } + return {{#returnType}}*res, {{/returnType}}httpRes, serviceError + {{^wildcard}} + } + {{/wildcard}} + {{/is2xx}} + {{/is1xx}} + {{/dataType}} +{{/responses}} +{{/hasRestServiceError}} + return {{#returnType}}*res, {{/returnType}}httpRes, err } diff --git a/templates/rest/api.mustache b/templates/rest/api.mustache deleted file mode 100644 index 33836f943..000000000 --- a/templates/rest/api.mustache +++ /dev/null @@ -1,155 +0,0 @@ -{{>partial_header}} -{{#lambda.lowercase}} -package {{packageName}} -{{/lambda.lowercase}} - -{{#operations}} -import ( - "context" - "net/http" - "net/url" - "strings" - "github.com/adyen/adyen-go-api-library/v7/src/common" -) - -// {{classname}} service -type {{classname}} common.Service -{{#operation}} - -// All parameters accepted by {{{classname}}}.{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}} -type {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input struct { -{{#allParams}} - {{paramName}} {{^isPathParam}}{{^isFile}}*{{/isFile}}{{/isPathParam}}{{{dataType}}} -{{/allParams}} -} - -{{#allParams}} -{{^isPathParam}} -{{#description}} -// {{.}} -{{/description}} -{{#isDeprecated}} -// Deprecated -{{/isDeprecated}} -func (r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input) {{vendorExtensions.x-export-param-name}}({{paramName}} {{{dataType}}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input { - r.{{paramName}} = {{^isFile}}&{{/isFile}}{{paramName}} - return r -} - -{{/isPathParam}} -{{/allParams}} - -/* -Prepare a request for {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}} -{{#pathParams}} -@param {{paramName}}{{#description}} {{{.}}}{{/description}}{{/pathParams}} -@return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input -{{#isDeprecated}} - -Deprecated -{{/isDeprecated}} -*/ -func (a *{{{classname}}}) {{{nickname}}}Input({{#pathParams}}{{paramName}} {{{dataType}}}{{^-last}}, {{/-last}}{{/pathParams}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input { - return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input{ - {{#pathParams}} - {{paramName}}: {{paramName}}, - {{/pathParams}} - } -} - -/* -{{operationId}} {{{summary}}}{{^summary}}Method for {{operationId}}{{/summary}} -{{#notes}} - -{{{unescapedNotes}}} -{{/notes}} - -@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). -@param r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input - Request parameters, see {{{nickname}}}Input -@return {{{returnType}}}, *http.Response, error -{{#isDeprecated}} - - Deprecated -{{/isDeprecated}} -*/ -func (a *{{{classname}}}) {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}(ctx context.Context, r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Input) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) { - {{#returnType}} - res := &{{{returnType}}}{} - {{/returnType}} - {{^returnType}} - var res interface{} - {{/returnType}} - path := "{{{path}}}"{{#pathParams}} - path = strings.Replace(path, "{"+"{{baseName}}"+"}", url.PathEscape(common.ParameterValueToString(r.{{paramName}}, "{{paramName}}")), -1){{/pathParams}} - queryParams := url.Values{} - headerParams := make(map[string]string) -{{#queryParams}} - if r.{{paramName}} != nil { - common.ParameterAddToQuery(queryParams, "{{baseName}}", r.{{paramName}}, "") - } -{{/queryParams}} -{{#headerParams}} - {{#required}} - common.ParameterAddToHeaderOrQuery(headerParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}") - {{/required}} - {{^required}} - if r.{{paramName}} != nil { - common.ParameterAddToHeaderOrQuery(headerParams, "{{baseName}}", r.{{paramName}}, "{{collectionFormat}}") - } - {{/required}} -{{/headerParams}} - httpRes, err := common.SendAPIRequest( - ctx, - a.Client, - {{#bodyParams}}r.{{paramName}}{{/bodyParams}}{{^bodyParams}}nil{{/bodyParams}}, - res, - http.Method{{httpMethod}}, - a.BasePath()+path, - queryParams, - headerParams, - ) - -var serviceError common.RestServiceError -{{#responses}} - {{#dataType}} - - {{^is1xx}} - {{^is2xx}} - {{#range}} - - {{#is3xx}} - - if httpRes.StatusCode >= 300 && httpRes.StatusCode < 400 { - {{/is3xx}} - {{#is4xx}} - if httpRes.StatusCode >= 400 && httpRes.StatusCode < 500 { - {{/is4xx}} - {{#is5xx}} - if httpRes.StatusCode >= 500 { - {{/is5xx}} - {{/range}} - {{^range}} - - {{^wildcard}} - if httpRes.StatusCode == {{{code}}} { - {{/wildcard}} - {{/range}} - body, _ := ioutil.ReadAll(httpRes.Body) - decodeError := json.Unmarshal([]byte(body), &serviceError) - if decodeError != nil { - return {{#returnType}}*res, {{/returnType}}httpRes, decodeError - } - return {{#returnType}}*res, {{/returnType}}httpRes, serviceError - {{^wildcard}} - } - {{/wildcard}} - {{/is2xx}} - {{/is1xx}} - {{/dataType}} -{{/responses}} - - return {{#returnType}}*res, {{/returnType}}httpRes, err -} - -{{/operation}} -{{/operations}} diff --git a/templates/rest/client.mustache b/templates/rest/client.mustache deleted file mode 100644 index 1e364fb14..000000000 --- a/templates/rest/client.mustache +++ /dev/null @@ -1,42 +0,0 @@ -{{>partial_header}} -package {{packageName}} - -import ( - "github.com/adyen/adyen-go-api-library/v7/src/common" -) - -// APIClient manages communication with the {{appName}} API v{{version}} -// In most cases there should be only one, shared, APIClient. -type APIClient struct { - common common.Service // Reuse a single struct instead of allocating one for each service on the heap. - - // API Services -{{#apiInfo}} -{{#apis}} -{{#operations}} - - {{classname}} {{#generateInterfaces}}{{classname}}{{/generateInterfaces}}{{^generateInterfaces}}*{{classname}}{{/generateInterfaces}} -{{/operations}} -{{/apis}} -{{/apiInfo}} -} - -// NewAPIClient creates a new API client. -func NewAPIClient(client *common.Client) *APIClient { - c := &APIClient{} - c.common.Client = client - c.common.BasePath = func() string { - return client.Cfg.{{{serviceName}}}Endpoint - } - -{{#apiInfo}} - // API Services -{{#apis}} -{{#operations}} - c.{{classname}} = (*{{classname}})(&c.common) -{{/operations}} -{{/apis}} -{{/apiInfo}} - - return c -} \ No newline at end of file diff --git a/templates/rest/model.mustache b/templates/rest/model.mustache deleted file mode 100644 index 2b0fb4d0a..000000000 --- a/templates/rest/model.mustache +++ /dev/null @@ -1,21 +0,0 @@ -{{>partial_header}} -package {{packageName}} - -{{#models}} -import ( - "encoding/json" - "github.com/adyen/adyen-go-api-library/v7/src/common" -{{#imports}} - "{{import}}" -{{/imports}} -) - -{{#model}} -{{#isEnum}} -{{>model_enum}} -{{/isEnum}} -{{^isEnum}} -{{#oneOf}}{{#-first}}{{>model_oneof}}{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}{{>model_anyof}}{{/-first}}{{/anyOf}}{{^anyOf}}{{>model_simple}}{{/anyOf}}{{/oneOf}} -{{/isEnum}} -{{/model}} -{{/models}} diff --git a/templates/rest/model_oneof.mustache b/templates/rest/model_oneof.mustache deleted file mode 100644 index 5615a2756..000000000 --- a/templates/rest/model_oneof.mustache +++ /dev/null @@ -1,144 +0,0 @@ -// {{classname}} - {{{description}}}{{^description}}struct for {{{classname}}}{{/description}} -type {{classname}} struct { - {{#oneOf}} - {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} *{{{.}}} - {{/oneOf}} -} - -{{#oneOf}} -// {{{.}}}As{{classname}} is a convenience function that returns {{{.}}} wrapped in {{classname}} -func {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}As{{classname}}(v *{{{.}}}) {{classname}} { - return {{classname}}{ - {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}: v, - } -} - -{{/oneOf}} - -// Unmarshal JSON data into one of the pointers in the struct -func (dst *{{classname}}) UnmarshalJSON(data []byte) error { - var err error - {{#isNullable}} - // this object is nullable so check if the payload is null or empty string - if string(data) == "" || string(data) == "{}" { - return nil - } - - {{/isNullable}} - {{#useOneOfDiscriminatorLookup}} - {{#discriminator}} - {{#mappedModels}} - {{#-first}} - // use discriminator value to speed up the lookup - var jsonDict map[string]interface{} - err = newStrictDecoder(data).Decode(&jsonDict) - if err != nil { - return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup") - } - - {{/-first}} - // check if the discriminator value is '{{{mappingName}}}' - if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" { - // try to unmarshal JSON data into {{{modelName}}} - err = json.Unmarshal(data, &dst.{{{modelName}}}) - if err == nil { - return nil // data stored in dst.{{{modelName}}}, return on the first match - } else { - dst.{{{modelName}}} = nil - return fmt.Errorf("failed to unmarshal {{classname}} as {{{modelName}}}: %s", err.Error()) - } - } - - {{/mappedModels}} - return nil - {{/discriminator}} - {{^discriminator}} - match := 0 - {{#oneOf}} - // try to unmarshal data into {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} - err = json.Unmarshal(data, &dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) - if err == nil { - json{{{.}}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) - if string(json{{{.}}}) == "{}" || !dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}.isValidType() { // empty struct - dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil - } else { - match++ - } - } else { - dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil - } - - {{/oneOf}} - if match > 1 { // more than 1 match - // reset to nil - {{#oneOf}} - dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil - {{/oneOf}} - - return fmt.Errorf("data matches more than one schema in oneOf({{classname}})") - } else if match == 1 { - return nil // exactly one match - } else { // no match - return fmt.Errorf("data failed to match schemas in oneOf({{classname}})") - } - {{/discriminator}} - {{/useOneOfDiscriminatorLookup}} - {{^useOneOfDiscriminatorLookup}} - match := 0 - {{#oneOf}} - // try to unmarshal data into {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} - err = newStrictDecoder(data).Decode(&dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) - if err == nil { - json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) - if string(json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) == "{}" { // empty struct - dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil - } else { - match++ - } - } else { - dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil - } - - {{/oneOf}} - if match > 1 { // more than 1 match - // reset to nil - {{#oneOf}} - dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil - {{/oneOf}} - - return fmt.Errorf("data matches more than one schema in oneOf({{classname}})") - } else if match == 1 { - return nil // exactly one match - } else { // no match - return fmt.Errorf("data failed to match schemas in oneOf({{classname}})") - } - {{/useOneOfDiscriminatorLookup}} -} - -// Marshal data from the first non-nil pointers in the struct to JSON -func (src {{classname}}) MarshalJSON() ([]byte, error) { -{{#oneOf}} - if src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil { - return json.Marshal(&src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) - } - -{{/oneOf}} - return nil, nil // no data in oneOf schemas -} - -// Get the actual instance -func (obj *{{classname}}) GetActualInstance() (interface{}) { - if obj == nil { - return nil - } -{{#oneOf}} - if obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil { - return obj.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} - } - -{{/oneOf}} - // all schemas are nil - return nil -} - -{{>nullable_model}} diff --git a/templates/rest/model_simple.mustache b/templates/rest/model_simple.mustache deleted file mode 100644 index 5cea1a27b..000000000 --- a/templates/rest/model_simple.mustache +++ /dev/null @@ -1,466 +0,0 @@ -// checks if the {{classname}} type satisfies the MappedNullable interface at compile time -var _ common.MappedNullable = &{{classname}}{} - -// {{classname}} {{{description}}}{{^description}}struct for {{{classname}}}{{/description}} -type {{classname}} struct { -{{#parent}} -{{^isMap}} -{{^isArray}} - {{{parent}}} -{{/isArray}} -{{/isMap}} -{{#isArray}} - Items {{{parent}}} -{{/isArray}} -{{/parent}} -{{#vars}} -{{^-first}} -{{/-first}} -{{#description}} - // {{{.}}} -{{/description}} -{{#deprecated}} - // Deprecated -{{/deprecated}} - {{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}` -{{/vars}} -{{#isAdditionalPropertiesTrue}} - AdditionalProperties map[string]interface{} -{{/isAdditionalPropertiesTrue}} -} - -{{#isAdditionalPropertiesTrue}} -type _{{{classname}}} {{{classname}}} - -{{/isAdditionalPropertiesTrue}} -// New{{classname}} instantiates a new {{classname}} object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} {{dataType}}{{^-last}}, {{/-last}}{{/requiredVars}}) *{{classname}} { - this := {{classname}}{} -{{#allVars}} -{{#required}} - this.{{name}} = {{nameInCamelCase}} -{{/required}} -{{^required}} -{{#defaultValue}} -{{^vendorExtensions.x-golang-is-container}} -{{^isReadOnly}} -{{#isNullable}} - var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}} - this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}}) -{{/isNullable}} -{{^isNullable}} - var {{nameInCamelCase}} {{{dataType}}} = {{{.}}} - this.{{name}} = &{{nameInCamelCase}} -{{/isNullable}} -{{/isReadOnly}} -{{/vendorExtensions.x-golang-is-container}} -{{/defaultValue}} -{{/required}} -{{/allVars}} - return &this -} - -// New{{classname}}WithDefaults instantiates a new {{classname}} object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func New{{classname}}WithDefaults() *{{classname}} { - this := {{classname}}{} -{{#vars}} -{{#defaultValue}} -{{^vendorExtensions.x-golang-is-container}} -{{^isReadOnly}} -{{#isNullable}} -{{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}} - var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}} - this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}}) -{{/isNullable}} -{{^isNullable}} - var {{nameInCamelCase}} {{{dataType}}} = {{{.}}} - this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}} -{{/isNullable}} -{{/isReadOnly}} -{{/vendorExtensions.x-golang-is-container}} -{{/defaultValue}} -{{/vars}} - return &this -} - -{{#vars}} -{{#required}} -// Get{{name}} returns the {{name}} field value -{{#isNullable}} -// If the value is explicit nil, the zero value for {{vendorExtensions.x-go-base-type}} will be returned -{{/isNullable}} -{{#deprecated}} -// Deprecated -{{/deprecated}} -func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} { - if o == nil{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { - var ret {{vendorExtensions.x-go-base-type}} - return ret - } - -{{#isNullable}} -{{#vendorExtensions.x-golang-is-container}} - return o.{{name}} -{{/vendorExtensions.x-golang-is-container}} -{{^vendorExtensions.x-golang-is-container}} - return *o.{{name}}.Get() -{{/vendorExtensions.x-golang-is-container}} -{{/isNullable}} -{{^isNullable}} - return o.{{name}} -{{/isNullable}} -} - -// Get{{name}}Ok returns a tuple with the {{name}} field value -// and a boolean to check if the value has been set. -{{#isNullable}} -// NOTE: If the value is an explicit nil, `nil, true` will be returned -{{/isNullable}} -{{#deprecated}} -// Deprecated -{{/deprecated}} -func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) { - if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || common.IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { -{{^isFreeFormObject}} - return nil, false - {{/isFreeFormObject}} - {{#isFreeFormObject}} - return {{vendorExtensions.x-go-base-type}}{}, false - {{/isFreeFormObject}} - } -{{#isNullable}} -{{#vendorExtensions.x-golang-is-container}} - return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true -{{/vendorExtensions.x-golang-is-container}} -{{^vendorExtensions.x-golang-is-container}} - return o.{{name}}.Get(), o.{{name}}.IsSet() -{{/vendorExtensions.x-golang-is-container}} -{{/isNullable}} -{{^isNullable}} - return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true -{{/isNullable}} -} - -// Set{{name}} sets field value -{{#deprecated}} -// Deprecated -{{/deprecated}} -func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) { -{{#isNullable}} -{{#vendorExtensions.x-golang-is-container}} - o.{{name}} = v -{{/vendorExtensions.x-golang-is-container}} -{{^vendorExtensions.x-golang-is-container}} - o.{{name}}.Set(&v) -{{/vendorExtensions.x-golang-is-container}} -{{/isNullable}} -{{^isNullable}} - o.{{name}} = v -{{/isNullable}} -} - -{{/required}} -{{^required}} -// Get{{name}} returns the {{name}} field value if set, zero value otherwise{{#isNullable}} (both if not set or set to explicit null){{/isNullable}}. -{{#deprecated}} -// Deprecated -{{/deprecated}} -func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} { - if o == nil{{^isNullable}} || common.IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || common.IsNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { - var ret {{vendorExtensions.x-go-base-type}} - return ret - } -{{#isNullable}} -{{#vendorExtensions.x-golang-is-container}} - return o.{{name}} -{{/vendorExtensions.x-golang-is-container}} -{{^vendorExtensions.x-golang-is-container}} - return *o.{{name}}.Get() -{{/vendorExtensions.x-golang-is-container}} -{{/isNullable}} -{{^isNullable}} - return {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}o.{{name}} -{{/isNullable}} -} - -// Get{{name}}Ok returns a tuple with the {{name}} field value if set, nil otherwise -// and a boolean to check if the value has been set. -{{#isNullable}} -// NOTE: If the value is an explicit nil, `nil, true` will be returned -{{/isNullable}} -{{#deprecated}} -// Deprecated -{{/deprecated}} -func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) { - if o == nil{{^isNullable}} || common.IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || common.IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { - {{^isFreeFormObject}} - return nil, false - {{/isFreeFormObject}} - {{#isFreeFormObject}} - return {{vendorExtensions.x-go-base-type}}{}, false - {{/isFreeFormObject}} - } -{{#isNullable}} -{{#vendorExtensions.x-golang-is-container}} - return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true -{{/vendorExtensions.x-golang-is-container}} -{{^vendorExtensions.x-golang-is-container}} - return o.{{name}}.Get(), o.{{name}}.IsSet() -{{/vendorExtensions.x-golang-is-container}} -{{/isNullable}} -{{^isNullable}} - return o.{{name}}, true -{{/isNullable}} -} - -// Has{{name}} returns a boolean if a field has been set. -func (o *{{classname}}) Has{{name}}() bool { - if o != nil && {{^isNullable}}!common.IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}common.IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} { - return true - } - - return false -} - -// Set{{name}} gets a reference to the given {{dataType}} and assigns it to the {{name}} field. -{{#deprecated}} -// Deprecated -{{/deprecated}} -func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) { -{{#isNullable}} -{{#vendorExtensions.x-golang-is-container}} - o.{{name}} = v -{{/vendorExtensions.x-golang-is-container}} -{{^vendorExtensions.x-golang-is-container}} - o.{{name}}.Set({{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}v) -{{/vendorExtensions.x-golang-is-container}} -{{/isNullable}} -{{^isNullable}} - o.{{name}} = {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}v -{{/isNullable}} -} -{{#isNullable}} -{{^vendorExtensions.x-golang-is-container}} -// Set{{name}}Nil sets the value for {{name}} to be an explicit nil -func (o *{{classname}}) Set{{name}}Nil() { - o.{{name}}.Set(nil) -} - -// Unset{{name}} ensures that no value is present for {{name}}, not even an explicit nil -func (o *{{classname}}) Unset{{name}}() { - o.{{name}}.Unset() -} -{{/vendorExtensions.x-golang-is-container}} -{{/isNullable}} - -{{/required}} -{{/vars}} -func (o {{classname}}) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o {{classname}}) ToMap() (map[string]interface{}, error) { - toSerialize := {{#isArray}}make([]interface{}, len(o.Items)){{/isArray}}{{^isArray}}map[string]interface{}{}{{/isArray}} - {{#parent}} - {{^isMap}} - {{^isArray}} - serialized{{parent}}, err{{parent}} := json.Marshal(o.{{parent}}) - if err{{parent}} != nil { - return map[string]interface{}{}, err{{parent}} - } - err{{parent}} = json.Unmarshal([]byte(serialized{{parent}}), &toSerialize) - if err{{parent}} != nil { - return map[string]interface{}{}, err{{parent}} - } - {{/isArray}} - {{/isMap}} - {{#isArray}} - for i, item := range o.Items { - toSerialize[i] = item - } - {{/isArray}} - {{/parent}} - {{#vars}} - {{! if argument is nullable, only serialize it if it is set}} - {{#isNullable}} - {{#vendorExtensions.x-golang-is-container}} - {{! support for container fields is not ideal at this point because of lack of Nullable* types}} - if o.{{name}} != nil { - toSerialize["{{baseName}}"] = o.{{name}} - } - {{/vendorExtensions.x-golang-is-container}} - {{^vendorExtensions.x-golang-is-container}} - {{#required}} - toSerialize["{{baseName}}"] = o.{{name}}.Get() - {{/required}} - {{^required}} - if o.{{name}}.IsSet() { - toSerialize["{{baseName}}"] = o.{{name}}.Get() - } - {{/required}} - {{/vendorExtensions.x-golang-is-container}} - {{/isNullable}} - {{! if argument is not nullable, don't set it if it is nil}} - {{^isNullable}} - {{#required}} - toSerialize["{{baseName}}"] = o.{{name}} - {{/required}} - {{^required}} - if !common.IsNil(o.{{name}}) { - toSerialize["{{baseName}}"] = o.{{name}} - } - {{/required}} - {{/isNullable}} - {{/vars}} - {{#isAdditionalPropertiesTrue}} - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - {{/isAdditionalPropertiesTrue}} - return toSerialize, nil -} - -{{#isAdditionalPropertiesTrue}} -func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) { -{{#parent}} -{{^isMap}} - type {{classname}}WithoutEmbeddedStruct struct { - {{#vars}} - {{^-first}} - {{/-first}} - {{#description}} - // {{{.}}} - {{/description}} - {{#deprecated}} - // Deprecated - {{/deprecated}} - {{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}` - {{/vars}} - } - - var{{{classname}}}WithoutEmbeddedStruct := {{{classname}}}WithoutEmbeddedStruct{} - - err = json.Unmarshal(bytes, &var{{{classname}}}WithoutEmbeddedStruct) - if err == nil { - var{{{classname}}} := _{{{classname}}}{} - {{#vars}} - var{{{classname}}}.{{{name}}} = var{{{classname}}}WithoutEmbeddedStruct.{{{name}}} - {{/vars}} - *o = {{{classname}}}(var{{{classname}}}) - } else { - return err - } - - var{{{classname}}} := _{{{classname}}}{} - - err = json.Unmarshal(bytes, &var{{{classname}}}) - if err == nil { - o.{{{parent}}} = var{{{classname}}}.{{{parent}}} - } else { - return err - } - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(bytes, &additionalProperties); err == nil { - {{#vars}} - delete(additionalProperties, "{{{baseName}}}") - {{/vars}} - - // remove fields from embedded structs - reflect{{{parent}}} := reflect.ValueOf(o.{{{parent}}}) - for i := 0; i < reflect{{{parent}}}.Type().NumField(); i++ { - t := reflect{{{parent}}}.Type().Field(i) - - if jsonTag := t.Tag.Get("json"); jsonTag != "" { - fieldName := "" - if commaIdx := strings.Index(jsonTag, ","); commaIdx > 0 { - fieldName = jsonTag[:commaIdx] - } else { - fieldName = jsonTag - } - if fieldName != "AdditionalProperties" { - delete(additionalProperties, fieldName) - } - } - } - - o.AdditionalProperties = additionalProperties - } - - return err -{{/isMap}} -{{#isMap}} - var{{{classname}}} := _{{{classname}}}{} - - if err = json.Unmarshal(bytes, &var{{{classname}}}); err == nil { - *o = {{{classname}}}(var{{{classname}}}) - } - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(bytes, &additionalProperties); err == nil { - {{#vars}} - delete(additionalProperties, "{{{baseName}}}") - {{/vars}} - o.AdditionalProperties = additionalProperties - } - - return err -{{/isMap}} -{{/parent}} -{{^parent}} - var{{{classname}}} := _{{{classname}}}{} - - if err = json.Unmarshal(bytes, &var{{{classname}}}); err == nil { - *o = {{{classname}}}(var{{{classname}}}) - } - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(bytes, &additionalProperties); err == nil { - {{#vars}} - delete(additionalProperties, "{{{baseName}}}") - {{/vars}} - o.AdditionalProperties = additionalProperties - } - - return err -{{/parent}} -} - -{{/isAdditionalPropertiesTrue}} -{{#isArray}} -func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) { - return json.Unmarshal(bytes, &o.Items) -} - -{{/isArray}} -{{>nullable_model}} - -{{#vars}} -{{#allowableValues}} -{{#isString}} -func (o *{{classname}}) isValid{{name}}() bool { - var allowedEnumValues = []string{ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} } - for _, allowed := range allowedEnumValues { - if o.Get{{name}}() == allowed { - return true - } - } - return false -} -{{/isString}} -{{/allowableValues}} -{{/vars}} diff --git a/templates/rest/partial_header.mustache b/templates/rest/partial_header.mustache deleted file mode 100644 index 98cca0d25..000000000 --- a/templates/rest/partial_header.mustache +++ /dev/null @@ -1,11 +0,0 @@ -/* -{{#appName}} -{{{.}}} - -{{/appName}} -{{#version}} -API version: {{{.}}} -{{/version}} -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/tests/balanceplatform_test.go b/tests/balanceplatform_test.go index 87e49be86..41ab239e4 100644 --- a/tests/balanceplatform_test.go +++ b/tests/balanceplatform_test.go @@ -2,7 +2,6 @@ package tests import ( "context" - "encoding/json" "github.com/adyen/adyen-go-api-library/v7/src/adyen" "github.com/adyen/adyen-go-api-library/v7/src/balanceplatform" "github.com/adyen/adyen-go-api-library/v7/src/common" @@ -110,16 +109,14 @@ func Test_BalancePlatform(t *testing.T) { body := balanceplatform.NewPaymentInstrumentUpdateRequest() body.SetBalanceAccountId("BA32272223222B5CM82WL892M") req.PaymentInstrumentUpdateRequest(*body) - _, _, err := service.PaymentInstrumentsApi.UpdatePaymentInstrument(context.Background(), req) - apiError := err.(common.APIError) - assert.Equal(t, float64(422), apiError.Status) - assert.Equal(t, "30_112", apiError.Code) + _, _, err := service.PaymentInstrumentsApi.UpdatePaymentInstrument(context.Background(), req) - var restError balanceplatform.RestServiceError - _ = json.Unmarshal(apiError.RawBody, &restError) - assert.Equal(t, "Entity was not found", restError.Title) - assert.Equal(t, "Payment instrument not found", restError.Detail) + serviceError := err.(common.RestServiceError) + assert.Equal(t, int32(422), serviceError.Status) + assert.Equal(t, "30_112", serviceError.GetErrorCode()) + assert.Equal(t, "Entity was not found", serviceError.GetTitle()) + assert.Equal(t, "Payment instrument not found", serviceError.GetDetail()) }) t.Run("Delete a sweep", func(t *testing.T) { diff --git a/tests/transfers_test.go b/tests/transfers_test.go index 6c2ea44a2..b2733de81 100644 --- a/tests/transfers_test.go +++ b/tests/transfers_test.go @@ -92,5 +92,10 @@ func Test_Transfers(t *testing.T) { assert.Equal(t, 403, httpRes.StatusCode) require.NotNil(t, err) + serviceError := err.(common.RestServiceError) + assert.Equal(t, int32(403), serviceError.Status) + assert.Equal(t, "00_403", serviceError.GetErrorCode()) + assert.Equal(t, "Forbidden", serviceError.GetTitle()) + assert.Equal(t, "Not allowed", serviceError.GetDetail()) }) }