Class: Io::Flow::V0::Models::Carrier

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Carrier

Returns a new instance of Carrier.



14095
14096
14097
14098
14099
14100
14101
14102
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14095

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

#facilitiesObject (readonly)

Returns the value of attribute facilities.



14093
14094
14095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14093

def facilities
  @facilities
end

#idObject (readonly)

Returns the value of attribute id.



14093
14094
14095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14093

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



14093
14094
14095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14093

def name
  @name
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



14093
14094
14095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14093

def visibility
  @visibility
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14108
14109
14110
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14108

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

#to_hashObject



14112
14113
14114
14115
14116
14117
14118
14119
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14112

def to_hash
  {
    :id => id,
    :name => name,
    :facilities => facilities.map { |o| o.to_hash },
    :visibility => visibility.value
  }
end

#to_jsonObject



14104
14105
14106
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14104

def to_json
  JSON.dump(to_hash)
end