/*
Management API

API version: 3
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package management

import (
	"context"
	"encoding/json"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"

	"github.com/adyen/adyen-go-api-library/v21/src/common"
)

// TerminalSettingsStoreLevelApi service
type TerminalSettingsStoreLevelApi common.Service

// All parameters accepted by TerminalSettingsStoreLevelApi.GetTerminalLogo
type TerminalSettingsStoreLevelApiGetTerminalLogoInput struct {
	merchantId string
	reference  string
	model      *string
}

// The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T.
func (r TerminalSettingsStoreLevelApiGetTerminalLogoInput) Model(model string) TerminalSettingsStoreLevelApiGetTerminalLogoInput {
	r.model = &model
	return r
}

/*
Prepare a request for GetTerminalLogo
@param merchantId The unique identifier of the merchant account.@param reference The reference that identifies the store.
@return TerminalSettingsStoreLevelApiGetTerminalLogoInput
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalLogoInput(merchantId string, reference string) TerminalSettingsStoreLevelApiGetTerminalLogoInput {
	return TerminalSettingsStoreLevelApiGetTerminalLogoInput{
		merchantId: merchantId,
		reference:  reference,
	}
}

/*
GetTerminalLogo Get the terminal logo

Returns the logo that is configured for a specific payment terminal model at the store identified in the path.
The logo is returned as a Base64-encoded string. You need to Base64-decode the string to get the actual image file.
This logo applies to all terminals of the specified model under the store, unless a different logo is configured for an individual terminal.

To make this request, your API credential must have one of the following [roles](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read
* Management API—Terminal settings read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiGetTerminalLogoInput - Request parameters, see GetTerminalLogoInput
@return Logo, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalLogo(ctx context.Context, r TerminalSettingsStoreLevelApiGetTerminalLogoInput) (Logo, *http.Response, error) {
	res := &Logo{}
	path := "/merchants/{merchantId}/stores/{reference}/terminalLogos"
	path = strings.Replace(path, "{"+"merchantId"+"}", url.PathEscape(common.ParameterValueToString(r.merchantId, "merchantId")), -1)
	path = strings.Replace(path, "{"+"reference"+"}", url.PathEscape(common.ParameterValueToString(r.reference, "reference")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	if r.model != nil {
		common.ParameterAddToQuery(queryParams, "model", r.model, "")
	}
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		nil,
		res,
		http.MethodGet,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}

// All parameters accepted by TerminalSettingsStoreLevelApi.GetTerminalLogoByStoreId
type TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput struct {
	storeId string
	model   *string
}

// The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T.
func (r TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput) Model(model string) TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput {
	r.model = &model
	return r
}

/*
Prepare a request for GetTerminalLogoByStoreId
@param storeId The unique identifier of the store.
@return TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalLogoByStoreIdInput(storeId string) TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput {
	return TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput{
		storeId: storeId,
	}
}

/*
GetTerminalLogoByStoreId Get the terminal logo

Returns the logo that is configured for a specific payment terminal model at the store identified in the path.
The logo is returned as a Base64-encoded string. You need to Base64-decode the string to get the actual image file.
This logo applies to all terminals of that model under the store unless a different logo is configured for an individual terminal.

To make this request, your API credential must have one of the following [roles](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read
* Management API—Terminal settings read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput - Request parameters, see GetTerminalLogoByStoreIdInput
@return Logo, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalLogoByStoreId(ctx context.Context, r TerminalSettingsStoreLevelApiGetTerminalLogoByStoreIdInput) (Logo, *http.Response, error) {
	res := &Logo{}
	path := "/stores/{storeId}/terminalLogos"
	path = strings.Replace(path, "{"+"storeId"+"}", url.PathEscape(common.ParameterValueToString(r.storeId, "storeId")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	if r.model != nil {
		common.ParameterAddToQuery(queryParams, "model", r.model, "")
	}
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		nil,
		res,
		http.MethodGet,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}

// All parameters accepted by TerminalSettingsStoreLevelApi.GetTerminalSettings
type TerminalSettingsStoreLevelApiGetTerminalSettingsInput struct {
	merchantId string
	reference  string
}

/*
Prepare a request for GetTerminalSettings
@param merchantId The unique identifier of the merchant account.@param reference The reference that identifies the store.
@return TerminalSettingsStoreLevelApiGetTerminalSettingsInput
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalSettingsInput(merchantId string, reference string) TerminalSettingsStoreLevelApiGetTerminalSettingsInput {
	return TerminalSettingsStoreLevelApiGetTerminalSettingsInput{
		merchantId: merchantId,
		reference:  reference,
	}
}

/*
GetTerminalSettings Get terminal settings

Returns the payment terminal settings that are configured for the store identified in the path. These settings apply to all terminals under the store unless different values are configured for an individual terminal.

To make this request, your API credential must have one of the following [roles](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read
* Management API—Terminal settings read and write

For [sensitive terminal settings](https://docs.adyen.com/point-of-sale/automating-terminal-management/configure-terminals-api#sensitive-terminal-settings), your API credential must have the following role:
* Management API—Terminal settings Advanced read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiGetTerminalSettingsInput - Request parameters, see GetTerminalSettingsInput
@return TerminalSettings, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalSettings(ctx context.Context, r TerminalSettingsStoreLevelApiGetTerminalSettingsInput) (TerminalSettings, *http.Response, error) {
	res := &TerminalSettings{}
	path := "/merchants/{merchantId}/stores/{reference}/terminalSettings"
	path = strings.Replace(path, "{"+"merchantId"+"}", url.PathEscape(common.ParameterValueToString(r.merchantId, "merchantId")), -1)
	path = strings.Replace(path, "{"+"reference"+"}", url.PathEscape(common.ParameterValueToString(r.reference, "reference")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		nil,
		res,
		http.MethodGet,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}

// All parameters accepted by TerminalSettingsStoreLevelApi.GetTerminalSettingsByStoreId
type TerminalSettingsStoreLevelApiGetTerminalSettingsByStoreIdInput struct {
	storeId string
}

/*
Prepare a request for GetTerminalSettingsByStoreId
@param storeId The unique identifier of the store.
@return TerminalSettingsStoreLevelApiGetTerminalSettingsByStoreIdInput
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalSettingsByStoreIdInput(storeId string) TerminalSettingsStoreLevelApiGetTerminalSettingsByStoreIdInput {
	return TerminalSettingsStoreLevelApiGetTerminalSettingsByStoreIdInput{
		storeId: storeId,
	}
}

/*
GetTerminalSettingsByStoreId Get terminal settings

Returns the payment terminal settings that are configured for the store identified in the path. These settings apply to all terminals under the store unless different values are configured for an individual terminal.

To make this request, your API credential must have one of the following [roles](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read
* Management API—Terminal settings read and write

For [sensitive terminal settings](https://docs.adyen.com/point-of-sale/automating-terminal-management/configure-terminals-api#sensitive-terminal-settings), your API credential must have the following role:
* Management API—Terminal settings Advanced read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiGetTerminalSettingsByStoreIdInput - Request parameters, see GetTerminalSettingsByStoreIdInput
@return TerminalSettings, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) GetTerminalSettingsByStoreId(ctx context.Context, r TerminalSettingsStoreLevelApiGetTerminalSettingsByStoreIdInput) (TerminalSettings, *http.Response, error) {
	res := &TerminalSettings{}
	path := "/stores/{storeId}/terminalSettings"
	path = strings.Replace(path, "{"+"storeId"+"}", url.PathEscape(common.ParameterValueToString(r.storeId, "storeId")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		nil,
		res,
		http.MethodGet,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}

// All parameters accepted by TerminalSettingsStoreLevelApi.UpdateTerminalLogo
type TerminalSettingsStoreLevelApiUpdateTerminalLogoInput struct {
	merchantId string
	reference  string
	model      *string
	logo       *Logo
}

// The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T
func (r TerminalSettingsStoreLevelApiUpdateTerminalLogoInput) Model(model string) TerminalSettingsStoreLevelApiUpdateTerminalLogoInput {
	r.model = &model
	return r
}

func (r TerminalSettingsStoreLevelApiUpdateTerminalLogoInput) Logo(logo Logo) TerminalSettingsStoreLevelApiUpdateTerminalLogoInput {
	r.logo = &logo
	return r
}

/*
Prepare a request for UpdateTerminalLogo
@param merchantId The unique identifier of the merchant account.@param reference The reference that identifies the store.
@return TerminalSettingsStoreLevelApiUpdateTerminalLogoInput
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalLogoInput(merchantId string, reference string) TerminalSettingsStoreLevelApiUpdateTerminalLogoInput {
	return TerminalSettingsStoreLevelApiUpdateTerminalLogoInput{
		merchantId: merchantId,
		reference:  reference,
	}
}

/*
UpdateTerminalLogo Update the terminal logo

Updates the logo that is configured for a specific payment terminal model at the store identified in the path. You can update the logo for only one terminal model at a time.
This logo applies to all terminals of the specified model under the store, unless a different logo is configured for an individual terminal.

* To change the logo, specify the image file as a Base64-encoded string.
* To restore the logo inherited from a higher level (merchant or company account), specify an empty logo value.

To make this request, your API credential must have the following [role](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiUpdateTerminalLogoInput - Request parameters, see UpdateTerminalLogoInput
@return Logo, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalLogo(ctx context.Context, r TerminalSettingsStoreLevelApiUpdateTerminalLogoInput) (Logo, *http.Response, error) {
	res := &Logo{}
	path := "/merchants/{merchantId}/stores/{reference}/terminalLogos"
	path = strings.Replace(path, "{"+"merchantId"+"}", url.PathEscape(common.ParameterValueToString(r.merchantId, "merchantId")), -1)
	path = strings.Replace(path, "{"+"reference"+"}", url.PathEscape(common.ParameterValueToString(r.reference, "reference")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	if r.model != nil {
		common.ParameterAddToQuery(queryParams, "model", r.model, "")
	}
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		r.logo,
		res,
		http.MethodPatch,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}

// All parameters accepted by TerminalSettingsStoreLevelApi.UpdateTerminalLogoByStoreId
type TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput struct {
	storeId string
	model   *string
	logo    *Logo
}

// The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T.
func (r TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput) Model(model string) TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput {
	r.model = &model
	return r
}

func (r TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput) Logo(logo Logo) TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput {
	r.logo = &logo
	return r
}

/*
Prepare a request for UpdateTerminalLogoByStoreId
@param storeId The unique identifier of the store.
@return TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalLogoByStoreIdInput(storeId string) TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput {
	return TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput{
		storeId: storeId,
	}
}

/*
UpdateTerminalLogoByStoreId Update the terminal logo

Updates the logo that is configured for a specific payment terminal model at the store identified in the path. You can update the logo for only one terminal model at a time.
This logo applies to all terminals of the specified model under the store, unless a different logo is configured for an individual terminal.

* To change the logo, specify the image file as a Base64-encoded string.
* To restore the logo inherited from a higher level (merchant or company account), specify an empty logo value.

To make this request, your API credential must have the following [role](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput - Request parameters, see UpdateTerminalLogoByStoreIdInput
@return Logo, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalLogoByStoreId(ctx context.Context, r TerminalSettingsStoreLevelApiUpdateTerminalLogoByStoreIdInput) (Logo, *http.Response, error) {
	res := &Logo{}
	path := "/stores/{storeId}/terminalLogos"
	path = strings.Replace(path, "{"+"storeId"+"}", url.PathEscape(common.ParameterValueToString(r.storeId, "storeId")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	if r.model != nil {
		common.ParameterAddToQuery(queryParams, "model", r.model, "")
	}
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		r.logo,
		res,
		http.MethodPatch,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}

// All parameters accepted by TerminalSettingsStoreLevelApi.UpdateTerminalSettings
type TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput struct {
	merchantId       string
	reference        string
	terminalSettings *TerminalSettings
}

func (r TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput) TerminalSettings(terminalSettings TerminalSettings) TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput {
	r.terminalSettings = &terminalSettings
	return r
}

/*
Prepare a request for UpdateTerminalSettings
@param merchantId The unique identifier of the merchant account.@param reference The reference that identifies the store.
@return TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalSettingsInput(merchantId string, reference string) TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput {
	return TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput{
		merchantId: merchantId,
		reference:  reference,
	}
}

/*
UpdateTerminalSettings Update terminal settings

Updates payment terminal settings for the store identified in the path. These settings apply to all terminals under the store, unless different values are configured for an individual terminal.

* To change a parameter value, include the full object that contains the parameter, even if you don't want to change all parameters in the object.
* To restore a parameter value inherited from a higher level, include the full object that contains the parameter, and specify an empty value for the parameter or omit the parameter.
* Objects that are not included in the request are not updated.

To make this request, your API credential must have the following [role](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read and write

For [sensitive terminal settings](https://docs.adyen.com/point-of-sale/automating-terminal-management/configure-terminals-api#sensitive-terminal-settings), your API credential must have the following role:
* Management API—Terminal settings Advanced read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput - Request parameters, see UpdateTerminalSettingsInput
@return TerminalSettings, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalSettings(ctx context.Context, r TerminalSettingsStoreLevelApiUpdateTerminalSettingsInput) (TerminalSettings, *http.Response, error) {
	res := &TerminalSettings{}
	path := "/merchants/{merchantId}/stores/{reference}/terminalSettings"
	path = strings.Replace(path, "{"+"merchantId"+"}", url.PathEscape(common.ParameterValueToString(r.merchantId, "merchantId")), -1)
	path = strings.Replace(path, "{"+"reference"+"}", url.PathEscape(common.ParameterValueToString(r.reference, "reference")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		r.terminalSettings,
		res,
		http.MethodPatch,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}

// All parameters accepted by TerminalSettingsStoreLevelApi.UpdateTerminalSettingsByStoreId
type TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput struct {
	storeId          string
	terminalSettings *TerminalSettings
}

func (r TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput) TerminalSettings(terminalSettings TerminalSettings) TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput {
	r.terminalSettings = &terminalSettings
	return r
}

/*
Prepare a request for UpdateTerminalSettingsByStoreId
@param storeId The unique identifier of the store.
@return TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalSettingsByStoreIdInput(storeId string) TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput {
	return TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput{
		storeId: storeId,
	}
}

/*
UpdateTerminalSettingsByStoreId Update terminal settings

Updates payment terminal settings for the store identified in the path. These settings apply to all terminals under the store, unless different values are configured for an individual terminal.

* To change a parameter value, include the full object that contains the parameter, even if you don't want to change all parameters in the object.
* To restore a parameter value inherited from a higher level, include the full object that contains the parameter, and specify an empty value for the parameter or omit the parameter.
* Objects that are not included in the request are not updated.

To make this request, your API credential must have the following [role](https://docs.adyen.com/development-resources/api-credentials#api-permissions):
* Management API—Terminal settings read and write

For [sensitive terminal settings](https://docs.adyen.com/point-of-sale/automating-terminal-management/configure-terminals-api#sensitive-terminal-settings), your API credential must have the following role:
* Management API—Terminal settings Advanced read and write

In the live environment, requests to this endpoint are subject to [rate limits](https://docs.adyen.com/point-of-sale/automating-terminal-management#rate-limits-in-the-live-environment).

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param r TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput - Request parameters, see UpdateTerminalSettingsByStoreIdInput
@return TerminalSettings, *http.Response, error
*/
func (a *TerminalSettingsStoreLevelApi) UpdateTerminalSettingsByStoreId(ctx context.Context, r TerminalSettingsStoreLevelApiUpdateTerminalSettingsByStoreIdInput) (TerminalSettings, *http.Response, error) {
	res := &TerminalSettings{}
	path := "/stores/{storeId}/terminalSettings"
	path = strings.Replace(path, "{"+"storeId"+"}", url.PathEscape(common.ParameterValueToString(r.storeId, "storeId")), -1)
	queryParams := url.Values{}
	headerParams := make(map[string]string)
	httpRes, err := common.SendAPIRequest(
		ctx,
		a.Client,
		r.terminalSettings,
		res,
		http.MethodPatch,
		a.BasePath()+path,
		queryParams,
		headerParams,
	)

	if httpRes == nil {
		return *res, httpRes, err
	}

	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
}
