Class: Io::Flow::V0::Models::DiscountRuleSettings

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

Returns a new instance of DiscountRuleSettings.



36951
36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36951

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :name, :from_with_tz, :status, :experience_keys, :rule], 'DiscountRuleSettings')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @from_with_tz = (x = opts.delete(:from_with_tz); x.is_a?(::Io::Flow::V0::Models::DatetimeWithTimezone) ? x : ::Io::Flow::V0::Models::DatetimeWithTimezone.new(x))
  @to_with_tz = (x = opts.delete(:to_with_tz); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DatetimeWithTimezone) ? x : ::Io::Flow::V0::Models::DatetimeWithTimezone.new(x)))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::DiscountRuleStatus) ? x : ::Io::Flow::V0::Models::DiscountRuleStatus.apply(x))
  @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.



36949
36950
36951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36949

def experience_keys
  @experience_keys
end

#from_with_tzObject (readonly)

Returns the value of attribute from_with_tz.



36949
36950
36951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36949

def from_with_tz
  @from_with_tz
end

#idObject (readonly)

Returns the value of attribute id.



36949
36950
36951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36949

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



36949
36950
36951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36949

def name
  @name
end

#ruleObject (readonly)

Returns the value of attribute rule.



36949
36950
36951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36949

def rule
  @rule
end

#statusObject (readonly)

Returns the value of attribute status.



36949
36950
36951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36949

def status
  @status
end

#to_with_tzObject (readonly)

Returns the value of attribute to_with_tz.



36949
36950
36951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36949

def to_with_tz
  @to_with_tz
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36967
36968
36969
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36967

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

#to_hashObject



36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36971

def to_hash
  {
    :id => id,
    :name => name,
    :from_with_tz => from_with_tz.to_hash,
    :to_with_tz => to_with_tz.nil? ? nil : to_with_tz.to_hash,
    :status => status.value,
    :experience_keys => experience_keys,
    :rule => rule.to_hash
  }
end

#to_jsonObject



36963
36964
36965
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36963

def to_json
  JSON.dump(to_hash)
end