Class: Io::Flow::V0::Models::AvailablePromotion

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ AvailablePromotion

Returns a new instance of AvailablePromotion.



23829
23830
23831
23832
23833
23834
23835
23836
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23829

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :shipping_configuration, :region, :promotions], 'AvailablePromotion')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @shipping_configuration = (x = opts.delete(:shipping_configuration); x.is_a?(::Io::Flow::V0::Models::ShippingConfigurationReference) ? x : ::Io::Flow::V0::Models::ShippingConfigurationReference.new(x))
  @region = (x = opts.delete(:region); x.is_a?(::Io::Flow::V0::Models::RegionReference) ? x : ::Io::Flow::V0::Models::RegionReference.new(x))
  @promotions = HttpClient::Preconditions.assert_class('promotions', opts.delete(:promotions), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Promotion) ? x : ::Io::Flow::V0::Models::Promotion.from_json(x)) }
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



23827
23828
23829
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23827

def id
  @id
end

#promotionsObject (readonly)

Returns the value of attribute promotions.



23827
23828
23829
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23827

def promotions
  @promotions
end

#regionObject (readonly)

Returns the value of attribute region.



23827
23828
23829
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23827

def region
  @region
end

#shipping_configurationObject (readonly)

Returns the value of attribute shipping_configuration.



23827
23828
23829
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23827

def shipping_configuration
  @shipping_configuration
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



23842
23843
23844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23842

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

#to_hashObject



23846
23847
23848
23849
23850
23851
23852
23853
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23846

def to_hash
  {
    :id => id,
    :shipping_configuration => shipping_configuration.to_hash,
    :region => region.to_hash,
    :promotions => promotions.map { |o| o.to_hash }
  }
end

#to_jsonObject



23838
23839
23840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23838

def to_json
  JSON.dump(to_hash)
end