Class: Io::Flow::V0::Models::Return

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 = {}) ⇒ Return

Returns a new instance of Return.



19347
19348
19349
19350
19351
19352
19353
19354
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19347

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :items, :labels], 'Return')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ReturnLineItem) ? x : ::Io::Flow::V0::Models::ReturnLineItem.new(x)) }
  @labels = HttpClient::Preconditions.assert_class('labels', opts.delete(:labels), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShippingLabel) ? x : ::Io::Flow::V0::Models::ShippingLabel.new(x)) }
end

Instance Attribute Details

#id ⇒ Object (readonly)

Returns the value of attribute id.



19345
19346
19347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19345

def id
  @id
end

#items ⇒ Object (readonly)

Returns the value of attribute items.



19345
19346
19347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19345

def items
  @items
end

#key ⇒ Object (readonly)

Returns the value of attribute key.



19345
19346
19347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19345

def key
  @key
end

#labels ⇒ Object (readonly)

Returns the value of attribute labels.



19345
19346
19347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19345

def labels
  @labels
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19360
19361
19362
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19360

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

#to_hash ⇒ Object



19364
19365
19366
19367
19368
19369
19370
19371
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19364

def to_hash
  {
    :id => id,
    :key => key,
    :items => items.map { |o| o.to_hash },
    :labels => labels.map { |o| o.to_hash }
  }
end

#to_json ⇒ Object



19356
19357
19358
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19356

def to_json
  JSON.dump(to_hash)
end