Class: Io::Flow::V0::Models::ReturnForm

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

Returns a new instance of ReturnForm.



25339
25340
25341
25342
25343
25344
25345
25346
25347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25339

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:items], 'ReturnForm')
  @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)) }
  @service = (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, String))
  @destination = (x = opts.delete(:destination); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x)))
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
  @origin = (x = opts.delete(:origin); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x)))
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



25337
25338
25339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25337

def destination
  @destination
end

#itemsObject (readonly)

Returns the value of attribute items.



25337
25338
25339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25337

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



25337
25338
25339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25337

def key
  @key
end

#originObject (readonly)

Returns the value of attribute origin.



25337
25338
25339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25337

def origin
  @origin
end

#serviceObject (readonly)

Returns the value of attribute service.



25337
25338
25339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25337

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



25353
25354
25355
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25353

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

#to_hashObject



25357
25358
25359
25360
25361
25362
25363
25364
25365
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25357

def to_hash
  {
    :items => items.map { |o| o.to_hash },
    :service => service,
    :destination => destination.nil? ? nil : destination.to_hash,
    :key => key,
    :origin => origin.nil? ? nil : origin.to_hash
  }
end

#to_jsonObject



25349
25350
25351
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25349

def to_json
  JSON.dump(to_hash)
end