Class: Io::Flow::V0::Models::DiscountRuleSettingsForm

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

Returns a new instance of DiscountRuleSettingsForm.



28943
28944
28945
28946
28947
28948
28949
28950
28951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28943

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name, :from, :experience_keys, :rule], 'DiscountRuleSettingsForm')
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @from = HttpClient::Preconditions.assert_class('from', HttpClient::Helper.to_date_time_iso8601(opts.delete(:from)), DateTime)
  @to = (x = opts.delete(:to); x.nil? ? nil : HttpClient::Preconditions.assert_class('to', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @experience_keys = HttpClient::Preconditions.assert_class('experience_keys', opts.delete(:experience_keys), Array).map { |v| HttpClient::Preconditions.assert_class('experience_keys', v, String) }
  @rule = (x = opts.delete(:rule); x.is_a?(::Io::Flow::V0::Models::DiscountRule) ? x : ::Io::Flow::V0::Models::DiscountRule.new(x))
end

Instance Attribute Details

#experience_keysObject (readonly)

Returns the value of attribute experience_keys.



28941
28942
28943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28941

def experience_keys
  @experience_keys
end

#fromObject (readonly)

Returns the value of attribute from.



28941
28942
28943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28941

def from
  @from
end

#nameObject (readonly)

Returns the value of attribute name.



28941
28942
28943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28941

def name
  @name
end

#ruleObject (readonly)

Returns the value of attribute rule.



28941
28942
28943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28941

def rule
  @rule
end

#toObject (readonly)

Returns the value of attribute to.



28941
28942
28943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28941

def to
  @to
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28957
28958
28959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28957

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

#to_hashObject



28961
28962
28963
28964
28965
28966
28967
28968
28969
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28961

def to_hash
  {
    :name => name,
    :from => from,
    :to => to,
    :experience_keys => experience_keys,
    :rule => rule.to_hash
  }
end

#to_jsonObject



28953
28954
28955
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28953

def to_json
  JSON.dump(to_hash)
end