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.



37467
37468
37469
37470
37471
37472
37473
37474
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37467

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.



37465
37466
37467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37465

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



37465
37466
37467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37465

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



37465
37466
37467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37465

def key
  @key
end

#labelsObject (readonly)

Returns the value of attribute labels.



37465
37466
37467
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37465

def labels
  @labels
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37480
37481
37482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37480

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

#to_hashObject



37484
37485
37486
37487
37488
37489
37490
37491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37484

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

#to_jsonObject



37476
37477
37478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37476

def to_json
  JSON.dump(to_hash)
end