/*
OPEN OUTCRY API

# Introduction This API is documented in **OpenAPI 3.0 format**.  This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades  # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded.

API version: 1.0.0
*/

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

package api

import (
	"encoding/json"
	"fmt"
)

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

// Payment struct for Payment
type Payment struct {
	Id     string      `json:"id"`
	Type   PaymentType `json:"type"`
	Amount float64     `json:"amount"`
	// ISO 4217 Currency symbol
	Currency                string   `json:"currency"`
	SenderAccountId         string   `json:"senderAccountId"`
	BeneficiaryAccountId    string   `json:"beneficiaryAccountId"`
	Details                 string   `json:"details"`
	ExternalReferenceNumber string   `json:"externalReferenceNumber"`
	Status                  string   `json:"status"`
	DebitBalanceAmount      *float64 `json:"debitBalanceAmount,omitempty"`
	CreditBalanceAmount     *float64 `json:"creditBalanceAmount,omitempty"`
}

type _Payment Payment

// NewPayment instantiates a new Payment 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 NewPayment(id string, type_ PaymentType, amount float64, currency string, senderAccountId string, beneficiaryAccountId string, details string, externalReferenceNumber string, status string) *Payment {
	this := Payment{}
	this.Id = id
	this.Type = type_
	this.Amount = amount
	this.Currency = currency
	this.SenderAccountId = senderAccountId
	this.BeneficiaryAccountId = beneficiaryAccountId
	this.Details = details
	this.ExternalReferenceNumber = externalReferenceNumber
	this.Status = status
	return &this
}

// NewPaymentWithDefaults instantiates a new Payment 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 NewPaymentWithDefaults() *Payment {
	this := Payment{}
	return &this
}

// GetId returns the Id field value
func (o *Payment) GetId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Id
}

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

// SetId sets field value
func (o *Payment) SetId(v string) {
	o.Id = v
}

// GetType returns the Type field value
func (o *Payment) GetType() PaymentType {
	if o == nil {
		var ret PaymentType
		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 *Payment) GetTypeOk() (*PaymentType, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Type, true
}

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

// GetAmount returns the Amount field value
func (o *Payment) GetAmount() float64 {
	if o == nil {
		var ret float64
		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 *Payment) GetAmountOk() (*float64, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Amount, true
}

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

// GetCurrency returns the Currency field value
func (o *Payment) GetCurrency() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Currency
}

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

// SetCurrency sets field value
func (o *Payment) SetCurrency(v string) {
	o.Currency = v
}

// GetSenderAccountId returns the SenderAccountId field value
func (o *Payment) GetSenderAccountId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SenderAccountId
}

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

// SetSenderAccountId sets field value
func (o *Payment) SetSenderAccountId(v string) {
	o.SenderAccountId = v
}

// GetBeneficiaryAccountId returns the BeneficiaryAccountId field value
func (o *Payment) GetBeneficiaryAccountId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.BeneficiaryAccountId
}

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

// SetBeneficiaryAccountId sets field value
func (o *Payment) SetBeneficiaryAccountId(v string) {
	o.BeneficiaryAccountId = v
}

// GetDetails returns the Details field value
func (o *Payment) GetDetails() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Details
}

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

// SetDetails sets field value
func (o *Payment) SetDetails(v string) {
	o.Details = v
}

// GetExternalReferenceNumber returns the ExternalReferenceNumber field value
func (o *Payment) GetExternalReferenceNumber() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ExternalReferenceNumber
}

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

// SetExternalReferenceNumber sets field value
func (o *Payment) SetExternalReferenceNumber(v string) {
	o.ExternalReferenceNumber = v
}

// GetStatus returns the Status field value
func (o *Payment) GetStatus() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Status
}

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

// SetStatus sets field value
func (o *Payment) SetStatus(v string) {
	o.Status = v
}

// GetDebitBalanceAmount returns the DebitBalanceAmount field value if set, zero value otherwise.
func (o *Payment) GetDebitBalanceAmount() float64 {
	if o == nil || IsNil(o.DebitBalanceAmount) {
		var ret float64
		return ret
	}
	return *o.DebitBalanceAmount
}

// GetDebitBalanceAmountOk returns a tuple with the DebitBalanceAmount field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Payment) GetDebitBalanceAmountOk() (*float64, bool) {
	if o == nil || IsNil(o.DebitBalanceAmount) {
		return nil, false
	}
	return o.DebitBalanceAmount, true
}

// HasDebitBalanceAmount returns a boolean if a field has been set.
func (o *Payment) HasDebitBalanceAmount() bool {
	if o != nil && !IsNil(o.DebitBalanceAmount) {
		return true
	}

	return false
}

// SetDebitBalanceAmount gets a reference to the given float64 and assigns it to the DebitBalanceAmount field.
func (o *Payment) SetDebitBalanceAmount(v float64) {
	o.DebitBalanceAmount = &v
}

// GetCreditBalanceAmount returns the CreditBalanceAmount field value if set, zero value otherwise.
func (o *Payment) GetCreditBalanceAmount() float64 {
	if o == nil || IsNil(o.CreditBalanceAmount) {
		var ret float64
		return ret
	}
	return *o.CreditBalanceAmount
}

// GetCreditBalanceAmountOk returns a tuple with the CreditBalanceAmount field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Payment) GetCreditBalanceAmountOk() (*float64, bool) {
	if o == nil || IsNil(o.CreditBalanceAmount) {
		return nil, false
	}
	return o.CreditBalanceAmount, true
}

// HasCreditBalanceAmount returns a boolean if a field has been set.
func (o *Payment) HasCreditBalanceAmount() bool {
	if o != nil && !IsNil(o.CreditBalanceAmount) {
		return true
	}

	return false
}

// SetCreditBalanceAmount gets a reference to the given float64 and assigns it to the CreditBalanceAmount field.
func (o *Payment) SetCreditBalanceAmount(v float64) {
	o.CreditBalanceAmount = &v
}

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

func (o Payment) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	toSerialize["type"] = o.Type
	toSerialize["amount"] = o.Amount
	toSerialize["currency"] = o.Currency
	toSerialize["senderAccountId"] = o.SenderAccountId
	toSerialize["beneficiaryAccountId"] = o.BeneficiaryAccountId
	toSerialize["details"] = o.Details
	toSerialize["externalReferenceNumber"] = o.ExternalReferenceNumber
	toSerialize["status"] = o.Status
	if !IsNil(o.DebitBalanceAmount) {
		toSerialize["debitBalanceAmount"] = o.DebitBalanceAmount
	}
	if !IsNil(o.CreditBalanceAmount) {
		toSerialize["creditBalanceAmount"] = o.CreditBalanceAmount
	}
	return toSerialize, nil
}

func (o *Payment) UnmarshalJSON(bytes []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"id",
		"type",
		"amount",
		"currency",
		"senderAccountId",
		"beneficiaryAccountId",
		"details",
		"externalReferenceNumber",
		"status",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(bytes, &allProperties)

	if err != nil {
		return err
	}

	for _, requiredProperty := range requiredProperties {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varPayment := _Payment{}

	err = json.Unmarshal(bytes, &varPayment)

	if err != nil {
		return err
	}

	*o = Payment(varPayment)

	return err
}

type NullablePayment struct {
	value *Payment
	isSet bool
}

func (v NullablePayment) Get() *Payment {
	return v.value
}

func (v *NullablePayment) Set(val *Payment) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullablePayment(val *Payment) *NullablePayment {
	return &NullablePayment{value: val, isSet: true}
}

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

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