tremendous_ruby 5.0.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +677 -9
  3. data/lib/tremendous/models/campaign.rb +25 -14
  4. data/lib/tremendous/models/campaign_base.rb +287 -0
  5. data/lib/tremendous/models/{get_campaign200_response.rb → create_campaign201_response.rb} +3 -3
  6. data/lib/tremendous/models/create_campaign_request.rb +273 -0
  7. data/lib/tremendous/models/create_member.rb +2 -53
  8. data/lib/tremendous/models/create_member_request.rb +2 -53
  9. data/lib/tremendous/models/create_order_request_reward.rb +1 -1
  10. data/lib/tremendous/models/create_order_request_reward_custom_fields_inner.rb +248 -0
  11. data/lib/tremendous/models/create_organization_request_copy_settings.rb +29 -5
  12. data/lib/tremendous/models/{list_products200_response_products_inner_countries_inner.rb → create_public_key.rb} +15 -15
  13. data/lib/tremendous/models/create_public_key200_response.rb +221 -0
  14. data/lib/tremendous/models/create_public_key_request.rb +222 -0
  15. data/lib/tremendous/models/custom_field.rb +15 -5
  16. data/lib/tremendous/models/get_member200_response_member.rb +13 -21
  17. data/lib/tremendous/models/invoice.rb +2 -2
  18. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner.rb +25 -14
  19. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_email_style.rb +270 -0
  20. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.rb +270 -0
  21. data/lib/tremendous/models/{get_product200_response.rb → list_forex_response.rb} +16 -14
  22. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +2 -2
  23. data/lib/tremendous/models/list_members200_response_members_inner.rb +13 -21
  24. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +15 -5
  25. data/lib/tremendous/models/{list_products200_response.rb → list_roles200_response.rb} +15 -15
  26. data/lib/tremendous/models/{list_products200_response_products_inner_images_inner.rb → list_roles200_response_roles_inner.rb} +59 -57
  27. data/lib/tremendous/models/member.rb +13 -21
  28. data/lib/tremendous/models/member_base.rb +13 -21
  29. data/lib/tremendous/models/member_with_events.rb +13 -21
  30. data/lib/tremendous/models/member_without_events.rb +13 -21
  31. data/lib/tremendous/models/public_key.rb +257 -0
  32. data/lib/tremendous/models/public_keys_response.rb +223 -0
  33. data/lib/tremendous/models/public_keys_response_public_keys_inner.rb +257 -0
  34. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +15 -5
  35. data/lib/tremendous/models/{list_products200_response_products_inner_skus_inner.rb → role.rb} +51 -53
  36. data/lib/tremendous/models/test_public_key.rb +222 -0
  37. data/lib/tremendous/models/test_public_key_request.rb +222 -0
  38. data/lib/tremendous/models/update_campaign.rb +287 -0
  39. data/lib/tremendous/models/update_campaign_request.rb +257 -0
  40. data/lib/tremendous/version.rb +1 -1
  41. data/lib/tremendous.rb +20 -1
  42. metadata +23 -10
  43. data/lib/tremendous/models/list_products200_response_products_inner.rb +0 -457
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Tremendous
17
- # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. > Note: Campaigns must be created from the Tremendous dashboard. > > • [Production Dashboard](https://app.tremendous.com) > • [Sandbox Dashboard](https://app.testflight.tremendous.com/)
17
+ # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from.
18
18
  class Campaign
19
19
  attr_accessor :id
20
20
 
@@ -27,13 +27,19 @@ module Tremendous
27
27
  # List of IDs of products (different gift cards, charity, etc.) that are available in this campaign.
28
28
  attr_accessor :products
29
29
 
30
+ attr_accessor :webpage_style
31
+
32
+ attr_accessor :email_style
33
+
30
34
  # Attribute mapping from ruby-style variable name to JSON key.
31
35
  def self.attribute_map
