Class: Io::Flow::V0::Models::Promotions

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

Returns a new instance of Promotions.



61034
61035
61036
61037
61038
61039
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61034

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:applied, :available], 'Promotions')
  @applied = HttpClient::Preconditions.assert_class('applied', opts.delete(:applied), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Promotion) ? x : ::Io::Flow::V0::Models::Promotion.from_json(x)) }
  @available = HttpClient::Preconditions.assert_class('available', opts.delete(:available), 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

#appliedObject (readonly)

Returns the value of attribute applied.



61032
61033
61034
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61032

def applied
  @applied
end

#availableObject (readonly)

Returns the value of attribute available.



61032
61033
61034
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61032

def available
  @available
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



61045
61046
61047
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61045

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

#to_hashObject



61049
61050
61051
61052
61053
61054
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61049

def to_hash
  {
    :applied => applied.map { |o| o.to_hash },
    :available => available.map { |o| o.to_hash }
  }
end

#to_jsonObject



61041
61042
61043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61041

def to_json
  JSON.dump(to_hash)
end