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.



25366
25367
25368
25369
25370
25371
25372
25373
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25366

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

#idObject (readonly)

Returns the value of attribute id.



25364
25365
25366
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25364

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



25364
25365
25366
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25364

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



25364
25365
25366
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25364

def key
  @key
end

#labelsObject (readonly)

Returns the value of attribute labels.



25364
25365
25366
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25364

def labels
  @labels
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



25379
25380
25381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25379

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

#to_hashObject



25383
25384
25385
25386
25387
25388
25389
25390
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25383

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

#to_jsonObject



25375
25376
25377
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25375

def to_json
  JSON.dump(to_hash)
end