Class: ApiReference::ThresholdDiscountGroup

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/threshold_discount_group.rb

Overview

ThresholdDiscountGroup Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(cell_coordinates:, threshold_amount:, below_threshold_discount_percentage:, above_threshold_discount_percentage:, description: SKIP) ⇒ ThresholdDiscountGroup

Returns a new instance of ThresholdDiscountGroup.



66
67
68
69
70
71
72
73
74
# File 'lib/api_reference/models/threshold_discount_group.rb', line 66

def initialize(cell_coordinates:, threshold_amount:,
               below_threshold_discount_percentage:,
               above_threshold_discount_percentage:, description: SKIP)
  @description = description unless description == SKIP
  @cell_coordinates = cell_coordinates
  @threshold_amount = threshold_amount
  @below_threshold_discount_percentage = below_threshold_discount_percentage
  @above_threshold_discount_percentage = above_threshold_discount_percentage
end

Instance Attribute Details

#above_threshold_discount_percentageString

Discount rate applied to spend above the threshold.

Returns:

  • (String)


37
38
39
# File 'lib/api_reference/models/threshold_discount_group.rb', line 37

def above_threshold_discount_percentage
  @above_threshold_discount_percentage
end

#below_threshold_discount_percentageString

Discount rate applied to spend at or below the threshold. Set to 0 for no baseline discount.

Returns:

  • (String)


33
34
35
# File 'lib/api_reference/models/threshold_discount_group.rb', line 33

def below_threshold_discount_percentage
  @below_threshold_discount_percentage
end

#cell_coordinatesString

Semicolon-separated list of matrix cell coordinates targeted by this group. Each coordinate is first,second when the matrix has two dimensions, or just first for a single-dimension matrix. Example: blue,circle;green,triangle.

Returns:

  • (String)


21
22
23
# File 'lib/api_reference/models/threshold_discount_group.rb', line 21

def cell_coordinates
  @cell_coordinates
end

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/api_reference/models/threshold_discount_group.rb', line 14

def description
  @description
end

#threshold_amountString

Semicolon-separated list of matrix cell coordinates targeted by this group. Each coordinate is first,second when the matrix has two dimensions, or just first for a single-dimension matrix. Example: blue,circle;green,triangle.

Returns:

  • (String)


28
29
30
# File 'lib/api_reference/models/threshold_discount_group.rb', line 28

def threshold_amount
  @threshold_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/api_reference/models/threshold_discount_group.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  cell_coordinates =
    hash.key?('cell_coordinates') ? hash['cell_coordinates'] : nil
  threshold_amount =
    hash.key?('threshold_amount') ? hash['threshold_amount'] : nil
  below_threshold_discount_percentage =
    hash.key?('below_threshold_discount_percentage') ? hash['below_threshold_discount_percentage'] : nil
  above_threshold_discount_percentage =
    hash.key?('above_threshold_discount_percentage') ? hash['above_threshold_discount_percentage'] : nil
  description = hash.key?('description') ? hash['description'] : SKIP

  # Create object from extracted values.
  ThresholdDiscountGroup.new(cell_coordinates: cell_coordinates,
                             threshold_amount: threshold_amount,
                             below_threshold_discount_percentage: below_threshold_discount_percentage,
                             above_threshold_discount_percentage: above_threshold_discount_percentage,
                             description: description)
end

.namesObject

A mapping from model property names to API property names.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/api_reference/models/threshold_discount_group.rb', line 40

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['description'] = 'description'
  @_hash['cell_coordinates'] = 'cell_coordinates'
  @_hash['threshold_amount'] = 'threshold_amount'
  @_hash['below_threshold_discount_percentage'] =
    'below_threshold_discount_percentage'
  @_hash['above_threshold_discount_percentage'] =
    'above_threshold_discount_percentage'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
63
64
# File 'lib/api_reference/models/threshold_discount_group.rb', line 60

def self.nullables
  %w[
    description
  ]
end

.optionalsObject

An array for optional fields



53
54
55
56
57
# File 'lib/api_reference/models/threshold_discount_group.rb', line 53

def self.optionals
  %w[
    description
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/api_reference/models/threshold_discount_group.rb', line 101

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.cell_coordinates,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.threshold_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.below_threshold_discount_percentage,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.above_threshold_discount_percentage,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['cell_coordinates'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['threshold_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['below_threshold_discount_percentage'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['above_threshold_discount_percentage'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



139
140
141
142
143
144
145
# File 'lib/api_reference/models/threshold_discount_group.rb', line 139

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description.inspect}, cell_coordinates:"\
  " #{@cell_coordinates.inspect}, threshold_amount: #{@threshold_amount.inspect},"\
  " below_threshold_discount_percentage: #{@below_threshold_discount_percentage.inspect},"\
  " above_threshold_discount_percentage: #{@above_threshold_discount_percentage.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



130
131
132
133
134
135
136
# File 'lib/api_reference/models/threshold_discount_group.rb', line 130

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description}, cell_coordinates: #{@cell_coordinates},"\
  " threshold_amount: #{@threshold_amount}, below_threshold_discount_percentage:"\
  " #{@below_threshold_discount_percentage}, above_threshold_discount_percentage:"\
  " #{@above_threshold_discount_percentage}>"
end