Class: Io::Flow::V0::Models::Fulfillment

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Used to track and manage the fulfillment of an order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Fulfillment

Returns a new instance of Fulfillment.



19284
19285
19286
19287
19288
19289
19290
19291
19292
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19284

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:organization, :key, :number, :items], 'Fulfillment')
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FulfillmentItem) ? x : ::Io::Flow::V0::Models::FulfillmentItem.new(x)) }
  @center = (x = opts.delete(:center); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CenterSummary) ? x : ::Io::Flow::V0::Models::CenterSummary.new(x)))
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



19282
19283
19284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19282

def center
  @center
end

#itemsObject (readonly)

Returns the value of attribute items.



19282
19283
19284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19282

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



19282
19283
19284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19282

def key
  @key
end

#numberObject (readonly)

Returns the value of attribute number.



19282
19283
19284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19282

def number
  @number
end

#organizationObject (readonly)

Returns the value of attribute organization.



19282
19283
19284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19282

def organization
  @organization
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19298
19299
19300
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19298

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

#to_hashObject



19302
19303
19304
19305
19306
19307
19308
19309
19310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19302

def to_hash
  {
    :organization => organization,
    :key => key,
    :number => number,
    :items => items.map { |o| o.to_hash },
    :center => center.nil? ? nil : center.to_hash
  }
end

#to_jsonObject



19294
19295
19296
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19294

def to_json
  JSON.dump(to_hash)
end