diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index aa7e05fd4..19da26a8b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e4aac361d..c2344cf83 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - uses: actions/setup-go@v4 with: diff --git a/.github/workflows/models.yml b/.github/workflows/models.yml index a9cd6a82e..178466ac1 100644 --- a/.github/workflows/models.yml +++ b/.github/workflows/models.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest name: Generate Models steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - uses: actions/setup-go@v4 with: go-version: 1.18 diff --git a/src/balanceplatform/api_account_holders.go b/src/balanceplatform/api_account_holders.go index 727cf3310..df253f605 100644 --- a/src/balanceplatform/api_account_holders.go +++ b/src/balanceplatform/api_account_holders.go @@ -68,6 +68,10 @@ func (a *AccountHoldersApi) CreateAccountHolder(ctx context.Context, r AccountHo headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -160,6 +164,10 @@ func (a *AccountHoldersApi) GetAccountHolder(ctx context.Context, r AccountHolde headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -274,6 +282,10 @@ func (a *AccountHoldersApi) GetAllBalanceAccountsOfAccountHolder(ctx context.Con headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -372,6 +384,10 @@ func (a *AccountHoldersApi) UpdateAccountHolder(ctx context.Context, r AccountHo headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/balanceplatform/api_balance_accounts.go b/src/balanceplatform/api_balance_accounts.go index 9b01a4ef3..3b72cf4e0 100644 --- a/src/balanceplatform/api_balance_accounts.go +++ b/src/balanceplatform/api_balance_accounts.go @@ -66,6 +66,10 @@ func (a *BalanceAccountsApi) CreateBalanceAccount(ctx context.Context, r Balance headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -166,6 +170,10 @@ func (a *BalanceAccountsApi) CreateSweep(ctx context.Context, r BalanceAccountsA headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -261,6 +269,10 @@ func (a *BalanceAccountsApi) DeleteSweep(ctx context.Context, r BalanceAccountsA headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -375,6 +387,10 @@ func (a *BalanceAccountsApi) GetAllPaymentInstrumentsForBalanceAccount(ctx conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -489,6 +505,10 @@ func (a *BalanceAccountsApi) GetAllSweepsForBalanceAccount(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -581,6 +601,10 @@ func (a *BalanceAccountsApi) GetBalanceAccount(ctx context.Context, r BalanceAcc headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -676,6 +700,10 @@ func (a *BalanceAccountsApi) GetSweep(ctx context.Context, r BalanceAccountsApiG headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -774,6 +802,10 @@ func (a *BalanceAccountsApi) UpdateBalanceAccount(ctx context.Context, r Balance headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -875,6 +907,10 @@ func (a *BalanceAccountsApi) UpdateSweep(ctx context.Context, r BalanceAccountsA headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/balanceplatform/api_bank_account_validation.go b/src/balanceplatform/api_bank_account_validation.go index a2bfce539..a9146efd1 100644 --- a/src/balanceplatform/api_bank_account_validation.go +++ b/src/balanceplatform/api_bank_account_validation.go @@ -65,6 +65,10 @@ func (a *BankAccountValidationApi) ValidateBankAccountIdentification(ctx context headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 401 { diff --git a/src/balanceplatform/api_grant_accounts.go b/src/balanceplatform/api_grant_accounts.go index 7d71304d3..6a5889277 100644 --- a/src/balanceplatform/api_grant_accounts.go +++ b/src/balanceplatform/api_grant_accounts.go @@ -64,6 +64,10 @@ func (a *GrantAccountsApi) GetGrantAccount(ctx context.Context, r GrantAccountsA headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/balanceplatform/api_grant_offers.go b/src/balanceplatform/api_grant_offers.go index d6f48a1f2..c7b7d157d 100644 --- a/src/balanceplatform/api_grant_offers.go +++ b/src/balanceplatform/api_grant_offers.go @@ -70,6 +70,10 @@ func (a *GrantOffersApi) GetAllAvailableGrantOffers(ctx context.Context, r Grant headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -162,6 +166,10 @@ func (a *GrantOffersApi) GetGrantOffer(ctx context.Context, r GrantOffersApiGetG headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/balanceplatform/api_network_tokens.go b/src/balanceplatform/api_network_tokens.go index 81243bcb1..395d21c79 100644 --- a/src/balanceplatform/api_network_tokens.go +++ b/src/balanceplatform/api_network_tokens.go @@ -64,6 +64,10 @@ func (a *NetworkTokensApi) GetNetworkToken(ctx context.Context, r NetworkTokensA headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 401 { @@ -153,6 +157,10 @@ func (a *NetworkTokensApi) UpdateNetworkToken(ctx context.Context, r NetworkToke headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 401 { diff --git a/src/balanceplatform/api_payment_instrument_groups.go b/src/balanceplatform/api_payment_instrument_groups.go index 222c0d46d..605ee8038 100644 --- a/src/balanceplatform/api_payment_instrument_groups.go +++ b/src/balanceplatform/api_payment_instrument_groups.go @@ -66,6 +66,10 @@ func (a *PaymentInstrumentGroupsApi) CreatePaymentInstrumentGroup(ctx context.Co headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -158,6 +162,10 @@ func (a *PaymentInstrumentGroupsApi) GetAllTransactionRulesForPaymentInstrumentG headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -250,6 +258,10 @@ func (a *PaymentInstrumentGroupsApi) GetPaymentInstrumentGroup(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/balanceplatform/api_payment_instruments.go b/src/balanceplatform/api_payment_instruments.go index 15fffdfa9..8083bb759 100644 --- a/src/balanceplatform/api_payment_instruments.go +++ b/src/balanceplatform/api_payment_instruments.go @@ -68,6 +68,10 @@ func (a *PaymentInstrumentsApi) CreatePaymentInstrument(ctx context.Context, r P headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -160,6 +164,10 @@ func (a *PaymentInstrumentsApi) GetAllTransactionRulesForPaymentInstrument(ctx c headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -256,6 +264,10 @@ func (a *PaymentInstrumentsApi) GetPanOfPaymentInstrument(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -348,6 +360,10 @@ func (a *PaymentInstrumentsApi) GetPaymentInstrument(ctx context.Context, r Paym headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -440,6 +456,10 @@ func (a *PaymentInstrumentsApi) ListNetworkTokens(ctx context.Context, r Payment headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -538,6 +558,10 @@ func (a *PaymentInstrumentsApi) UpdatePaymentInstrument(ctx context.Context, r P headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/balanceplatform/api_platform.go b/src/balanceplatform/api_platform.go index 281f7d7ee..9aadf116c 100644 --- a/src/balanceplatform/api_platform.go +++ b/src/balanceplatform/api_platform.go @@ -86,6 +86,10 @@ func (a *PlatformApi) GetAllAccountHoldersUnderBalancePlatform(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -178,6 +182,10 @@ func (a *PlatformApi) GetBalancePlatform(ctx context.Context, r PlatformApiGetBa headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/balanceplatform/api_transaction_rules.go b/src/balanceplatform/api_transaction_rules.go index 197a497e5..62e7adb19 100644 --- a/src/balanceplatform/api_transaction_rules.go +++ b/src/balanceplatform/api_transaction_rules.go @@ -66,6 +66,10 @@ func (a *TransactionRulesApi) CreateTransactionRule(ctx context.Context, r Trans headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -158,6 +162,10 @@ func (a *TransactionRulesApi) DeleteTransactionRule(ctx context.Context, r Trans headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -250,6 +258,10 @@ func (a *TransactionRulesApi) GetTransactionRule(ctx context.Context, r Transact headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -352,6 +364,10 @@ func (a *TransactionRulesApi) UpdateTransactionRule(ctx context.Context, r Trans headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/common/client.go b/src/common/client.go index 1c32215cf..f9a48e3d0 100644 --- a/src/common/client.go +++ b/src/common/client.go @@ -32,6 +32,12 @@ import ( "golang.org/x/oauth2" ) +const ( + apiKeyHeader = "X-Api-Key" + authorizationHeader = "Authorization" + redacted = "***************" +) + var ( jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) @@ -194,7 +200,11 @@ func (c *Client) MakeHTTPPatchRequest(req interface{}, res interface{}, path str // CallAPI do the Request. func (c *Client) CallAPI(request *http.Request) (*http.Response, error) { if c.Cfg.Debug { + originalHeaders := request.Header.Clone() + maskApiKey(request) + maskAuthorization(request) dump, err := httputil.DumpRequestOut(request, true) + request.Header = originalHeaders if err != nil { return nil, err } @@ -217,6 +227,32 @@ func (c *Client) CallAPI(request *http.Request) (*http.Response, error) { return resp, err } +func maskApiKey(request *http.Request) { + apiKey := request.Header.Get(apiKeyHeader) + if apiKey == "" { + return + } + const visibleChars = 5 + cutPoint := len(apiKey) - visibleChars + if cutPoint > 0 { + maskedKey := redacted + apiKey[cutPoint:] + request.Header.Set(apiKeyHeader, maskedKey) + } +} + +func maskAuthorization(request *http.Request) { + authorization := request.Header.Get(authorizationHeader) + if authorization == "" { + return + } + fields := strings.Fields(authorization) + maskedAuthorization := redacted + if len(fields) > 0 { + maskedAuthorization = fields[0] + " " + redacted + } + request.Header.Set(authorizationHeader, maskedAuthorization) +} + // PrepareRequest build the Request func (c *Client) PrepareRequest( ctx context.Context, @@ -285,7 +321,7 @@ func (c *Client) PrepareRequest( // Add authentication headers if c.Cfg.ApiKey != "" { - localVarRequest.Header.Add("x-API-key", c.Cfg.ApiKey) + localVarRequest.Header.Add(apiKeyHeader, c.Cfg.ApiKey) } else if c.Cfg.Username != "" && c.Cfg.Password != "" { localVarRequest.SetBasicAuth(c.Cfg.Username, c.Cfg.Password) } @@ -314,7 +350,7 @@ func (c *Client) PrepareRequest( // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { - localVarRequest.Header.Add("Authorization", "Bearer "+auth) + localVarRequest.Header.Add(authorizationHeader, "Bearer "+auth) } } diff --git a/src/common/configuration.go b/src/common/configuration.go index dc7f58046..d3fac2305 100644 --- a/src/common/configuration.go +++ b/src/common/configuration.go @@ -51,7 +51,7 @@ const ( const ( LibName = "adyen-go-api-library" - LibVersion = "7.3.0" + LibVersion = "7.3.1" ) // Config stores the configuration of the API client diff --git a/src/management/api_account_company_level.go b/src/management/api_account_company_level.go index 0e4a5bb3d..59dba2f49 100644 --- a/src/management/api_account_company_level.go +++ b/src/management/api_account_company_level.go @@ -67,6 +67,10 @@ func (a *AccountCompanyLevelApi) GetCompanyAccount(ctx context.Context, r Accoun headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -179,6 +183,10 @@ func (a *AccountCompanyLevelApi) ListCompanyAccounts(ctx context.Context, r Acco headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -294,6 +302,10 @@ func (a *AccountCompanyLevelApi) ListMerchantAccounts(ctx context.Context, r Acc headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_account_merchant_level.go b/src/management/api_account_merchant_level.go index f8c54df88..407f2afaa 100644 --- a/src/management/api_account_merchant_level.go +++ b/src/management/api_account_merchant_level.go @@ -71,6 +71,10 @@ func (a *AccountMerchantLevelApi) CreateMerchantAccount(ctx context.Context, r A headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -166,6 +170,10 @@ func (a *AccountMerchantLevelApi) GetMerchantAccount(ctx context.Context, r Acco headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -277,6 +285,10 @@ func (a *AccountMerchantLevelApi) ListMerchantAccounts(ctx context.Context, r Ac headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -348,7 +360,7 @@ RequestToActivateMerchantAccount Request to activate a merchant account Sends a request to activate the merchant account identified in the path. -You get the result of the activation asychronously through a [`merchant.updated`](https://docs.adyen.com/api-explorer/ManagementNotification/latest/post/merchant.updated) webhook. Once the merchant account is activated, you can start using it to accept payments and payouts. +You get the result of the activation asynchronously through a [`merchant.updated`](https://docs.adyen.com/api-explorer/ManagementNotification/latest/post/merchant.updated) webhook. Once the merchant account is activated, you can start using it to accept payments and payouts. Use this endpoint if your integration requires it, such as Adyen for Platforms Manage. Your Adyen contact will set up your access. @@ -376,6 +388,10 @@ func (a *AccountMerchantLevelApi) RequestToActivateMerchantAccount(ctx context.C headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_account_store_level.go b/src/management/api_account_store_level.go index bfd41628d..2cc76de7d 100644 --- a/src/management/api_account_store_level.go +++ b/src/management/api_account_store_level.go @@ -69,6 +69,10 @@ func (a *AccountStoreLevelApi) CreateStore(ctx context.Context, r AccountStoreLe headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -170,6 +174,10 @@ func (a *AccountStoreLevelApi) CreateStoreByMerchantId(ctx context.Context, r Ac headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -269,6 +277,10 @@ func (a *AccountStoreLevelApi) GetStore(ctx context.Context, r AccountStoreLevel headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -365,6 +377,10 @@ func (a *AccountStoreLevelApi) GetStoreById(ctx context.Context, r AccountStoreL headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -497,6 +513,10 @@ func (a *AccountStoreLevelApi) ListStores(ctx context.Context, r AccountStoreLev headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -623,6 +643,10 @@ func (a *AccountStoreLevelApi) ListStoresByMerchantId(ctx context.Context, r Acc headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -727,6 +751,10 @@ func (a *AccountStoreLevelApi) UpdateStore(ctx context.Context, r AccountStoreLe headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -829,6 +857,10 @@ func (a *AccountStoreLevelApi) UpdateStoreById(ctx context.Context, r AccountSto headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_allowed_origins_company_level.go b/src/management/api_allowed_origins_company_level.go index 4bca96ad0..066731e00 100644 --- a/src/management/api_allowed_origins_company_level.go +++ b/src/management/api_allowed_origins_company_level.go @@ -76,6 +76,10 @@ func (a *AllowedOriginsCompanyLevelApi) CreateAllowedOrigin(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -177,6 +181,10 @@ func (a *AllowedOriginsCompanyLevelApi) DeleteAllowedOrigin(ctx context.Context, headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -278,6 +286,10 @@ func (a *AllowedOriginsCompanyLevelApi) GetAllowedOrigin(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -376,6 +388,10 @@ func (a *AllowedOriginsCompanyLevelApi) ListAllowedOrigins(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_allowed_origins_merchant_level.go b/src/management/api_allowed_origins_merchant_level.go index f77689543..39313bd74 100644 --- a/src/management/api_allowed_origins_merchant_level.go +++ b/src/management/api_allowed_origins_merchant_level.go @@ -76,6 +76,10 @@ func (a *AllowedOriginsMerchantLevelApi) CreateAllowedOrigin(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -177,6 +181,10 @@ func (a *AllowedOriginsMerchantLevelApi) DeleteAllowedOrigin(ctx context.Context headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -278,6 +286,10 @@ func (a *AllowedOriginsMerchantLevelApi) GetAllowedOrigin(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -376,6 +388,10 @@ func (a *AllowedOriginsMerchantLevelApi) ListAllowedOrigins(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_api_credentials_company_level.go b/src/management/api_api_credentials_company_level.go index 4c99cbe60..41d1162c0 100644 --- a/src/management/api_api_credentials_company_level.go +++ b/src/management/api_api_credentials_company_level.go @@ -82,6 +82,10 @@ func (a *APICredentialsCompanyLevelApi) CreateApiCredential(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -180,6 +184,10 @@ func (a *APICredentialsCompanyLevelApi) GetApiCredential(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -295,6 +303,10 @@ func (a *APICredentialsCompanyLevelApi) ListApiCredentials(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -399,6 +411,10 @@ func (a *APICredentialsCompanyLevelApi) UpdateApiCredential(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_api_credentials_merchant_level.go b/src/management/api_api_credentials_merchant_level.go index 085edb165..8ee7d1f47 100644 --- a/src/management/api_api_credentials_merchant_level.go +++ b/src/management/api_api_credentials_merchant_level.go @@ -82,6 +82,10 @@ func (a *APICredentialsMerchantLevelApi) CreateApiCredential(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -180,6 +184,10 @@ func (a *APICredentialsMerchantLevelApi) GetApiCredential(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -295,6 +303,10 @@ func (a *APICredentialsMerchantLevelApi) ListApiCredentials(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -399,6 +411,10 @@ func (a *APICredentialsMerchantLevelApi) UpdateApiCredential(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_api_key_company_level.go b/src/management/api_api_key_company_level.go index ff20ea47f..c16a8931f 100644 --- a/src/management/api_api_key_company_level.go +++ b/src/management/api_api_key_company_level.go @@ -70,6 +70,10 @@ func (a *APIKeyCompanyLevelApi) GenerateNewApiKey(ctx context.Context, r APIKeyC headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_api_key_merchant_level.go b/src/management/api_api_key_merchant_level.go index 4e9901e03..1f5739bf7 100644 --- a/src/management/api_api_key_merchant_level.go +++ b/src/management/api_api_key_merchant_level.go @@ -70,6 +70,10 @@ func (a *APIKeyMerchantLevelApi) GenerateNewApiKey(ctx context.Context, r APIKey headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_client_key_company_level.go b/src/management/api_client_key_company_level.go index 39b2a5d33..007305caf 100644 --- a/src/management/api_client_key_company_level.go +++ b/src/management/api_client_key_company_level.go @@ -70,6 +70,10 @@ func (a *ClientKeyCompanyLevelApi) GenerateNewClientKey(ctx context.Context, r C headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_client_key_merchant_level.go b/src/management/api_client_key_merchant_level.go index f3eaa95e5..77756daf6 100644 --- a/src/management/api_client_key_merchant_level.go +++ b/src/management/api_client_key_merchant_level.go @@ -70,6 +70,10 @@ func (a *ClientKeyMerchantLevelApi) GenerateNewClientKey(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_my_api_credential.go b/src/management/api_my_api_credential.go index 0b18d40a5..809849574 100644 --- a/src/management/api_my_api_credential.go +++ b/src/management/api_my_api_credential.go @@ -69,6 +69,10 @@ func (a *MyAPICredentialApi) AddAllowedOrigin(ctx context.Context, r MyAPICreden headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -164,6 +168,10 @@ func (a *MyAPICredentialApi) GetAllowedOriginDetails(ctx context.Context, r MyAP headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -254,6 +262,10 @@ func (a *MyAPICredentialApi) GetAllowedOrigins(ctx context.Context, r MyAPICrede headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -344,6 +356,10 @@ func (a *MyAPICredentialApi) GetApiCredentialDetails(ctx context.Context, r MyAP headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -439,6 +455,10 @@ func (a *MyAPICredentialApi) RemoveAllowedOrigin(ctx context.Context, r MyAPICre headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_payment_methods_merchant_level.go b/src/management/api_payment_methods_merchant_level.go index 6841d59fa..de65b63f6 100644 --- a/src/management/api_payment_methods_merchant_level.go +++ b/src/management/api_payment_methods_merchant_level.go @@ -77,6 +77,10 @@ func (a *PaymentMethodsMerchantLevelApi) AddApplePayDomain(ctx context.Context, headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -213,6 +217,10 @@ func (a *PaymentMethodsMerchantLevelApi) GetAllPaymentMethods(ctx context.Contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -312,6 +320,10 @@ func (a *PaymentMethodsMerchantLevelApi) GetApplePayDomains(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -411,6 +423,10 @@ func (a *PaymentMethodsMerchantLevelApi) GetPaymentMethodDetails(ctx context.Con headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -513,6 +529,10 @@ func (a *PaymentMethodsMerchantLevelApi) RequestPaymentMethod(ctx context.Contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -618,6 +638,10 @@ func (a *PaymentMethodsMerchantLevelApi) UpdatePaymentMethod(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_payout_settings_merchant_level.go b/src/management/api_payout_settings_merchant_level.go index 18ecb94ee..85cb5863b 100644 --- a/src/management/api_payout_settings_merchant_level.go +++ b/src/management/api_payout_settings_merchant_level.go @@ -78,6 +78,10 @@ func (a *PayoutSettingsMerchantLevelApi) AddPayoutSetting(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -179,6 +183,10 @@ func (a *PayoutSettingsMerchantLevelApi) DeletePayoutSetting(ctx context.Context headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -279,6 +287,10 @@ func (a *PayoutSettingsMerchantLevelApi) GetPayoutSetting(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -376,6 +388,10 @@ func (a *PayoutSettingsMerchantLevelApi) ListPayoutSettings(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -483,6 +499,10 @@ func (a *PayoutSettingsMerchantLevelApi) UpdatePayoutSetting(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_split_configuration_merchant_level.go b/src/management/api_split_configuration_merchant_level.go index 22787f5a2..69fa74644 100644 --- a/src/management/api_split_configuration_merchant_level.go +++ b/src/management/api_split_configuration_merchant_level.go @@ -76,6 +76,10 @@ func (a *SplitConfigurationMerchantLevelApi) CreateRule(ctx context.Context, r S headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -177,6 +181,10 @@ func (a *SplitConfigurationMerchantLevelApi) CreateSplitConfiguration(ctx contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -275,6 +283,10 @@ func (a *SplitConfigurationMerchantLevelApi) DeleteSplitConfiguration(ctx contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -376,6 +388,10 @@ func (a *SplitConfigurationMerchantLevelApi) DeleteSplitConfigurationRule(ctx co headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -474,6 +490,10 @@ func (a *SplitConfigurationMerchantLevelApi) GetSplitConfiguration(ctx context.C headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -569,6 +589,10 @@ func (a *SplitConfigurationMerchantLevelApi) ListSplitConfigurations(ctx context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -676,6 +700,10 @@ func (a *SplitConfigurationMerchantLevelApi) UpdateSplitConditions(ctx context.C headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -780,6 +808,10 @@ func (a *SplitConfigurationMerchantLevelApi) UpdateSplitConfigurationDescription headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -890,6 +922,10 @@ func (a *SplitConfigurationMerchantLevelApi) UpdateSplitLogic(ctx context.Contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_actions_company_level.go b/src/management/api_terminal_actions_company_level.go index ebb4949a9..021334e29 100644 --- a/src/management/api_terminal_actions_company_level.go +++ b/src/management/api_terminal_actions_company_level.go @@ -70,6 +70,10 @@ func (a *TerminalActionsCompanyLevelApi) GetTerminalAction(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -207,6 +211,10 @@ func (a *TerminalActionsCompanyLevelApi) ListAndroidApps(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -334,6 +342,10 @@ func (a *TerminalActionsCompanyLevelApi) ListAndroidCertificates(ctx context.Con headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -469,6 +481,10 @@ func (a *TerminalActionsCompanyLevelApi) ListTerminalActions(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_actions_terminal_level.go b/src/management/api_terminal_actions_terminal_level.go index 99704ce76..cee981e56 100644 --- a/src/management/api_terminal_actions_terminal_level.go +++ b/src/management/api_terminal_actions_terminal_level.go @@ -73,6 +73,10 @@ func (a *TerminalActionsTerminalLevelApi) CreateTerminalAction(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_orders_company_level.go b/src/management/api_terminal_orders_company_level.go index 627a45975..a99552a20 100644 --- a/src/management/api_terminal_orders_company_level.go +++ b/src/management/api_terminal_orders_company_level.go @@ -72,6 +72,10 @@ func (a *TerminalOrdersCompanyLevelApi) CancelOrder(ctx context.Context, r Termi headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -173,6 +177,10 @@ func (a *TerminalOrdersCompanyLevelApi) CreateOrder(ctx context.Context, r Termi headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -274,6 +282,10 @@ func (a *TerminalOrdersCompanyLevelApi) CreateShippingLocation(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -373,6 +385,10 @@ func (a *TerminalOrdersCompanyLevelApi) GetOrder(ctx context.Context, r Terminal headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -480,6 +496,10 @@ func (a *TerminalOrdersCompanyLevelApi) ListBillingEntities(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -617,6 +637,10 @@ func (a *TerminalOrdersCompanyLevelApi) ListOrders(ctx context.Context, r Termin headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -744,6 +768,10 @@ func (a *TerminalOrdersCompanyLevelApi) ListShippingLocations(ctx context.Contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -841,6 +869,10 @@ func (a *TerminalOrdersCompanyLevelApi) ListTerminalModels(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -977,6 +1009,10 @@ func (a *TerminalOrdersCompanyLevelApi) ListTerminalProducts(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -1086,6 +1122,10 @@ func (a *TerminalOrdersCompanyLevelApi) UpdateOrder(ctx context.Context, r Termi headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_orders_merchant_level.go b/src/management/api_terminal_orders_merchant_level.go index 410b10432..97f0de105 100644 --- a/src/management/api_terminal_orders_merchant_level.go +++ b/src/management/api_terminal_orders_merchant_level.go @@ -72,6 +72,10 @@ func (a *TerminalOrdersMerchantLevelApi) CancelOrder(ctx context.Context, r Term headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -173,6 +177,10 @@ func (a *TerminalOrdersMerchantLevelApi) CreateOrder(ctx context.Context, r Term headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -274,6 +282,10 @@ func (a *TerminalOrdersMerchantLevelApi) CreateShippingLocation(ctx context.Cont headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -373,6 +385,10 @@ func (a *TerminalOrdersMerchantLevelApi) GetOrder(ctx context.Context, r Termina headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -480,6 +496,10 @@ func (a *TerminalOrdersMerchantLevelApi) ListBillingEntities(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -616,6 +636,10 @@ func (a *TerminalOrdersMerchantLevelApi) ListOrders(ctx context.Context, r Termi headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -743,6 +767,10 @@ func (a *TerminalOrdersMerchantLevelApi) ListShippingLocations(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -839,6 +867,10 @@ func (a *TerminalOrdersMerchantLevelApi) ListTerminalModels(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -975,6 +1007,10 @@ func (a *TerminalOrdersMerchantLevelApi) ListTerminalProducts(ctx context.Contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -1084,6 +1120,10 @@ func (a *TerminalOrdersMerchantLevelApi) UpdateOrder(ctx context.Context, r Term headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_settings_company_level.go b/src/management/api_terminal_settings_company_level.go index 937cf0c6f..1e50cda00 100644 --- a/src/management/api_terminal_settings_company_level.go +++ b/src/management/api_terminal_settings_company_level.go @@ -81,6 +81,10 @@ func (a *TerminalSettingsCompanyLevelApi) GetTerminalLogo(ctx context.Context, r headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -180,6 +184,10 @@ func (a *TerminalSettingsCompanyLevelApi) GetTerminalSettings(ctx context.Contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -294,6 +302,10 @@ func (a *TerminalSettingsCompanyLevelApi) UpdateTerminalLogo(ctx context.Context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -402,6 +414,10 @@ func (a *TerminalSettingsCompanyLevelApi) UpdateTerminalSettings(ctx context.Con headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_settings_merchant_level.go b/src/management/api_terminal_settings_merchant_level.go index a69bd7cd5..ed55ff9b0 100644 --- a/src/management/api_terminal_settings_merchant_level.go +++ b/src/management/api_terminal_settings_merchant_level.go @@ -80,6 +80,10 @@ func (a *TerminalSettingsMerchantLevelApi) GetTerminalLogo(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -176,6 +180,10 @@ func (a *TerminalSettingsMerchantLevelApi) GetTerminalSettings(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -291,6 +299,10 @@ func (a *TerminalSettingsMerchantLevelApi) UpdateTerminalLogo(ctx context.Contex headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -397,6 +409,10 @@ func (a *TerminalSettingsMerchantLevelApi) UpdateTerminalSettings(ctx context.Co headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_settings_store_level.go b/src/management/api_terminal_settings_store_level.go index cd21690b5..0988c1c82 100644 --- a/src/management/api_terminal_settings_store_level.go +++ b/src/management/api_terminal_settings_store_level.go @@ -83,6 +83,10 @@ func (a *TerminalSettingsStoreLevelApi) GetTerminalLogo(ctx context.Context, r T headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -191,6 +195,10 @@ func (a *TerminalSettingsStoreLevelApi) GetTerminalLogoByStoreId(ctx context.Con headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -293,6 +301,10 @@ func (a *TerminalSettingsStoreLevelApi) GetTerminalSettings(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -392,6 +404,10 @@ func (a *TerminalSettingsStoreLevelApi) GetTerminalSettingsByStoreId(ctx context headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -510,6 +526,10 @@ func (a *TerminalSettingsStoreLevelApi) UpdateTerminalLogo(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -625,6 +645,10 @@ func (a *TerminalSettingsStoreLevelApi) UpdateTerminalLogoByStoreId(ctx context. headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -736,6 +760,10 @@ func (a *TerminalSettingsStoreLevelApi) UpdateTerminalSettings(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -844,6 +872,10 @@ func (a *TerminalSettingsStoreLevelApi) UpdateTerminalSettingsByStoreId(ctx cont headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminal_settings_terminal_level.go b/src/management/api_terminal_settings_terminal_level.go index 321cbedcb..52c09d708 100644 --- a/src/management/api_terminal_settings_terminal_level.go +++ b/src/management/api_terminal_settings_terminal_level.go @@ -69,6 +69,10 @@ func (a *TerminalSettingsTerminalLevelApi) GetTerminalLogo(ctx context.Context, headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -168,6 +172,10 @@ func (a *TerminalSettingsTerminalLevelApi) GetTerminalSettings(ctx context.Conte headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -272,6 +280,10 @@ func (a *TerminalSettingsTerminalLevelApi) UpdateLogo(ctx context.Context, r Ter headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -380,6 +392,10 @@ func (a *TerminalSettingsTerminalLevelApi) UpdateTerminalSettings(ctx context.Co headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_terminals_terminal_level.go b/src/management/api_terminals_terminal_level.go index d41f23f32..d346975a7 100644 --- a/src/management/api_terminals_terminal_level.go +++ b/src/management/api_terminals_terminal_level.go @@ -141,6 +141,10 @@ func (a *TerminalsTerminalLevelApi) ListTerminals(ctx context.Context, r Termina headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_users_company_level.go b/src/management/api_users_company_level.go index 746452d83..35da7465e 100644 --- a/src/management/api_users_company_level.go +++ b/src/management/api_users_company_level.go @@ -74,6 +74,10 @@ func (a *UsersCompanyLevelApi) CreateNewUser(ctx context.Context, r UsersCompany headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -173,6 +177,10 @@ func (a *UsersCompanyLevelApi) GetUserDetails(ctx context.Context, r UsersCompan headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -299,6 +307,10 @@ func (a *UsersCompanyLevelApi) ListUsers(ctx context.Context, r UsersCompanyLeve headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -404,6 +416,10 @@ func (a *UsersCompanyLevelApi) UpdateUserDetails(ctx context.Context, r UsersCom headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_users_merchant_level.go b/src/management/api_users_merchant_level.go index cd40d64d6..46e6a1340 100644 --- a/src/management/api_users_merchant_level.go +++ b/src/management/api_users_merchant_level.go @@ -74,6 +74,10 @@ func (a *UsersMerchantLevelApi) CreateNewUser(ctx context.Context, r UsersMercha headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -173,6 +177,10 @@ func (a *UsersMerchantLevelApi) GetUserDetails(ctx context.Context, r UsersMerch headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -299,6 +307,10 @@ func (a *UsersMerchantLevelApi) ListUsers(ctx context.Context, r UsersMerchantLe headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -404,6 +416,10 @@ func (a *UsersMerchantLevelApi) UpdateUser(ctx context.Context, r UsersMerchantL headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_webhooks_company_level.go b/src/management/api_webhooks_company_level.go index c28ca8b7b..34d59af9d 100644 --- a/src/management/api_webhooks_company_level.go +++ b/src/management/api_webhooks_company_level.go @@ -70,6 +70,10 @@ func (a *WebhooksCompanyLevelApi) GenerateHmacKey(ctx context.Context, r Webhook headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -169,6 +173,10 @@ func (a *WebhooksCompanyLevelApi) GetWebhook(ctx context.Context, r WebhooksComp headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -285,6 +293,10 @@ func (a *WebhooksCompanyLevelApi) ListAllWebhooks(ctx context.Context, r Webhook headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -383,6 +395,10 @@ func (a *WebhooksCompanyLevelApi) RemoveWebhook(ctx context.Context, r WebhooksC headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -484,6 +500,10 @@ func (a *WebhooksCompanyLevelApi) SetUpWebhook(ctx context.Context, r WebhooksCo headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -594,6 +614,10 @@ func (a *WebhooksCompanyLevelApi) TestWebhook(ctx context.Context, r WebhooksCom headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -698,6 +722,10 @@ func (a *WebhooksCompanyLevelApi) UpdateWebhook(ctx context.Context, r WebhooksC headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/management/api_webhooks_merchant_level.go b/src/management/api_webhooks_merchant_level.go index f07c404fc..44de9fb29 100644 --- a/src/management/api_webhooks_merchant_level.go +++ b/src/management/api_webhooks_merchant_level.go @@ -70,6 +70,10 @@ func (a *WebhooksMerchantLevelApi) GenerateHmacKey(ctx context.Context, r Webhoo headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -169,6 +173,10 @@ func (a *WebhooksMerchantLevelApi) GetWebhook(ctx context.Context, r WebhooksMer headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -285,6 +293,10 @@ func (a *WebhooksMerchantLevelApi) ListAllWebhooks(ctx context.Context, r Webhoo headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -383,6 +395,10 @@ func (a *WebhooksMerchantLevelApi) RemoveWebhook(ctx context.Context, r Webhooks headerParams, ) + if httpRes == nil { + return httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -484,6 +500,10 @@ func (a *WebhooksMerchantLevelApi) SetUpWebhook(ctx context.Context, r WebhooksM headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -592,6 +612,10 @@ func (a *WebhooksMerchantLevelApi) TestWebhook(ctx context.Context, r WebhooksMe headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -696,6 +720,10 @@ func (a *WebhooksMerchantLevelApi) UpdateWebhook(ctx context.Context, r Webhooks headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/transfers/api_capital.go b/src/transfers/api_capital.go index 613fc7e70..1e4f8ffb7 100644 --- a/src/transfers/api_capital.go +++ b/src/transfers/api_capital.go @@ -70,6 +70,10 @@ func (a *CapitalApi) GetCapitalAccount(ctx context.Context, r CapitalApiGetCapit headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -171,6 +175,10 @@ func (a *CapitalApi) GetGrantReferenceDetails(ctx context.Context, r CapitalApiG headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { @@ -274,6 +282,10 @@ func (a *CapitalApi) RequestGrantPayout(ctx context.Context, r CapitalApiRequest headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 400 { diff --git a/src/transfers/api_transactions.go b/src/transfers/api_transactions.go index 7ecd9823c..b675f3237 100644 --- a/src/transfers/api_transactions.go +++ b/src/transfers/api_transactions.go @@ -145,6 +145,10 @@ func (a *TransactionsApi) GetAllTransactions(ctx context.Context, r Transactions headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 401 { @@ -228,6 +232,10 @@ func (a *TransactionsApi) GetTransaction(ctx context.Context, r TransactionsApiG headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 401 { diff --git a/src/transfers/api_transfers.go b/src/transfers/api_transfers.go index e5b71474c..34845be88 100644 --- a/src/transfers/api_transfers.go +++ b/src/transfers/api_transfers.go @@ -67,6 +67,10 @@ func (a *TransfersApi) TransferFunds(ctx context.Context, r TransfersApiTransfer headerParams, ) + if httpRes == nil { + return *res, httpRes, err + } + var serviceError common.RestServiceError if httpRes.StatusCode == 401 { diff --git a/templates/custom/api.mustache b/templates/custom/api.mustache index d5c233251..049ccd215 100644 --- a/templates/custom/api.mustache +++ b/templates/custom/api.mustache @@ -109,17 +109,18 @@ func (a *{{{classname}}}) {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecas headerParams, ) + if httpRes == nil { + return {{#returnType}}*res, {{/returnType}}httpRes, err + } + {{#hasRestServiceError}} {{#responses}} {{#-first}}var serviceError common.RestServiceError{{/-first}} {{#dataType}} - {{^is1xx}} {{^is2xx}} {{#range}} - {{#is3xx}} - if httpRes.StatusCode >= 300 && httpRes.StatusCode < 400 { {{/is3xx}} {{#is4xx}} @@ -130,19 +131,18 @@ func (a *{{{classname}}}) {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecas {{/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 + 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}} diff --git a/tests/balanceplatform_test.go b/tests/balanceplatform_test.go index a7689bf67..6327540c0 100644 --- a/tests/balanceplatform_test.go +++ b/tests/balanceplatform_test.go @@ -76,6 +76,12 @@ func Test_BalancePlatform(t *testing.T) { return mockServer.URL } + // Network error + mux.HandleFunc("/balanceAccounts", func(w http.ResponseWriter, r *http.Request) { + require.Equal(t, "POST", r.Method) + mockServer.CloseClientConnections() + }) + t.Run("Configuration", func(t *testing.T) { testClient := adyen.NewClient(&common.Config{ Environment: common.TestEnv, @@ -145,6 +151,18 @@ func Test_BalancePlatform(t *testing.T) { assert.Equal(t, "Payment instrument not found", serviceError.GetDetail()) }) + t.Run("Gateway Timeout error", func(t *testing.T) { + req := service.BalanceAccountsApi.CreateBalanceAccountInput().BalanceAccountInfo(balanceplatform.BalanceAccountInfo{ + AccountHolderId: "AH123ABC", + Description: common.PtrString("S.Hopper - Main balance account"), + }) + + _, httpRes, err := service.BalanceAccountsApi.CreateBalanceAccount(context.Background(), req) + + assert.Error(t, err) + assert.Nil(t, httpRes) + }) + t.Run("Get a sweep", func(t *testing.T) { req := service.BalanceAccountsApi.GetSweepInput("BA123", "SWPC123")