Class: StickyIoRestfulApiV2025731::CouponProfile

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb

Overview

CouponProfile 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(id:, name:, description:, use_count:, discount_amt:, discount_pct:, minimum_purchase:, is_lifetime:, is_active:, created_at:, updated_at:, expires_at:, is_free_shipping:, promo_code_count:, limits:, creator:, updator:, additional_properties: nil) ⇒ CouponProfile

Returns a new instance of CouponProfile.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 116

def initialize(id:, name:, description:, use_count:, discount_amt:,
               discount_pct:, minimum_purchase:, is_lifetime:, is_active:,
               created_at:, updated_at:, expires_at:, is_free_shipping:,
               promo_code_count:, limits:, creator:, updator:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @name = name
  @description = description
  @use_count = use_count
  @discount_amt = discount_amt
  @discount_pct = discount_pct
  @minimum_purchase = minimum_purchase
  @is_lifetime = is_lifetime
  @is_active = is_active
  @created_at = created_at
  @updated_at = updated_at
  @expires_at = expires_at
  @is_free_shipping = is_free_shipping
  @promo_code_count = promo_code_count
  @limits = limits
  @creator = creator
  @updator = updator
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_atCreatedAt

TODO: Write general description for this method

Returns:



50
51
52
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 50

def created_at
  @created_at
end

#creatorCreator

TODO: Write general description for this method

Returns:



74
75
76
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 74

def creator
  @creator
end

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 22

def description
  @description
end

#discount_amtString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 30

def discount_amt
  @discount_amt
end

#discount_pctString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 34

def discount_pct
  @discount_pct
end

#expires_atString

TODO: Write general description for this method

Returns:

  • (String)


58
59
60
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 58

def expires_at
  @expires_at
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 14

def id
  @id
end

#is_activeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


46
47
48
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 46

def is_active
  @is_active
end

#is_free_shippingInteger

TODO: Write general description for this method

Returns:

  • (Integer)


62
63
64
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 62

def is_free_shipping
  @is_free_shipping
end

#is_lifetimeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


42
43
44
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 42

def is_lifetime
  @is_lifetime
end

#limitsString

TODO: Write general description for this method

Returns:

  • (String)


70
71
72
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 70

def limits
  @limits
end

#minimum_purchaseString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 38

def minimum_purchase
  @minimum_purchase
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 18

def name
  @name
end

#promo_code_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


66
67
68
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 66

def promo_code_count
  @promo_code_count
end

#updated_atUpdatedAtCouponProfile

TODO: Write general description for this method



54
55
56
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 54

def updated_at
  @updated_at
end

#updatorUpdatorCouponProfile

TODO: Write general description for this method



78
79
80
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 78

def updator
  @updator
end

#use_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 26

def use_count
  @use_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 145

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  use_count = hash.key?('use_count') ? hash['use_count'] : nil
  discount_amt = hash.key?('discount_amt') ? hash['discount_amt'] : nil
  discount_pct = hash.key?('discount_pct') ? hash['discount_pct'] : nil
  minimum_purchase =
    hash.key?('minimum_purchase') ? hash['minimum_purchase'] : nil
  is_lifetime = hash.key?('is_lifetime') ? hash['is_lifetime'] : nil
  is_active = hash.key?('is_active') ? hash['is_active'] : nil
  created_at = CreatedAt.from_hash(hash['created_at']) if hash['created_at']
  updated_at = UpdatedAtCouponProfile.from_hash(hash['updated_at']) if hash['updated_at']
  expires_at = hash.key?('expires_at') ? hash['expires_at'] : nil
  is_free_shipping =
    hash.key?('is_free_shipping') ? hash['is_free_shipping'] : nil
  promo_code_count =
    hash.key?('promo_code_count') ? hash['promo_code_count'] : nil
  limits = hash.key?('limits') ? hash['limits'] : nil
  creator = Creator.from_hash(hash['creator']) if hash['creator']
  updator = UpdatorCouponProfile.from_hash(hash['updator']) if hash['updator']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CouponProfile.new(id: id,
                    name: name,
                    description: description,
                    use_count: use_count,
                    discount_amt: discount_amt,
                    discount_pct: discount_pct,
                    minimum_purchase: minimum_purchase,
                    is_lifetime: is_lifetime,
                    is_active: is_active,
                    created_at: created_at,
                    updated_at: updated_at,
                    expires_at: expires_at,
                    is_free_shipping: is_free_shipping,
                    promo_code_count: promo_code_count,
                    limits: limits,
                    creator: creator,
                    updator: updator,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 81

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['use_count'] = 'use_count'
  @_hash['discount_amt'] = 'discount_amt'
  @_hash['discount_pct'] = 'discount_pct'
  @_hash['minimum_purchase'] = 'minimum_purchase'
  @_hash['is_lifetime'] = 'is_lifetime'
  @_hash['is_active'] = 'is_active'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['expires_at'] = 'expires_at'
  @_hash['is_free_shipping'] = 'is_free_shipping'
  @_hash['promo_code_count'] = 'promo_code_count'
  @_hash['limits'] = 'limits'
  @_hash['creator'] = 'creator'
  @_hash['updator'] = 'updator'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
112
113
114
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 109

def self.nullables
  %w[
    expires_at
    limits
  ]
end

.optionalsObject

An array for optional fields



104
105
106
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 104

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 211

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, description:"\
  " #{@description.inspect}, use_count: #{@use_count.inspect}, discount_amt:"\
  " #{@discount_amt.inspect}, discount_pct: #{@discount_pct.inspect}, minimum_purchase:"\
  " #{@minimum_purchase.inspect}, is_lifetime: #{@is_lifetime.inspect}, is_active:"\
  " #{@is_active.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
  " #{@updated_at.inspect}, expires_at: #{@expires_at.inspect}, is_free_shipping:"\
  " #{@is_free_shipping.inspect}, promo_code_count: #{@promo_code_count.inspect}, limits:"\
  " #{@limits.inspect}, creator: #{@creator.inspect}, updator: #{@updator.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



199
200
201
202
203
204
205
206
207
208
# File 'lib/sticky_io_restful_api_v2025731/models/coupon_profile.rb', line 199

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, name: #{@name}, description: #{@description}, use_count:"\
  " #{@use_count}, discount_amt: #{@discount_amt}, discount_pct: #{@discount_pct},"\
  " minimum_purchase: #{@minimum_purchase}, is_lifetime: #{@is_lifetime}, is_active:"\
  " #{@is_active}, created_at: #{@created_at}, updated_at: #{@updated_at}, expires_at:"\
  " #{@expires_at}, is_free_shipping: #{@is_free_shipping}, promo_code_count:"\
  " #{@promo_code_count}, limits: #{@limits}, creator: #{@creator}, updator: #{@updator},"\
  " additional_properties: #{@additional_properties}>"
end