/*
Adyen Checkout API

API version: 71
*/

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

package checkout

import (
	"encoding/json"
	"time"

	"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](https://www.iata.org/services/pages/codes.aspx) 2-letter accounting code (PAX) that identifies the carrier. This field is required if the airline data includes leg details. * Example: KLM = KL * minLength: 2 characters * maxLength: 2 characters * Must not start with a space or be all spaces. * Must not be all zeros.
	CarrierCode *string `json:"carrierCode,omitempty"`
	// A one-letter travel class identifier.  The following are common:  * F: first class * J: business class * Y: economy class * W: premium economy  * Encoding: ASCII * minLength: 1 character * maxLength: 1 character * Must not start with a space or be all spaces. * Must not be all zeros.
	ClassOfTravel *string `json:"classOfTravel,omitempty"`
	// Date and time of travel in format `yyyy-MM-ddTHH:mm`. * Use local time of departure airport. * minLength: 16 characters * maxLength: 16 characters
	DateOfTravel *time.Time `json:"dateOfTravel,omitempty"`
	// The [IATA](https://www.iata.org/services/pages/codes.aspx) three-letter airport code of the departure airport. This field is required if the airline data includes leg details.  * Encoding: ASCII * Example: Amsterdam = AMS * minLength: 3 characters * maxLength: 3 characters * Must not start with a space or be all spaces. * Must not be all zeros.
	DepartureAirportCode *string `json:"departureAirportCode,omitempty"`
	// The amount of [departure tax](https://en.wikipedia.org/wiki/Departure_tax) charged, in [minor units](https://docs.adyen.com/development-resources/currency-codes). * Encoding: Numeric * minLength: 1 * maxLength: 11 * Must not be all zeros.
	DepartureTax *int64 `json:"departureTax,omitempty"`
	// The [IATA](https://www.iata.org/services/pages/codes.aspx) 3-letter airport code of the destination airport. This field is required if the airline data includes leg details. * Example: Amsterdam = AMS * Encoding: ASCII * minLength: 3 characters * maxLength: 3 characters * Must not start with a space or be all spaces. * Must not be all zeros.
	DestinationAirportCode *string `json:"destinationAirportCode,omitempty"`
	// The [fare basis code](https://en.wikipedia.org/wiki/Fare_basis_code), alphanumeric. * minLength: 1 character * maxLength: 6 characters * Must not start with a space or be all spaces. * Must not be all zeros.
	FareBasisCode *string `json:"fareBasisCode,omitempty"`
	// The flight identifier. * minLength: 1 character * maxLength: 5 characters * Must not start with a space or be all spaces. * Must not be all zeros.
	FlightNumber *string `json:"flightNumber,omitempty"`
	// A one-letter code that indicates whether the passenger is entitled to make a stopover. Can be a space, O if the passenger is entitled to make a stopover, or X if they are not. * Encoding: ASCII * minLength: 1 character * maxLength: 1 character
	StopOverCode *string `json:"stopOverCode,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
}

// 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
}

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

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

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

	return false
}

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

// GetDateOfTravel returns the DateOfTravel field value if set, zero value otherwise.
func (o *Leg) GetDateOfTravel() time.Time {
	if o == nil || common.IsNil(o.DateOfTravel) {
		var ret time.Time
		return ret
	}
	return *o.DateOfTravel
}

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

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

	return false
}

// SetDateOfTravel gets a reference to the given time.Time and assigns it to the DateOfTravel field.
func (o *Leg) SetDateOfTravel(v time.Time) {
	o.DateOfTravel = &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
}

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

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

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

	return false
}

// SetDepartureTax gets a reference to the given int64 and assigns it to the DepartureTax field.
func (o *Leg) SetDepartureTax(v int64) {
	o.DepartureTax = &v
}

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

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

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

	return false
}

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

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

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

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

	return false
}

// SetFareBasisCode gets a reference to the given string and assigns it to the FareBasisCode field.
func (o *Leg) SetFareBasisCode(v string) {
	o.FareBasisCode = &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
}

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

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

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

	return false
}

// SetStopOverCode gets a reference to the given string and assigns it to the StopOverCode field.
func (o *Leg) SetStopOverCode(v string) {
	o.StopOverCode = &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.CarrierCode) {
		toSerialize["carrierCode"] = o.CarrierCode
	}
	if !common.IsNil(o.ClassOfTravel) {
		toSerialize["classOfTravel"] = o.ClassOfTravel
	}
	if !common.IsNil(o.DateOfTravel) {
		toSerialize["dateOfTravel"] = o.DateOfTravel
	}
	if !common.IsNil(o.DepartureAirportCode) {
		toSerialize["departureAirportCode"] = o.DepartureAirportCode
	}
	if !common.IsNil(o.DepartureTax) {
		toSerialize["departureTax"] = o.DepartureTax
	}
	if !common.IsNil(o.DestinationAirportCode) {
		toSerialize["destinationAirportCode"] = o.DestinationAirportCode
	}
	if !common.IsNil(o.FareBasisCode) {
		toSerialize["fareBasisCode"] = o.FareBasisCode
	}
	if !common.IsNil(o.FlightNumber) {
		toSerialize["flightNumber"] = o.FlightNumber
	}
	if !common.IsNil(o.StopOverCode) {
		toSerialize["stopOverCode"] = o.StopOverCode
	}
	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)
}
