Class: TalonOne::CustomerAnalytics

Inherits:
ApiModelBase show all
Defined in:
lib/talon_one_sdk/models/customer_analytics.rb

Overview

A summary report of customer activity for a given time range.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ CustomerAnalytics

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 84

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::CustomerAnalytics` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TalonOne::CustomerAnalytics`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'accepted_coupons')
    self.accepted_coupons = attributes[:'accepted_coupons']
  else
    self.accepted_coupons = nil
  end

  if attributes.key?(:'created_coupons')
    self.created_coupons = attributes[:'created_coupons']
  else
    self.created_coupons = nil
  end

  if attributes.key?(:'free_items')
    self.free_items = attributes[:'free_items']
  else
    self.free_items = nil
  end

  if attributes.key?(:'total_orders')
    self.total_orders = attributes[:'total_orders']
  else
    self.total_orders = nil
  end

  if attributes.key?(:'total_discounted_orders')
    self.total_discounted_orders = attributes[:'total_discounted_orders']
  else
    self.total_discounted_orders = nil
  end

  if attributes.key?(:'total_revenue')
    self.total_revenue = attributes[:'total_revenue']
  else
    self.total_revenue = nil
  end

  if attributes.key?(:'total_discounts')
    self.total_discounts = attributes[:'total_discounts']
  else
    self.total_discounts = nil
  end
end

Instance Attribute Details

#accepted_couponsObject

Total accepted coupons for this customer.



20
21
22
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 20

def accepted_coupons
  @accepted_coupons
end

#created_couponsObject

Total created coupons for this customer.



23
24
25
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 23

def created_coupons
  @created_coupons
end

#free_itemsObject

Total free items given to this customer.



26
27
28
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 26

def free_items
  @free_items
end

#total_discounted_ordersObject

Total orders made by this customer that had a discount.



32
33
34
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 32

def total_discounted_orders
  @total_discounted_orders
end

#total_discountsObject

The sum of discounts that were given across all closed sessions.



38
39
40
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 38

def total_discounts
  @total_discounts
end

#total_ordersObject

Total orders made by this customer.



29
30
31
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 29

def total_orders
  @total_orders
end

#total_revenueObject

Total Revenue across all closed sessions.



35
36
37
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 35

def total_revenue
  @total_revenue
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



54
55
56
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 54

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



59
60
61
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 59

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 41

def self.attribute_map
  {
    :'accepted_coupons' => :'acceptedCoupons',
    :'created_coupons' => :'createdCoupons',
    :'free_items' => :'freeItems',
    :'total_orders' => :'totalOrders',
    :'total_discounted_orders' => :'totalDiscountedOrders',
    :'total_revenue' => :'totalRevenue',
    :'total_discounts' => :'totalDiscounts'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 290

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



77
78
79
80
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 77

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 64

def self.openapi_types
  {
    :'accepted_coupons' => :'Integer',
    :'created_coupons' => :'Integer',
    :'free_items' => :'Integer',
    :'total_orders' => :'Integer',
    :'total_discounted_orders' => :'Integer',
    :'total_revenue' => :'Float',
    :'total_discounts' => :'Float'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



263
264
265
266
267
268
269
270
271
272
273
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 263

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      accepted_coupons == o.accepted_coupons &&
      created_coupons == o.created_coupons &&
      free_items == o.free_items &&
      total_orders == o.total_orders &&
      total_discounted_orders == o.total_discounted_orders &&
      total_revenue == o.total_revenue &&
      total_discounts == o.total_discounts
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


277
278
279
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 277

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



283
284
285
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 283

def hash
  [accepted_coupons, created_coupons, free_items, total_orders, total_discounted_orders, total_revenue, total_discounts].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 143

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @accepted_coupons.nil?
    invalid_properties.push('invalid value for "accepted_coupons", accepted_coupons cannot be nil.')
  end

  if @created_coupons.nil?
    invalid_properties.push('invalid value for "created_coupons", created_coupons cannot be nil.')
  end

  if @free_items.nil?
    invalid_properties.push('invalid value for "free_items", free_items cannot be nil.')
  end

  if @total_orders.nil?
    invalid_properties.push('invalid value for "total_orders", total_orders cannot be nil.')
  end

  if @total_discounted_orders.nil?
    invalid_properties.push('invalid value for "total_discounted_orders", total_discounted_orders cannot be nil.')
  end

  if @total_revenue.nil?
    invalid_properties.push('invalid value for "total_revenue", total_revenue cannot be nil.')
  end

  if @total_discounts.nil?
    invalid_properties.push('invalid value for "total_discounts", total_discounts cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 312

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



179
180
181
182
183
184
185
186
187
188
189
# File 'lib/talon_one_sdk/models/customer_analytics.rb', line 179

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @accepted_coupons.nil?
  return false if @created_coupons.nil?
  return false if @free_items.nil?
  return false if @total_orders.nil?
  return false if @total_discounted_orders.nil?
  return false if @total_revenue.nil?
  return false if @total_discounts.nil?
  true
end