Class: Io::Flow::V0::Models::TierForm

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 = {}) ⇒ TierForm

Returns a new instance of TierForm.



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

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:currency, :experience, :integration, :name, :rules, :services, :strategy, :visibility], 'TierForm')
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @experience = HttpClient::Preconditions.assert_class('experience', opts.delete(:experience), String)
  @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::TierRuleForm) ? x : ::Io::Flow::V0::Models::TierRuleForm.new(x)) }
  @services = HttpClient::Preconditions.assert_class('services', opts.delete(:services), Array).map { |v| HttpClient::Preconditions.assert_class('services', v, String) }
  @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

#currency ⇒ Object (readonly)

Returns the value of attribute currency.



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

def currency
  @currency
end

#description ⇒ Object (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#experience ⇒ Object (readonly)

Returns the value of attribute experience.



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

def experience
  @experience
end

#integration ⇒ Object (readonly)

Returns the value of attribute integration.



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

def integration
  @integration
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#rules ⇒ Object (readonly)

Returns the value of attribute rules.



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

def rules
  @rules
end

#services ⇒ Object (readonly)

Returns the value of attribute services.



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

def services
  @services
end

#strategy ⇒ Object (readonly)

Returns the value of attribute strategy.



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

def strategy
  @strategy
end

#visibility ⇒ Object (readonly)

Returns the value of attribute visibility.



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

def visibility
  @visibility
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21607
21608
21609
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21607

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

#to_hash ⇒ Object



21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21611

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

#to_json ⇒ Object



21603
21604
21605
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21603

def to_json
  JSON.dump(to_hash)
end