sendx-ruby-sdk 1.0.1

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 (61) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +156 -0
  3. data/lib/sendx-ruby-sdk/api/campaign_api.rb +356 -0
  4. data/lib/sendx-ruby-sdk/api/contact_api.rb +426 -0
  5. data/lib/sendx-ruby-sdk/api/list_api.rb +356 -0
  6. data/lib/sendx-ruby-sdk/api/reports_api.rb +88 -0
  7. data/lib/sendx-ruby-sdk/api/sender_api.rb +156 -0
  8. data/lib/sendx-ruby-sdk/api/tags_api.rb +356 -0
  9. data/lib/sendx-ruby-sdk/api_client.rb +394 -0
  10. data/lib/sendx-ruby-sdk/api_error.rb +58 -0
  11. data/lib/sendx-ruby-sdk/configuration.rb +316 -0
  12. data/lib/sendx-ruby-sdk/models/campaign.rb +483 -0
  13. data/lib/sendx-ruby-sdk/models/campaign_dashboard_data.rb +255 -0
  14. data/lib/sendx-ruby-sdk/models/campaign_request.rb +441 -0
  15. data/lib/sendx-ruby-sdk/models/contact.rb +425 -0
  16. data/lib/sendx-ruby-sdk/models/contact_request.rb +292 -0
  17. data/lib/sendx-ruby-sdk/models/create_response.rb +232 -0
  18. data/lib/sendx-ruby-sdk/models/dashboard_stats.rb +234 -0
  19. data/lib/sendx-ruby-sdk/models/delete_campaign200_response.rb +225 -0
  20. data/lib/sendx-ruby-sdk/models/delete_request.rb +215 -0
  21. data/lib/sendx-ruby-sdk/models/delete_response.rb +223 -0
  22. data/lib/sendx-ruby-sdk/models/last_sent_campaign_stat.rb +284 -0
  23. data/lib/sendx-ruby-sdk/models/list_model.rb +410 -0
  24. data/lib/sendx-ruby-sdk/models/list_request.rb +379 -0
  25. data/lib/sendx-ruby-sdk/models/report_data.rb +358 -0
  26. data/lib/sendx-ruby-sdk/models/response.rb +235 -0
  27. data/lib/sendx-ruby-sdk/models/sender.rb +256 -0
  28. data/lib/sendx-ruby-sdk/models/sender_request.rb +239 -0
  29. data/lib/sendx-ruby-sdk/models/sender_response.rb +273 -0
  30. data/lib/sendx-ruby-sdk/models/tag.rb +241 -0
  31. data/lib/sendx-ruby-sdk/models/tag_request.rb +214 -0
  32. data/lib/sendx-ruby-sdk/version.rb +15 -0
  33. data/lib/sendx-ruby-sdk.rb +65 -0
  34. data/spec/api/campaign_api_spec.rb +98 -0
  35. data/spec/api/contact_api_spec.rb +111 -0
  36. data/spec/api/list_api_spec.rb +98 -0
  37. data/spec/api/reports_api_spec.rb +48 -0
  38. data/spec/api/sender_api_spec.rb +61 -0
  39. data/spec/api/tags_api_spec.rb +98 -0
  40. data/spec/models/campaign_dashboard_data_spec.rb +60 -0
  41. data/spec/models/campaign_request_spec.rb +148 -0
  42. data/spec/models/campaign_spec.rb +170 -0
  43. data/spec/models/contact_request_spec.rb +78 -0
  44. data/spec/models/contact_spec.rb +142 -0
  45. data/spec/models/create_response_spec.rb +48 -0
  46. data/spec/models/dashboard_stats_spec.rb +48 -0
  47. data/spec/models/delete_campaign200_response_spec.rb +42 -0
  48. data/spec/models/delete_request_spec.rb +36 -0
  49. data/spec/models/delete_response_spec.rb +42 -0
  50. data/spec/models/last_sent_campaign_stat_spec.rb +78 -0
  51. data/spec/models/list_model_spec.rb +136 -0
  52. data/spec/models/list_request_spec.rb +118 -0
  53. data/spec/models/report_data_spec.rb +120 -0
  54. data/spec/models/response_spec.rb +48 -0
  55. data/spec/models/sender_request_spec.rb +42 -0
  56. data/spec/models/sender_response_spec.rb +54 -0
  57. data/spec/models/sender_spec.rb +48 -0
  58. data/spec/models/tag_request_spec.rb +36 -0
  59. data/spec/models/tag_spec.rb +54 -0
  60. data/spec/spec_helper.rb +111 -0
  61. metadata +171 -0
