Class: Io::Flow::V0::Models::Center

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

Overview

Represents a facility capable of fulfilling a shipment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Center

Returns a new instance of Center.



11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11035

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :address, :packaging, :name, :services, :schedule, :timezone], 'Center')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @address = (x = opts.delete(:address); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @packaging = HttpClient::Preconditions.assert_class('packaging', opts.delete(:packaging), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Packaging) ? x : ::Io::Flow::V0::Models::Packaging.new(x)) }
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @services = HttpClient::Preconditions.assert_class('services', opts.delete(:services), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AvailableService) ? x : ::Io::Flow::V0::Models::AvailableService.new(x)) }
  @schedule = (x = opts.delete(:schedule); x.is_a?(::Io::Flow::V0::Models::Schedule) ? x : ::Io::Flow::V0::Models::Schedule.new(x))
  @timezone = HttpClient::Preconditions.assert_class('timezone', opts.delete(:timezone), String)
end

Instance Attribute Details

#address ⇒ Object (readonly)

Returns the value of attribute address.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def address
  @address
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def id
  @id
end

#key ⇒ Object (readonly)

Returns the value of attribute key.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def key
  @key
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def name
  @name
end

#packaging ⇒ Object (readonly)

Returns the value of attribute packaging.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def packaging
  @packaging
end

#schedule ⇒ Object (readonly)

Returns the value of attribute schedule.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def schedule
  @schedule
end

#services ⇒ Object (readonly)

Returns the value of attribute services.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def services
  @services
end

#timezone ⇒ Object (readonly)

Returns the value of attribute timezone.



11033
11034
11035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11033

def timezone
  @timezone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11052
11053
11054
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11052

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

#to_hash ⇒ Object



11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11056

def to_hash
  {
    :id => id,
    :key => key,
    :address => address.to_hash,
    :packaging => packaging.map { |o| o.to_hash },
    :name => name,
    :services => services.map { |o| o.to_hash },
    :schedule => schedule.to_hash,
    :timezone => timezone
  }
end

#to_json ⇒ Object



11048
11049
11050
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11048

def to_json
  JSON.dump(to_hash)
end