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.



71736
71737
71738
71739
71740
71741
71742
71743
71744
71745
71746
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71736

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.



71734
71735
71736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71734

def destinations
  @destinations
end

#effective_atObject (readonly)

Returns the value of attribute effective_at.



71734
71735
71736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71734

def effective_at
  @effective_at
end

#keyObject (readonly)

Returns the value of attribute key.



71734
71735
71736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71734

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



71734
71735
71736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71734

def name
  @name
end

#originsObject (readonly)

Returns the value of attribute origins.



71734
71735
71736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71734

def origins
  @origins
end

#ship_fromObject (readonly)

Returns the value of attribute ship_from.



71734
71735
71736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71734

def ship_from
  @ship_from
end

#statusObject (readonly)

Returns the value of attribute status.



71734
71735
71736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71734

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



71752
71753
71754
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71752

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

#to_hashObject



71756
71757
71758
71759
71760
71761
71762
71763
71764
71765
71766
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71756

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



71748
71749
71750
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71748

def to_json
  JSON.dump(to_hash)
end