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.



14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14821

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

#addressObject (readonly)

Returns the value of attribute address.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def address
  @address
end

#idObject (readonly)

Returns the value of attribute id.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def name
  @name
end

#packagingObject (readonly)

Returns the value of attribute packaging.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def packaging
  @packaging
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def schedule
  @schedule
end

#servicesObject (readonly)

Returns the value of attribute services.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def services
  @services
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



14819
14820
14821
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14819

def timezone
  @timezone
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14838
14839
14840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14838

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

#to_hashObject



14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14842

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_jsonObject



14834
14835
14836
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14834

def to_json
  JSON.dump(to_hash)
end