Class: Io::Flow::V0::Models::Tier

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

Overview

Service shipping tier available in this tier gorup. e.g. Standard tier, Express tier, Economy tier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Tier

Returns a new instance of Tier.



21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21569

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :experience, :integration, :name, :rules, :services, :strategy, :visibility], 'Tier')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @experience = (x = opts.delete(:experience); x.is_a?(::Io::Flow::V0::Models::FulfillmentExperienceReference) ? x : ::Io::Flow::V0::Models::FulfillmentExperienceReference.new(x))
  @integration = (x = opts.delete(:integration); x.is_a?(::Io::Flow::V0::Models::ShipmentIntegrationType) ? x : ::Io::Flow::V0::Models::ShipmentIntegrationType.apply(x))
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @rules = HttpClient::Preconditions.assert_class('rules', opts.delete(:rules), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::TierRule) ? x : ::Io::Flow::V0::Models::TierRule.new(x)) }
  @services = HttpClient::Preconditions.assert_class('services', opts.delete(:services), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Service) ? x : ::Io::Flow::V0::Models::Service.new(x)) }
  @strategy = (x = opts.delete(:strategy); x.is_a?(::Io::Flow::V0::Models::TierStrategy) ? x : ::Io::Flow::V0::Models::TierStrategy.apply(x))
  @visibility = (x = opts.delete(:visibility); x.is_a?(::Io::Flow::V0::Models::Visibility) ? x : ::Io::Flow::V0::Models::Visibility.apply(x))
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def description
  @description
end

#experienceObject (readonly)

Returns the value of attribute experience.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def experience
  @experience
end

#idObject (readonly)

Returns the value of attribute id.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def id
  @id
end

#integrationObject (readonly)

Returns the value of attribute integration.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def integration
  @integration
end

#nameObject (readonly)

Returns the value of attribute name.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def name
  @name
end

#rulesObject (readonly)

Returns the value of attribute rules.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def rules
  @rules
end

#servicesObject (readonly)

Returns the value of attribute services.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def services
  @services
end

#strategyObject (readonly)

Returns the value of attribute strategy.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def strategy
  @strategy
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



21567
21568
21569
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21567

def visibility
  @visibility
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21587
21588
21589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21587

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

#to_hashObject



21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21591

def to_hash
  {
    :id => id,
    :experience => experience.to_hash,
    :integration => integration.value,
    :name => name,
    :rules => rules.map { |o| o.to_hash },
    :services => services.map { |o| o.to_hash },
    :strategy => strategy.value,
    :visibility => visibility.value,
    :description => description
  }
end

#to_jsonObject



21583
21584
21585
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21583

def to_json
  JSON.dump(to_hash)
end