Class: Io::Flow::V0::Models::TradeAgreement

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TradeAgreement

Returns a new instance of TradeAgreement.



66596
66597
66598
66599
66600
66601
66602
66603
66604
66605
66606
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66596

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key, :name, :origins, :destinations, :effective_at, :status], 'TradeAgreement')
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @name = (x = opts.delete(:name); x.is_a?(::Io::Flow::V0::Models::TradeAgreementName) ? x : ::Io::Flow::V0::Models::TradeAgreementName.apply(x))
  @origins = HttpClient::Preconditions.assert_class('origins', opts.delete(:origins), Array).map { |v| HttpClient::Preconditions.assert_class('origins', v, String) }
  @destinations = HttpClient::Preconditions.assert_class('destinations', opts.delete(:destinations), Array).map { |v| HttpClient::Preconditions.assert_class('destinations', v, String) }
  @ship_from = (x = opts.delete(:ship_from); x.nil? ? nil : HttpClient::Preconditions.assert_class('ship_from', x, Array).map { |v| HttpClient::Preconditions.assert_class('ship_from', v, String) })
  @effective_at = HttpClient::Preconditions.assert_class('effective_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:effective_at)), DateTime)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::TradeAgreementStatus) ? x : ::Io::Flow::V0::Models::TradeAgreementStatus.apply(x))
end

Instance Attribute Details

#destinationsObject (readonly)

Returns the value of attribute destinations.



66594
66595
66596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66594

def destinations
  @destinations
end

#effective_atObject (readonly)

Returns the value of attribute effective_at.



66594
66595
66596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66594

def effective_at
  @effective_at
end

#keyObject (readonly)

Returns the value of attribute key.



66594
66595
66596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66594

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



66594
66595
66596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66594

def name
  @name
end

#originsObject (readonly)

Returns the value of attribute origins.



66594
66595
66596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66594

def origins
  @origins
end

#ship_fromObject (readonly)

Returns the value of attribute ship_from.



66594
66595
66596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66594

def ship_from
  @ship_from
end

#statusObject (readonly)

Returns the value of attribute status.



66594
66595
66596
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66594

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



66612
66613
66614
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66612

def copy(incoming={})
  TradeAgreement.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



66616
66617
66618
66619
66620
66621
66622
66623
66624
66625
66626
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66616

def to_hash
  {
    :key => key,
    :name => name.value,
    :origins => origins,
    :destinations => destinations,
    :ship_from => ship_from.nil? ? nil : ship_from,
    :effective_at => effective_at,
    :status => status.value
  }
end

#to_jsonObject



66608
66609
66610
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 66608

def to_json
  JSON.dump(to_hash)
end