32
36
  {
33
37
  :'id' => :'id',
34
38
  :'name' => :'name',
35
39
  :'description' => :'description',
36
- :'products' => :'products'
40
+ :'products' => :'products',
41
+ :'webpage_style' => :'webpage_style',
42
+ :'email_style' => :'email_style'
37
43
  }
38
44
  end
39
45
 
@@ -48,7 +54,9 @@ module Tremendous
48
54
  :'id' => :'String',
49
55
  :'name' => :'String',
50
56
  :'description' => :'String',
51
- :'products' => :'Array<String>'
57
+ :'products' => :'Array<String>',
58
+ :'webpage_style' => :'ListCampaigns200ResponseCampaignsInnerWebpageStyle',
59
+ :'email_style' => :'ListCampaigns200ResponseCampaignsInnerEmailStyle'
52
60
  }
53
61
  end
54
62
 
@@ -76,8 +84,6 @@ module Tremendous
76
84
 
77
85
  if attributes.key?(:'id')
78
86
  self.id = attributes[:'id']
79
- else
80
- self.id = nil
81
87
  end
82
88
 
83
89
  if attributes.key?(:'name')
@@ -99,6 +105,14 @@ module Tremendous
99
105
  else
100
106
  self.products = nil
101
107
  end
108
+
109
+ if attributes.key?(:'webpage_style')
110
+ self.webpage_style = attributes[:'webpage_style']
111
+ end
112
+
113
+ if attributes.key?(:'email_style')
114
+ self.email_style = attributes[:'email_style']
115
+ end
102
116
  end
103
117
 
104
118
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -106,12 +120,8 @@ module Tremendous
106
120
  def list_invalid_properties
107
121
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
122
  invalid_properties = Array.new
109
- if @id.nil?
110
- invalid_properties.push('invalid value for "id", id cannot be nil.')
111
- end
112
-
113
123
  pattern = Regexp.new(/[A-Z0-9]{4,20}/)
114
- if @id !~ pattern
124
+ if !@id.nil? && @id !~ pattern
115
125
  invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
116
126
  end
117
127
 
@@ -130,8 +140,7 @@ module Tremendous
130
140
  # @return true if the model is valid
131
141
  def valid?
132
142
  warn '[DEPRECATED] the `valid?` method is obsolete'
133
- return false if @id.nil?
134
- return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
143
+ return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
135
144
  return false if @name.nil?
136
145
  return false if @products.nil?
137
146
  true
@@ -160,7 +169,9 @@ module Tremendous
160
169
  id == o.id &&
161
170
  name == o.name &&
162
171
  description == o.description &&
163
- products == o.products
172
+ products == o.products &&
173
+ webpage_style == o.webpage_style &&
174
+ email_style == o.email_style
164
175
  end
165
176
 
166
177
  # @see the `==` method
@@ -172,7 +183,7 @@ module Tremendous
172
183
  # Calculates hash code according to all attributes.
173
184
  # @return [Integer] Hash code
174
185
  def hash
175
- [id, name, description, products].hash
186
+ [id, name, description, products, webpage_style, email_style].hash
176
187
  end
177
188
 
178
189
  # Builds the object from hash
