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.



30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30155

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.



30153
30154
30155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30153

def experience_keys
  @experience_keys
end

#from_with_tzObject (readonly)

Returns the value of attribute from_with_tz.



30153
30154
30155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30153

def from_with_tz
  @from_with_tz
end

#idObject (readonly)

Returns the value of attribute id.



30153
30154
30155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30153

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



30153
30154
30155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30153

def name
  @name
end

#ruleObject (readonly)

Returns the value of attribute rule.



30153
30154
30155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30153

def rule
  @rule
end

#statusObject (readonly)

Returns the value of attribute status.



30153
30154
30155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30153

def status
  @status
end

#to_with_tzObject (readonly)

Returns the value of attribute to_with_tz.



30153
30154
30155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30153

def to_with_tz
  @to_with_tz
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30171
30172
30173
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30171

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

#to_hashObject



30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30175

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



30167
30168
30169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30167

def to_json
  JSON.dump(to_hash)
end