class Io::Flow::V0::Models::TradeAgreement

Attributes

destinations[R]
effective_at[R]
key[R]
name[R]
origins[R]
ship_from[R]
status[R]

Public Class Methods

new(incoming={}) click to toggle source
# 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

Public Instance Methods

copy(incoming={}) click to toggle source
# 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_hash() click to toggle source
# 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_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 71748
def to_json
  JSON.dump(to_hash)
end