Class: Io::Flow::V0::Models::Carrier
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Carrier
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Partner that actually take a shipment between places (ex: FedEx, DHL, SF Express)
Instance Attribute Summary collapse
-
#facilities ⇒ Object
readonly
Returns the value of attribute facilities.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#visibility ⇒ Object
readonly
Returns the value of attribute visibility.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Carrier
constructor
A new instance of Carrier.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Carrier
Returns a new instance of Carrier.
13101 13102 13103 13104 13105 13106 13107 13108 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13101 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :name, :facilities, :visibility], 'Carrier') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @facilities = HttpClient::Preconditions.assert_class('facilities', opts.delete(:facilities), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x)) } @visibility = (x = opts.delete(:visibility); x.is_a?(::Io::Flow::V0::Models::Visibility) ? x : ::Io::Flow::V0::Models::Visibility.apply(x)) end |
Instance Attribute Details
#facilities ⇒ Object (readonly)
Returns the value of attribute facilities.
13099 13100 13101 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13099 def facilities @facilities end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13099 13100 13101 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13099 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13099 13100 13101 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13099 def name @name end |
#visibility ⇒ Object (readonly)
Returns the value of attribute visibility.
13099 13100 13101 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13099 def visibility @visibility end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
13114 13115 13116 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13114 def copy(incoming={}) Carrier.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
13118 13119 13120 13121 13122 13123 13124 13125 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13118 def to_hash { :id => id, :name => name, :facilities => facilities.map { |o| o.to_hash }, :visibility => visibility.value } end |
#to_json ⇒ Object
13110 13111 13112 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13110 def to_json JSON.dump(to_hash) end |