@@ -0,0 +1,284 @@
1
+ =begin
2
+ #SendX REST API
3
+
4
+ ## Introduction SendX is an email marketing product. It helps you convert website visitors to customers, send them promotional emails, engage with them using drip sequences and craft custom journeys using powerful but simple automations. The SendX API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The SendX Rest API doesn’t support bulk updates. You can work on only one object per request. <br>
5
+
6
+ The version of the OpenAPI document: 1.0.1
7
+ Contact: support@sendx.io
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SendX
17
+ class LastSentCampaignStat
18
+ attr_accessor :campaign
19
+
20
+ # Number of emails sent.
21
+ attr_accessor :sent
22
+
23
+ # Number of emails delivered.
24
+ attr_accessor :delivered
25
+
26
+ # Number of new subscriptions.
27
+ attr_accessor :subscribed
28
+
29
+ # Number of unsubscribes.
30
+ attr_accessor :unsubscribed
31
+
32
+ # Number of emails opened.
33
+ attr_accessor :open
34
+
35
+ # Number of link clicks.
36
+ attr_accessor :link_clicked
37
+
38
+ # Number of replies received.
39
+ attr_accessor :replied
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'campaign' => :'campaign',
45
+ :'sent' => :'sent',
46
+ :'delivered' => :'delivered',
47
+ :'subscribed' => :'subscribed',
48
+ :'unsubscribed' => :'unsubscribed',
49
+ :'open' => :'open',
50
+ :'link_clicked' => :'linkClicked',
51
+ :'replied' => :'replied'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'campaign' => :'CampaignDashboardData',
64
+ :'sent' => :'Integer',
65
+ :'delivered' => :'Integer',
66
+ :'subscribed' => :'Integer',
67
+ :'unsubscribed' => :'Integer',
68
+ :'open' => :'Integer',
69
+ :'link_clicked' => :'Integer',
70
+ :'replied' => :'Integer'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::LastSentCampaignStat` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::LastSentCampaignStat`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'campaign')
96
+ self.campaign = attributes[:'campaign']
97
+ end
98
+
99
+ if attributes.key?(:'sent')
100
+ self.sent = attributes[:'sent']
101
+ end
102
+
103
+ if attributes.key?(:'delivered')
104
+ self.delivered = attributes[:'delivered']
105
+ end
106
+
107
+ if attributes.key?(:'subscribed')
108
+ self.subscribed = attributes[:'subscribed']
109
+ end
110
+
111
+ if attributes.key?(:'unsubscribed')
112
+ self.unsubscribed = attributes[:'unsubscribed']
113
+ end
114
+
115
+ if attributes.key?(:'open')
116
+ self.open = attributes[:'open']
117
+ end
118
+
119
+ if attributes.key?(:'link_clicked')
120
+ self.link_clicked = attributes[:'link_clicked']
121
+ end
122
+
123
+ if attributes.key?(:'replied')
124
+ self.replied = attributes[:'replied']
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
132
+ invalid_properties = Array.new
133
+ invalid_properties
134
+ end
135
+
136
+ # Check to see if the all the properties in the model are valid
137
+ # @return true if the model is valid
138
+ def valid?
139
+ warn '[DEPRECATED] the `valid?` method is obsolete'
140
+ true
141
+ end
142
+
143
+ # Checks equality by comparing each attribute.
144
+ # @param [Object] Object to be compared
145
+ def ==(o)
146
+ return true if self.equal?(o)
147
+ self.class == o.class &&
148
+ campaign == o.campaign &&
149
+ sent == o.sent &&
150
+ delivered == o.delivered &&
151
+ subscribed == o.subscribed &&
152
+ unsubscribed == o.unsubscribed &&
153
+ open == o.open &&
154
+ link_clicked == o.link_clicked &&
155
+ replied == o.replied
156
+ end
157
+
158
+ # @see the `==` method
159
+ # @param [Object] Object to be compared
160
+ def eql?(o)
161
+ self == o
162
+ end
163
+
164
+ # Calculates hash code according to all attributes.
165
+ # @return [Integer] Hash code
166
+ def hash
167
+ [campaign, sent, delivered, subscribed, unsubscribed, open, link_clicked, replied].hash
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def self.build_from_hash(attributes)
174
+ return nil unless attributes.is_a?(Hash)
175
+ attributes = attributes.transform_keys(&:to_sym)
176
+ transformed_hash = {}
177
+ openapi_types.each_pair do |key, type|
178
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
179
+ transformed_hash["#{key}"] = nil
180
+ elsif type =~ /\AArray<(.*)>/i
181
+ # check to ensure the input is an array given that the attribute
182
+ # is documented as an array but the input is not
183
+ if attributes[attribute_map[key]].is_a?(Array)
184
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
185
+ end
186
+ elsif !attributes[attribute_map[key]].nil?
187
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
188
+ end
189
+ end
190
+ new(transformed_hash)
191
+ end
192
+
193
+ # Deserializes the data based on type
194
+ # @param string type Data type
195
+ # @param string value Value to be deserialized
196
+ # @return [Object] Deserialized data
197
+ def self._deserialize(type, value)
198
+ case type.to_sym
199
+ when :Time
200
+ Time.parse(value)
201
+ when :Date
202
+ Date.parse(value)
203
+ when :String
204
+ value.to_s
205
+ when :Integer
206
+ value.to_i
207
+ when :Float
208
+ value.to_f
209
+ when :Boolean
210
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
211
+ true
212
+ else
213
+ false
214
+ end
215
+ when :Object
216
+ # generic object (usually a Hash), return directly
217
+ value
218
+ when /\AArray<(?<inner_type>.+)>\z/
219
+ inner_type = Regexp.last_match[:inner_type]
220
+ value.map { |v| _deserialize(inner_type, v) }
221
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
222
+ k_type = Regexp.last_match[:k_type]
223
+ v_type = Regexp.last_match[:v_type]
224
+ {}.tap do |hash|
225
+ value.each do |k, v|
226
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
227
+ end
228
+ end
229
+ else # model
230
+ # models (e.g. Pet) or oneOf
231
+ klass = SendX.const_get(type)
232
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
233
+ end
234
+ end
235
+
236
+ # Returns the string representation of the object
237
+ # @return [String] String presentation of the object
238
+ def to_s
239
+ to_hash.to_s
240
+ end
241
+
242
+ # to_body is an alias to to_hash (backward compatibility)
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_body
245
+ to_hash
246
+ end
247
+
248
+ # Returns the object in the form of hash
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_hash
251
+ hash = {}
252
+ self.class.attribute_map.each_pair do |attr, param|
253
+ value = self.send(attr)
254
+ if value.nil?
255
+ is_nullable = self.class.openapi_nullable.include?(attr)
256
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
257
+ end
258
+
259
+ hash[param] = _to_hash(value)
260
+ end
261
+ hash
262
+ end
263
+
264
+ # Outputs non-array value in the form of hash
265
+ # For object, use to_hash. Otherwise, just return the value
266
+ # @param [Object] value Any valid value
267
+ # @return [Hash] Returns the value in the form of hash
268
+ def _to_hash(value)
269
+ if value.is_a?(Array)
270
+ value.compact.map { |v| _to_hash(v) }
271
+ elsif value.is_a?(Hash)
272
+ {}.tap do |hash|
273
+ value.each { |k, v| hash[k] = _to_hash(v) }
274
+ end
275
+ elsif value.respond_to? :to_hash
276
+ value.to_hash
277
+ else
278
+ value
279
+ end
280
+ end
281
+
282
+ end
283
+
284
+ end
@@ -0,0 +1,410 @@
1
+ =begin
2
+ #SendX REST API
3
+
4
+ ## Introduction SendX is an email marketing product. It helps you convert website visitors to customers, send them promotional emails, engage with them using drip sequences and craft custom journeys using powerful but simple automations. The SendX API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The SendX Rest API doesn’t support bulk updates. You can work on only one object per request. <br>
5
+
6
+ The version of the OpenAPI document: 1.0.1
7
+ Contact: support@sendx.io
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SendX
17
+ class ListModel
18
+ # Encrypted ID of the list
19
+ attr_accessor :id
20
+
21
+ # Name of the list
22
+ attr_accessor :name
23
+
24
+ # Type of the list representing opt-in methods (1: Single Opt-In, 2: Double Opt-In)
25
+ attr_accessor :type
26
+
27
+ # Indicates if a thank-you email should be sent
28
+ attr_accessor :send_thank_you_mail
29
+
30
+ # Name displayed as the sender in the thank-you email
31
+ attr_accessor :thank_you_from_name
32
+
33
+ # Email address from which the thank-you email is sent
34
+ attr_accessor :thank_you_from_email
35
+
36
+ # Subject line of the thank-you email
37
+ attr_accessor :thank_you_mail_subject
38
+
39
+ # Plain text message body of the thank-you email
40
+ attr_accessor :thank_you_mail_message
41
+
42
+ # Details of the sender of the thank-you email
43
+ attr_accessor :thank_you_sender
44
+
45
+ # Name displayed as the sender in the confirmation email
46
+ attr_accessor :confirm_from_name
47
+
48
+ # Email address from which the confirmation email is sent
49
+ attr_accessor :confirm_from_email
50
+
51
+ # Subject line of the confirmation email
52
+ attr_accessor :confirm_mail_subject
53
+
54
+ # Plain text message body of the confirmation email
55
+ attr_accessor :confirm_mail_message
56
+
57
+ # URL of the success page after confirmation
58
+ attr_accessor :confirm_success_page
59
+
60
+ # Date and time when the list was created
61
+ attr_accessor :created
62
+
63
+ # Date and time when the list was last updated
64
+ attr_accessor :updated
65
+
66
+ # Details of the sender of the confirmation email
67
+ attr_accessor :confirm_sender
68
+
69
+ class EnumAttributeValidator
70
+ attr_reader :datatype
71
+ attr_reader :allowable_values
72
+
73
+ def initialize(datatype, allowable_values)
74
+ @allowable_values = allowable_values.map do |value|
75
+ case datatype.to_s
76
+ when /Integer/i
77
+ value.to_i
78
+ when /Float/i
79
+ value.to_f
80
+ else
81
+ value
82
+ end
83
+ end
84
+ end
85
+
86
+ def valid?(value)
87
+ !value || allowable_values.include?(value)
88
+ end
89
+ end
90
+
91
+ # Attribute mapping from ruby-style variable name to JSON key.
92
+ def self.attribute_map
93
+ {
94
+ :'id' => :'id',
95
+ :'name' => :'name',
96
+ :'type' => :'type',
97
+ :'send_thank_you_mail' => :'sendThankYouMail',
98
+ :'thank_you_from_name' => :'thankYouFromName',
99
+ :'thank_you_from_email' => :'thankYouFromEmail',
100
+ :'thank_you_mail_subject' => :'thankYouMailSubject',
101
+ :'thank_you_mail_message' => :'thankYouMailMessage',
102
+ :'thank_you_sender' => :'thankYouSender',
103
+ :'confirm_from_name' => :'confirmFromName',
104
+ :'confirm_from_email' => :'confirmFromEmail',
105
+ :'confirm_mail_subject' => :'confirmMailSubject',
106
+ :'confirm_mail_message' => :'confirmMailMessage',
107
+ :'confirm_success_page' => :'confirmSuccessPage',
108
+ :'created' => :'created',
109
+ :'updated' => :'updated',
110
+ :'confirm_sender' => :'confirmSender'
111
+ }
112
+ end
113
+
114
+ # Returns all the JSON keys this model knows about
115
+ def self.acceptable_attributes
116
+ attribute_map.values
117
+ end
118
+
119
+ # Attribute type mapping.
120
+ def self.openapi_types
121
+ {
122
+ :'id' => :'String',
123
+ :'name' => :'String',
124
+ :'type' => :'Integer',
125
+ :'send_thank_you_mail' => :'Boolean',
126
+ :'thank_you_from_name' => :'String',
127
+ :'thank_you_from_email' => :'String',
128
+ :'thank_you_mail_subject' => :'String',
129
+ :'thank_you_mail_message' => :'String',
130
+ :'thank_you_sender' => :'String',
131
+ :'confirm_from_name' => :'String',
132
+ :'confirm_from_email' => :'String',
133
+ :'confirm_mail_subject' => :'String',
134
+ :'confirm_mail_message' => :'String',
135
+ :'confirm_success_page' => :'String',
136
+ :'created' => :'Time',
137
+ :'updated' => :'Time',
138
+ :'confirm_sender' => :'String'
139
+ }
140
+ end
141
+
142
+ # List of attributes with nullable: true
143
+ def self.openapi_nullable
144
+ Set.new([
145
+ :'confirm_sender'
146
+ ])
147
+ end
148
+
149
+ # Initializes the object
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ def initialize(attributes = {})
152
+ if (!attributes.is_a?(Hash))
153
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::ListModel` initialize method"
154
+ end
155
+
156
+ # check to see if the attribute exists and convert string to symbol for hash key
157
+ attributes = attributes.each_with_object({}) { |(k, v), h|
158
+ if (!self.class.attribute_map.key?(k.to_sym))
159
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::ListModel`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
160
+ end
161
+ h[k.to_sym] = v
162
+ }
163
+
164
+ if attributes.key?(:'id')
165
+ self.id = attributes[:'id']
166
+ end
167
+
168
+ if attributes.key?(:'name')
169
+ self.name = attributes[:'name']
170
+ end
171
+
172
+ if attributes.key?(:'type')
173
+ self.type = attributes[:'type']
174
+ end
175
+
176
+ if attributes.key?(:'send_thank_you_mail')
177
+ self.send_thank_you_mail = attributes[:'send_thank_you_mail']
178
+ end
179
+
180
+ if attributes.key?(:'thank_you_from_name')
181
+ self.thank_you_from_name = attributes[:'thank_you_from_name']
182
+ end
183
+
184
+ if attributes.key?(:'thank_you_from_email')
185
+ self.thank_you_from_email = attributes[:'thank_you_from_email']
186
+ end
187
+
188
+ if attributes.key?(:'thank_you_mail_subject')
189
+ self.thank_you_mail_subject = attributes[:'thank_you_mail_subject']
190
+ end
191
+
192
+ if attributes.key?(:'thank_you_mail_message')
193
+ self.thank_you_mail_message = attributes[:'thank_you_mail_message']
194
+ end
195
+
196
+ if attributes.key?(:'thank_you_sender')
197
+ self.thank_you_sender = attributes[:'thank_you_sender']
198
+ end
199
+
200
+ if attributes.key?(:'confirm_from_name')
201
+ self.confirm_from_name = attributes[:'confirm_from_name']
202
+ end
203
+
204
+ if attributes.key?(:'confirm_from_email')
205
+ self.confirm_from_email = attributes[:'confirm_from_email']
206
+ end
207
+
208
+ if attributes.key?(:'confirm_mail_subject')
209
+ self.confirm_mail_subject = attributes[:'confirm_mail_subject']
210
+ end
211
+
212
+ if attributes.key?(:'confirm_mail_message')
213
+ self.confirm_mail_message = attributes[:'confirm_mail_message']
214
+ end
215
+
216
+ if attributes.key?(:'confirm_success_page')
217
+ self.confirm_success_page = attributes[:'confirm_success_page']
218
+ end
219
+
220
+ if attributes.key?(:'created')
221
+ self.created = attributes[:'created']
222
+ end
223
+
224
+ if attributes.key?(:'updated')
225
+ self.updated = attributes[:'updated']
226
+ end
227
+
228
+ if attributes.key?(:'confirm_sender')
229
+ self.confirm_sender = attributes[:'confirm_sender']
230
+ end
231
+ end
232
+
233
+ # Show invalid properties with the reasons. Usually used together with valid?
234
+ # @return Array for valid properties with the reasons
235
+ def list_invalid_properties
236
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
237
+ invalid_properties = Array.new
238
+ invalid_properties
239
+ end
240
+
241
+ # Check to see if the all the properties in the model are valid
242
+ # @return true if the model is valid
243
+ def valid?
244
+ warn '[DEPRECATED] the `valid?` method is obsolete'
245
+ type_validator = EnumAttributeValidator.new('Integer', [0, 1])
246
+ return false unless type_validator.valid?(@type)
247
+ true
248
+ end
249
+
250
+ # Custom attribute writer method checking allowed values (enum).
251
+ # @param [Object] type Object to be assigned
252
+ def type=(type)
253
+ validator = EnumAttributeValidator.new('Integer', [0, 1])
254
+ unless validator.valid?(type)
255
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
256
+ end
257
+ @type = type
258
+ end
259
+
260
+ # Checks equality by comparing each attribute.
261
+ # @param [Object] Object to be compared
262
+ def ==(o)
263
+ return true if self.equal?(o)
264
+ self.class == o.class &&
265
+ id == o.id &&
266
+ name == o.name &&
267
+ type == o.type &&
268
+ send_thank_you_mail == o.send_thank_you_mail &&
269
+ thank_you_from_name == o.thank_you_from_name &&
270
+ thank_you_from_email == o.thank_you_from_email &&
271
+ thank_you_mail_subject == o.thank_you_mail_subject &&
272
+ thank_you_mail_message == o.thank_you_mail_message &&
273
+ thank_you_sender == o.thank_you_sender &&
274
+ confirm_from_name == o.confirm_from_name &&
275
+ confirm_from_email == o.confirm_from_email &&
276
+ confirm_mail_subject == o.confirm_mail_subject &&
277
+ confirm_mail_message == o.confirm_mail_message &&
278
+ confirm_success_page == o.confirm_success_page &&
279
+ created == o.created &&
280
+ updated == o.updated &&
281
+ confirm_sender == o.confirm_sender
282
+ end
283
+
284
+ # @see the `==` method
285
+ # @param [Object] Object to be compared
286
+ def eql?(o)
287
+ self == o
288
+ end
289
+
290
+ # Calculates hash code according to all attributes.
291
+ # @return [Integer] Hash code
292
+ def hash
293
+ [id, name, type, send_thank_you_mail, thank_you_from_name, thank_you_from_email, thank_you_mail_subject, thank_you_mail_message, thank_you_sender, confirm_from_name, confirm_from_email, confirm_mail_subject, confirm_mail_message, confirm_success_page, created, updated, confirm_sender].hash
294
+ end
295
+
296
+ # Builds the object from hash
297
+ # @param [Hash] attributes Model attributes in the form of hash
298
+ # @return [Object] Returns the model itself
299
+ def self.build_from_hash(attributes)
300
+ return nil unless attributes.is_a?(Hash)
301
+ attributes = attributes.transform_keys(&:to_sym)
302
+ transformed_hash = {}
303
+ openapi_types.each_pair do |key, type|
304
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
305
+ transformed_hash["#{key}"] = nil
306
+ elsif type =~ /\AArray<(.*)>/i
307
+ # check to ensure the input is an array given that the attribute
308
+ # is documented as an array but the input is not
309
+ if attributes[attribute_map[key]].is_a?(Array)
310
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
311
+ end
312
+ elsif !attributes[attribute_map[key]].nil?
313
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
314
+ end
315
+ end
316
+ new(transformed_hash)
317
+ end
318
+
319
+ # Deserializes the data based on type
320
+ # @param string type Data type
321
+ # @param string value Value to be deserialized
322
+ # @return [Object] Deserialized data
323
+ def self._deserialize(type, value)
324
+ case type.to_sym
325
+ when :Time
326
+ Time.parse(value)
327
+ when :Date
328
+ Date.parse(value)
329
+ when :String
330
+ value.to_s
331
+ when :Integer
332
+ value.to_i
333
+ when :Float
334
+ value.to_f
335
+ when :Boolean
336
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
337
+ true
338
+ else
339
+ false
340
+ end
341
+ when :Object
342
+ # generic object (usually a Hash), return directly
343
+ value
344
+ when /\AArray<(?<inner_type>.+)>\z/
345
+ inner_type = Regexp.last_match[:inner_type]
346
+ value.map { |v| _deserialize(inner_type, v) }
347
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
348
+ k_type = Regexp.last_match[:k_type]
349
+ v_type = Regexp.last_match[:v_type]
350
+ {}.tap do |hash|
351
+ value.each do |k, v|
352
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
353
+ end
354
+ end
355
+ else # model
356
+ # models (e.g. Pet) or oneOf
357
+ klass = SendX.const_get(type)
358
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
359
+ end
360
+ end
361
+
362
+ # Returns the string representation of the object
363
+ # @return [String] String presentation of the object
364
+ def to_s
365
+ to_hash.to_s
366
+ end
367
+
368
+ # to_body is an alias to to_hash (backward compatibility)
369
+ # @return [Hash] Returns the object in the form of hash
370
+ def to_body
371
+ to_hash
372
+ end
373
+
374
+ # Returns the object in the form of hash
375
+ # @return [Hash] Returns the object in the form of hash
376
+ def to_hash
377
+ hash = {}
378
+ self.class.attribute_map.each_pair do |attr, param|
379
+ value = self.send(attr)
380
+ if value.nil?
381
+ is_nullable = self.class.openapi_nullable.include?(attr)
382
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
383
+ end
384
+
385
+ hash[param] = _to_hash(value)
386
+ end
387
+ hash
388
+ end
389
+
390
+ # Outputs non-array value in the form of hash
391
+ # For object, use to_hash. Otherwise, just return the value
392
+ # @param [Object] value Any valid value
393
+ # @return [Hash] Returns the value in the form of hash
394
+ def _to_hash(value)
395
+ if value.is_a?(Array)
396
+ value.compact.map { |v| _to_hash(v) }
397
+ elsif value.is_a?(Hash)
398
+ {}.tap do |hash|
399
+ value.each { |k, v| hash[k] = _to_hash(v) }
400
+ end
401
+ elsif value.respond_to? :to_hash
402
+ value.to_hash
403
+ else
404
+ value
405
+ end
406
+ end
407
+
408
+ end
409
+
410
+ end