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.



40208
40209
40210
40211
40212
40213
40214
40215
40216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40208

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name, :from_with_tz, :experience_keys, :rule], 'DiscountRuleSettingsForm')
  @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)))
  @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.



40206
40207
40208
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40206

def experience_keys
  @experience_keys
end

#from_with_tzObject (readonly)

Returns the value of attribute from_with_tz.



40206
40207
40208
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40206

def from_with_tz
  @from_with_tz
end

#nameObject (readonly)

Returns the value of attribute name.



40206
40207
40208
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40206

def name
  @name
end

#ruleObject (readonly)

Returns the value of attribute rule.



40206
40207
40208
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40206

def rule
  @rule
end

#to_with_tzObject (readonly)

Returns the value of attribute to_with_tz.



40206
40207
40208
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40206

def to_with_tz
  @to_with_tz
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40222
40223
40224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40222

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

#to_hashObject



40226
40227
40228
40229
40230
40231
40232
40233
40234
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40226

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

#to_jsonObject



40218
40219
40220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40218

def to_json
  JSON.dump(to_hash)
end