@@ -0,0 +1,287 @@
1
+ =begin
2
+ #API Endpoints
3
+
4
+ #Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API.
5
+
6
+ The version of the OpenAPI document: 2
7
+ Contact: developers@tremendous.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from.
18
+ class CampaignBase
19
+ attr_accessor :id
20
+
21
+ # Name of the campaign
22
+ attr_accessor :name
23
+
24
+ # Description of the campaign
25
+ attr_accessor :description
26
+
27
+ # List of IDs of products (different gift cards, charity, etc.) that are available in this campaign.
28
+ attr_accessor :products
29
+
30
+ attr_accessor :webpage_style
31
+
32
+ attr_accessor :email_style
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'id' => :'id',
38
+ :'name' => :'name',
39
+ :'description' => :'description',
40
+ :'products' => :'products',
41
+ :'webpage_style' => :'webpage_style',
42
+ :'email_style' => :'email_style'
43
+ }
44
+ end
45
+
46
+ # Returns all the JSON keys this model knows about
47
+ def self.acceptable_attributes
48
+ attribute_map.values
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'id' => :'String',
55
+ :'name' => :'String',
56
+ :'description' => :'String',
57
+ :'products' => :'Array<String>',
58
+ :'webpage_style' => :'ListCampaigns200ResponseCampaignsInnerWebpageStyle',
59
+ :'email_style' => :'ListCampaigns200ResponseCampaignsInnerEmailStyle'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ :'description',
67
+ ])
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ if (!attributes.is_a?(Hash))
74
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CampaignBase` initialize method"
75
+ end
76
+
77
+ # check to see if the attribute exists and convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!self.class.attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CampaignBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'id')
86
+ self.id = attributes[:'id']
87
+ end
88
+
89
+ if attributes.key?(:'name')
90
+ self.name = attributes[:'name']
91
+ end
92
+
93
+ if attributes.key?(:'description')
94
+ self.description = attributes[:'description']
95
+ end
96
+
97
+ if attributes.key?(:'products')
98
+ if (value = attributes[:'products']).is_a?(Array)
99
+ self.products = value
100
+ end
101
+ end
102
+
103
+ if attributes.key?(:'webpage_style')
104
+ self.webpage_style = attributes[:'webpage_style']
105
+ end
106
+
107
+ if attributes.key?(:'email_style')
108
+ self.email_style = attributes[:'email_style']
109
+ end
110
+ end
111
+
112
+ # Show invalid properties with the reasons. Usually used together with valid?
113
+ # @return Array for valid properties with the reasons
114
+ def list_invalid_properties
115
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
116
+ invalid_properties = Array.new
117
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
118
+ if !@id.nil? && @id !~ pattern
119
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
120
+ end
121
+
122
+ invalid_properties
123
+ end
124
+
125
+ # Check to see if the all the properties in the model are valid
126
+ # @return true if the model is valid
127
+ def valid?
128
+ warn '[DEPRECATED] the `valid?` method is obsolete'
129
+ return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
130
+ true
131
+ end
132
+
133
+ # Custom attribute writer method with validation
134
+ # @param [Object] id Value to be assigned
135
+ def id=(id)
136
+ if id.nil?
137
+ fail ArgumentError, 'id cannot be nil'
138
+ end
139
+
140
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
141
+ if id !~ pattern
142
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
143
+ end
144
+
145
+ @id = id
146
+ end
147
+
148
+ # Checks equality by comparing each attribute.
149
+ # @param [Object] Object to be compared
150
+ def ==(o)
151
+ return true if self.equal?(o)
152
+ self.class == o.class &&
153
+ id == o.id &&
154
+ name == o.name &&
155
+ description == o.description &&
156
+ products == o.products &&
157
+ webpage_style == o.webpage_style &&
158
+ email_style == o.email_style
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(o)
164
+ self == o
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [id, name, description, products, webpage_style, email_style].hash
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def self.build_from_hash(attributes)
177
+ return nil unless attributes.is_a?(Hash)
178
+ attributes = attributes.transform_keys(&:to_sym)
179
+ transformed_hash = {}
180
+ openapi_types.each_pair do |key, type|
181
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
182
+ transformed_hash["#{key}"] = nil
183
+ elsif type =~ /\AArray<(.*)>/i
184
+ # check to ensure the input is an array given that the attribute
185
+ # is documented as an array but the input is not
186
+ if attributes[attribute_map[key]].is_a?(Array)
187
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
188
+ end
189
+ elsif !attributes[attribute_map[key]].nil?
190
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
191
+ end
192
+ end
193
+ new(transformed_hash)
194
+ end
195
+
196
+ # Deserializes the data based on type
197
+ # @param string type Data type
198
+ # @param string value Value to be deserialized
199
+ # @return [Object] Deserialized data
200
+ def self._deserialize(type, value)
201
+ case type.to_sym
202
+ when :Time
203
+ Time.parse(value)
204
+ when :Date
205
+ Date.parse(value)
206
+ when :String
207
+ value.to_s
208
+ when :Integer
209
+ value.to_i
210
+ when :Float
211
+ value.to_f
212
+ when :Boolean
213
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
214
+ true
215
+ else
216
+ false
217
+ end
218
+ when :Object
219
+ # generic object (usually a Hash), return directly
220
+ value
221
+ when /\AArray<(?<inner_type>.+)>\z/
222
+ inner_type = Regexp.last_match[:inner_type]
223
+ value.map { |v| _deserialize(inner_type, v) }
224
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
225
+ k_type = Regexp.last_match[:k_type]
226
+ v_type = Regexp.last_match[:v_type]
227
+ {}.tap do |hash|
228
+ value.each do |k, v|
229
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
230
+ end
231
+ end
232
+ else # model
233
+ # models (e.g. Pet) or oneOf
234
+ klass = Tremendous.const_get(type)
235
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
236
+ end
237
+ end
238
+
239
+ # Returns the string representation of the object
240
+ # @return [String] String presentation of the object
241
+ def to_s
242
+ to_hash.to_s
243
+ end
244
+
245
+ # to_body is an alias to to_hash (backward compatibility)
246
+ # @return [Hash] Returns the object in the form of hash
247
+ def to_body
248
+ to_hash
249
+ end
250
+
251
+ # Returns the object in the form of hash
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_hash
254
+ hash = {}
255
+ self.class.attribute_map.each_pair do |attr, param|
256
+ value = self.send(attr)
257
+ if value.nil?
258
+ is_nullable = self.class.openapi_nullable.include?(attr)
259
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
260
+ end
261
+
262
+ hash[param] = _to_hash(value)
263
+ end
264
+ hash
265
+ end
266
+
267
+ # Outputs non-array value in the form of hash
268
+ # For object, use to_hash. Otherwise, just return the value
269
+ # @param [Object] value Any valid value
270
+ # @return [Hash] Returns the value in the form of hash
271
+ def _to_hash(value)
272
+ if value.is_a?(Array)
273
+ value.compact.map { |v| _to_hash(v) }
274
+ elsif value.is_a?(Hash)
275
+ {}.tap do |hash|
276
+ value.each { |k, v| hash[k] = _to_hash(v) }
277
+ end
278
+ elsif value.respond_to? :to_hash
279
+ value.to_hash
280
+ else
281
+ value
282
+ end
283
+ end
284
+
285
+ end
286
+
287
+ end
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Tremendous
17
- class GetCampaign200Response
17
+ class CreateCampaign201Response
18
18
  attr_accessor :campaign
19
19
 
20
20
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -46,13 +46,13 @@ module Tremendous
46
46
  # @param [Hash] attributes Model attributes in the form of hash
47
47
  def initialize(attributes = {})
48
48
  if (!attributes.is_a?(Hash))
49
- fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::GetCampaign200Response` initialize method"
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreateCampaign201Response` initialize method"
50
50
  end
51
51
 
52
52
  # check to see if the attribute exists and convert string to symbol for hash key
53
53
  attributes = attributes.each_with_object({}) { |(k, v), h|
54
54
  if (!self.class.attribute_map.key?(k.to_sym))
55
- fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::GetCampaign200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreateCampaign201Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
56
  end
57
57
  h[k.to_sym] = v
58
58
  }
@@ -0,0 +1,273 @@
1
+ =begin
2
+ #API Endpoints
3
+
4
+ #Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and it's members within Tremendous, please see the Tremendous Organizational API.
5
+
6
+ The version of the OpenAPI document: 2
7
+ Contact: developers@tremendous.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from.
18
+ class CreateCampaignRequest
19
+ # Name of the campaign
20
+ attr_accessor :name
21
+
22
+ # Description of the campaign
23
+ attr_accessor :description
24
+
25
+ # List of IDs of products (different gift cards, charity, etc.) that are available in this campaign.
26
+ attr_accessor :products
27
+
28
+ attr_accessor :webpage_style
29
+
30
+ attr_accessor :email_style
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'name' => :'name',
36
+ :'description' => :'description',
37
+ :'products' => :'products',
38
+ :'webpage_style' => :'webpage_style',
39
+ :'email_style' => :'email_style'
40
+ }
41
+ end
42
+
43
+ # Returns all the JSON keys this model knows about
44
+ def self.acceptable_attributes
45
+ attribute_map.values
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.openapi_types
50
+ {
51
+ :'name' => :'String',
52
+ :'description' => :'String',
53
+ :'products' => :'Array<String>',
54
+ :'webpage_style' => :'ListCampaigns200ResponseCampaignsInnerWebpageStyle',
55
+ :'email_style' => :'ListCampaigns200ResponseCampaignsInnerEmailStyle'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ :'description',
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreateCampaignRequest` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreateCampaignRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'name')
82
+ self.name = attributes[:'name']
83
+ else
84
+ self.name = nil
85
+ end
86
+
87
+ if attributes.key?(:'description')
88
+ self.description = attributes[:'description']
89
+ else
90
+ self.description = nil
91
+ end
92
+
93
+ if attributes.key?(:'products')
94
+ if (value = attributes[:'products']).is_a?(Array)
95
+ self.products = value
96
+ end
97
+ else
98
+ self.products = nil
99
+ end
100
+
101
+ if attributes.key?(:'webpage_style')
102
+ self.webpage_style = attributes[:'webpage_style']
103
+ end
104
+
105
+ if attributes.key?(:'email_style')
106
+ self.email_style = attributes[:'email_style']
107
+ end
108
+ end
109
+
110
+ # Show invalid properties with the reasons. Usually used together with valid?
111
+ # @return Array for valid properties with the reasons
112
+ def list_invalid_properties
113
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
114
+ invalid_properties = Array.new
115
+ if @name.nil?
116
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
117
+ end
118
+
119
+ if @products.nil?
120
+ invalid_properties.push('invalid value for "products", products cannot be nil.')
121
+ end
122
+
123
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ warn '[DEPRECATED] the `valid?` method is obsolete'
130
+ return false if @name.nil?
131
+ return false if @products.nil?
132
+ true
133
+ end
134
+
135
+ # Checks equality by comparing each attribute.
136
+ # @param [Object] Object to be compared
137
+ def ==(o)
138
+ return true if self.equal?(o)
139
+ self.class == o.class &&
140
+ name == o.name &&
141
+ description == o.description &&
142
+ products == o.products &&
143
+ webpage_style == o.webpage_style &&
144
+ email_style == o.email_style
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [name, description, products, webpage_style, email_style].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+ attributes = attributes.transform_keys(&:to_sym)
165
+ transformed_hash = {}
166
+ openapi_types.each_pair do |key, type|
167
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
168
+ transformed_hash["#{key}"] = nil
169
+ elsif type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[attribute_map[key]].is_a?(Array)
173
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
174
+ end
175
+ elsif !attributes[attribute_map[key]].nil?
176
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
177
+ end
178
+ end
179
+ new(transformed_hash)
180
+ end
181
+
182
+ # Deserializes the data based on type
183
+ # @param string type Data type
184
+ # @param string value Value to be deserialized
185
+ # @return [Object] Deserialized data
186
+ def self._deserialize(type, value)
187
+ case type.to_sym
188
+ when :Time
189
+ Time.parse(value)
190
+ when :Date
191
+ Date.parse(value)
192
+ when :String
193
+ value.to_s
194
+ when :Integer
195
+ value.to_i
196
+ when :Float
197
+ value.to_f
198
+ when :Boolean
199
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
+ true
201
+ else
202
+ false
203
+ end
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ else # model
219
+ # models (e.g. Pet) or oneOf
220
+ klass = Tremendous.const_get(type)
221
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ end