/*
Adyen Balance Control API

API version: 1
*/

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

package balancecontrol

import (
	"encoding/json"

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

// checks if the BalanceTransferRequest type satisfies the MappedNullable interface at compile time
var _ common.MappedNullable = &BalanceTransferRequest{}

// BalanceTransferRequest struct for BalanceTransferRequest
type BalanceTransferRequest struct {
	Amount Amount `json:"amount"`
	// A human-readable description for the transfer. You can use alphanumeric characters and hyphens. We recommend sending a maximum of 140 characters, otherwise the description may be truncated.
	Description *string `json:"description,omitempty"`
	// The unique identifier of the source merchant account from which funds are deducted.
	FromMerchant string `json:"fromMerchant"`
	// A reference for the balance transfer. If you don't provide this in the request, Adyen generates a unique reference. Maximum length: 80 characters.
	Reference *string `json:"reference,omitempty"`
	// The unique identifier of the destination merchant account from which funds are transferred.
	ToMerchant string `json:"toMerchant"`
	// The type of balance transfer. Possible values: **tax**, **fee**, **terminalSale**, **credit**, **debit**, and **adjustment**.
	Type string `json:"type"`
}

// NewBalanceTransferRequest instantiates a new BalanceTransferRequest object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBalanceTransferRequest(amount Amount, fromMerchant string, toMerchant string, type_ string) *BalanceTransferRequest {
	this := BalanceTransferRequest{}
	this.Amount = amount
	this.FromMerchant = fromMerchant
	this.ToMerchant = toMerchant
	this.Type = type_
	return &this
}

// NewBalanceTransferRequestWithDefaults instantiates a new BalanceTransferRequest object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBalanceTransferRequestWithDefaults() *BalanceTransferRequest {
	this := BalanceTransferRequest{}
	return &this
}

// GetAmount returns the Amount field value
func (o *BalanceTransferRequest) GetAmount() Amount {
	if o == nil {
		var ret Amount
		return ret
	}

	return o.Amount
}

// GetAmountOk returns a tuple with the Amount field value
// and a boolean to check if the value has been set.
func (o *BalanceTransferRequest) GetAmountOk() (*Amount, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Amount, true
}

// SetAmount sets field value
func (o *BalanceTransferRequest) SetAmount(v Amount) {
	o.Amount = v
}

// GetDescription returns the Description field value if set, zero value otherwise.
func (o *BalanceTransferRequest) GetDescription() string {
	if o == nil || common.IsNil(o.Description) {
		var ret string
		return ret
	}
	return *o.Description
}

// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *BalanceTransferRequest) GetDescriptionOk() (*string, bool) {
	if o == nil || common.IsNil(o.Description) {
		return nil, false
	}
	return o.Description, true
}

// HasDescription returns a boolean if a field has been set.
func (o *BalanceTransferRequest) HasDescription() bool {
	if o != nil && !common.IsNil(o.Description) {
		return true
	}

	return false
}

// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *BalanceTransferRequest) SetDescription(v string) {
	o.Description = &v
}

// GetFromMerchant returns the FromMerchant field value
func (o *BalanceTransferRequest) GetFromMerchant() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.FromMerchant
}

// GetFromMerchantOk returns a tuple with the FromMerchant field value
// and a boolean to check if the value has been set.
func (o *BalanceTransferRequest) GetFromMerchantOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.FromMerchant, true
}

// SetFromMerchant sets field value
func (o *BalanceTransferRequest) SetFromMerchant(v string) {
	o.FromMerchant = v
}

// GetReference returns the Reference field value if set, zero value otherwise.
func (o *BalanceTransferRequest) GetReference() string {
	if o == nil || common.IsNil(o.Reference) {
		var ret string
		return ret
	}
	return *o.Reference
}

// GetReferenceOk returns a tuple with the Reference field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *BalanceTransferRequest) GetReferenceOk() (*string, bool) {
	if o == nil || common.IsNil(o.Reference) {
		return nil, false
	}
	return o.Reference, true
}

// HasReference returns a boolean if a field has been set.
func (o *BalanceTransferRequest) HasReference() bool {
	if o != nil && !common.IsNil(o.Reference) {
		return true
	}

	return false
}

// SetReference gets a reference to the given string and assigns it to the Reference field.
func (o *BalanceTransferRequest) SetReference(v string) {
	o.Reference = &v
}

// GetToMerchant returns the ToMerchant field value
func (o *BalanceTransferRequest) GetToMerchant() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ToMerchant
}

// GetToMerchantOk returns a tuple with the ToMerchant field value
// and a boolean to check if the value has been set.
func (o *BalanceTransferRequest) GetToMerchantOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.ToMerchant, true
}

// SetToMerchant sets field value
func (o *BalanceTransferRequest) SetToMerchant(v string) {
	o.ToMerchant = v
}

// GetType returns the Type field value
func (o *BalanceTransferRequest) GetType() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Type
}

// GetTypeOk returns a tuple with the Type field value
// and a boolean to check if the value has been set.
func (o *BalanceTransferRequest) GetTypeOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Type, true
}

// SetType sets field value
func (o *BalanceTransferRequest) SetType(v string) {
	o.Type = v
}

func (o BalanceTransferRequest) MarshalJSON() ([]byte, error) {
	toSerialize, err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o BalanceTransferRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["amount"] = o.Amount
	if !common.IsNil(o.Description) {
		toSerialize["description"] = o.Description
	}
	toSerialize["fromMerchant"] = o.FromMerchant
	if !common.IsNil(o.Reference) {
		toSerialize["reference"] = o.Reference
	}
	toSerialize["toMerchant"] = o.ToMerchant
	toSerialize["type"] = o.Type
	return toSerialize, nil
}

type NullableBalanceTransferRequest struct {
	value *BalanceTransferRequest
	isSet bool
}

func (v NullableBalanceTransferRequest) Get() *BalanceTransferRequest {
	return v.value
}

func (v *NullableBalanceTransferRequest) Set(val *BalanceTransferRequest) {
	v.value = val
	v.isSet = true
}

func (v NullableBalanceTransferRequest) IsSet() bool {
	return v.isSet
}

func (v *NullableBalanceTransferRequest) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableBalanceTransferRequest(val *BalanceTransferRequest) *NullableBalanceTransferRequest {
	return &NullableBalanceTransferRequest{value: val, isSet: true}
}

func (v NullableBalanceTransferRequest) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableBalanceTransferRequest) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}

func (o *BalanceTransferRequest) isValidType() bool {
	var allowedEnumValues = []string{"tax", "fee", "terminalSale", "credit", "debit", "adjustment"}
	for _, allowed := range allowedEnumValues {
		if o.GetType() == allowed {
			return true
		}
	}
	return false
}
