/*
Transfers API

API version: 4
*/

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

package transfers

import (
	"encoding/json"

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

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

// Leg struct for Leg
type Leg struct {
	// The IATA 3-letter airport code of the destination airport. This field is required if the airline data includes leg details.
	ArrivalAirportCode *string `json:"arrivalAirportCode,omitempty"`
	// The basic fare code for this leg.
	BasicFareCode *string `json:"basicFareCode,omitempty"`
	// IATA code of the carrier operating the flight.
	CarrierCode *string `json:"carrierCode,omitempty"`
	// The IATA three-letter airport code of the departure airport. This field is required if the airline data includes leg details
	DepartureAirportCode *string `json:"departureAirportCode,omitempty"`
	// The flight departure date.
	DepartureDate *string `json:"departureDate,omitempty"`
	// The flight identifier.
	FlightNumber *string `json:"flightNumber,omitempty"`
}

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

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

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

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

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

	return false
}

// SetArrivalAirportCode gets a reference to the given string and assigns it to the ArrivalAirportCode field.
func (o *Leg) SetArrivalAirportCode(v string) {
	o.ArrivalAirportCode = &v
}

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

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

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

	return false
}

// SetBasicFareCode gets a reference to the given string and assigns it to the BasicFareCode field.
func (o *Leg) SetBasicFareCode(v string) {
	o.BasicFareCode = &v
}

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

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

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

	return false
}

// SetCarrierCode gets a reference to the given string and assigns it to the CarrierCode field.
func (o *Leg) SetCarrierCode(v string) {
	o.CarrierCode = &v
}

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

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

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

	return false
}

// SetDepartureAirportCode gets a reference to the given string and assigns it to the DepartureAirportCode field.
func (o *Leg) SetDepartureAirportCode(v string) {
	o.DepartureAirportCode = &v
}

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

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

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

	return false
}

// SetDepartureDate gets a reference to the given string and assigns it to the DepartureDate field.
func (o *Leg) SetDepartureDate(v string) {
	o.DepartureDate = &v
}

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

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

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

	return false
}

// SetFlightNumber gets a reference to the given string and assigns it to the FlightNumber field.
func (o *Leg) SetFlightNumber(v string) {
	o.FlightNumber = &v
}

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

func (o Leg) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !common.IsNil(o.ArrivalAirportCode) {
		toSerialize["arrivalAirportCode"] = o.ArrivalAirportCode
	}
	if !common.IsNil(o.BasicFareCode) {
		toSerialize["basicFareCode"] = o.BasicFareCode
	}
	if !common.IsNil(o.CarrierCode) {
		toSerialize["carrierCode"] = o.CarrierCode
	}
	if !common.IsNil(o.DepartureAirportCode) {
		toSerialize["departureAirportCode"] = o.DepartureAirportCode
	}
	if !common.IsNil(o.DepartureDate) {
		toSerialize["departureDate"] = o.DepartureDate
	}
	if !common.IsNil(o.FlightNumber) {
		toSerialize["flightNumber"] = o.FlightNumber
	}
	return toSerialize, nil
}

type NullableLeg struct {
	value *Leg
	isSet bool
}

func (v NullableLeg) Get() *Leg {
	return v.value
}

func (v *NullableLeg) Set(val *Leg) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableLeg(val *Leg) *NullableLeg {
	return &NullableLeg{value: val, isSet: true}
}

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

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