zyphr 0.1.19 → 0.1.21

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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -6
  3. data/docs/AuthEmailTemplate.md +42 -0
  4. data/docs/AuthEmailTemplateDefault.md +26 -0
  5. data/docs/AuthEmailTemplateDefaultResponse.md +20 -0
  6. data/docs/AuthEmailTemplateDeleteResponse.md +20 -0
  7. data/docs/{SuccessResultData.md → AuthEmailTemplateDeleteResponseData.md} +2 -2
  8. data/docs/AuthEmailTemplateListResponse.md +20 -0
  9. data/docs/AuthEmailTemplatePreviewDraft.md +28 -0
  10. data/docs/AuthEmailTemplatePreviewRequest.md +20 -0
  11. data/docs/AuthEmailTemplatePreviewResponse.md +20 -0
  12. data/docs/AuthEmailTemplatePreviewResult.md +26 -0
  13. data/docs/AuthEmailTemplateResponse.md +20 -0
  14. data/docs/AuthEmailTemplateTestRequest.md +20 -0
  15. data/docs/AuthEmailTemplateTestResponse.md +20 -0
  16. data/docs/AuthEmailTemplateTestResult.md +20 -0
  17. data/docs/AuthEmailTemplateVersion.md +38 -0
  18. data/docs/AuthEmailTemplateVersionsResponse.md +20 -0
  19. data/docs/AuthEmailTemplatesApi.md +782 -0
  20. data/docs/AuthEmailType.md +15 -0
  21. data/docs/BulkUpsertAuthEmailTemplatesRequest.md +22 -0
  22. data/docs/BulkUpsertAuthEmailTemplatesResponse.md +20 -0
  23. data/docs/ResubscribeResponse.md +1 -1
  24. data/docs/SendSlackMessageRequest.md +40 -0
  25. data/docs/SendSlackMessageResponse.md +20 -0
  26. data/docs/SendSlackMessageResult.md +28 -0
  27. data/docs/SlackApi.md +233 -0
  28. data/docs/SlackMessage.md +50 -0
  29. data/docs/SlackMessageListResponse.md +20 -0
  30. data/docs/SlackMessageListResponseMeta.md +24 -0
  31. data/docs/SlackMessageResponse.md +20 -0
  32. data/docs/SlackMessageStatus.md +15 -0
  33. data/docs/SlackMessageSummary.md +38 -0
  34. data/docs/SuccessResult.md +1 -1
  35. data/docs/UpsertAuthEmailTemplateRequest.md +34 -0
  36. data/lib/zyphr/api/auth_email_templates_api.rb +688 -0
  37. data/lib/zyphr/api/slack_api.rb +233 -0
  38. data/lib/zyphr/models/auth_email_template.rb +372 -0
  39. data/lib/zyphr/models/auth_email_template_default.rb +281 -0
  40. data/lib/zyphr/models/auth_email_template_default_response.rb +229 -0
  41. data/lib/zyphr/models/auth_email_template_delete_response.rb +229 -0
  42. data/lib/zyphr/models/{success_result_data.rb → auth_email_template_delete_response_data.rb} +3 -3
  43. data/lib/zyphr/models/auth_email_template_list_response.rb +231 -0
  44. data/lib/zyphr/models/auth_email_template_preview_draft.rb +272 -0
  45. data/lib/zyphr/models/auth_email_template_preview_request.rb +232 -0
  46. data/lib/zyphr/models/auth_email_template_preview_response.rb +229 -0
  47. data/lib/zyphr/models/auth_email_template_preview_result.rb +258 -0
  48. data/lib/zyphr/models/auth_email_template_response.rb +229 -0
  49. data/lib/zyphr/models/auth_email_template_test_request.rb +249 -0
  50. data/lib/zyphr/models/auth_email_template_test_response.rb +229 -0
  51. data/lib/zyphr/models/auth_email_template_test_result.rb +229 -0
  52. data/lib/zyphr/models/auth_email_template_version.rb +352 -0
  53. data/lib/zyphr/models/auth_email_template_versions_response.rb +231 -0
  54. data/lib/zyphr/models/auth_email_type.rb +41 -0
  55. data/lib/zyphr/models/bulk_upsert_auth_email_templates_request.rb +239 -0
  56. data/lib/zyphr/models/bulk_upsert_auth_email_templates_response.rb +231 -0
  57. data/lib/zyphr/models/resubscribe_response.rb +1 -1
  58. data/lib/zyphr/models/send_slack_message_request.rb +340 -0
  59. data/lib/zyphr/models/send_slack_message_response.rb +229 -0
  60. data/lib/zyphr/models/send_slack_message_result.rb +289 -0
  61. data/lib/zyphr/models/slack_message.rb +406 -0
  62. data/lib/zyphr/models/slack_message_list_response.rb +231 -0
  63. data/lib/zyphr/models/slack_message_list_response_meta.rb +254 -0
  64. data/lib/zyphr/models/slack_message_response.rb +229 -0
  65. data/lib/zyphr/models/slack_message_status.rb +43 -0
  66. data/lib/zyphr/models/slack_message_summary.rb +340 -0
  67. data/lib/zyphr/models/success_result.rb +1 -1
  68. data/lib/zyphr/models/upsert_auth_email_template_request.rb +335 -0
  69. data/lib/zyphr.rb +31 -1
  70. data/spec/api/auth_email_templates_api_spec.rb +157 -0
  71. data/spec/api/slack_api_spec.rb +75 -0
  72. data/spec/models/auth_email_template_default_response_spec.rb +42 -0
  73. data/spec/models/auth_email_template_default_spec.rb +60 -0
  74. data/spec/models/{success_result_data_spec.rb → auth_email_template_delete_response_data_spec.rb} +6 -6
  75. data/spec/models/auth_email_template_delete_response_spec.rb +42 -0
  76. data/spec/models/auth_email_template_list_response_spec.rb +42 -0
  77. data/spec/models/auth_email_template_preview_draft_spec.rb +66 -0
  78. data/spec/models/auth_email_template_preview_request_spec.rb +42 -0
  79. data/spec/models/auth_email_template_preview_response_spec.rb +42 -0
  80. data/spec/models/auth_email_template_preview_result_spec.rb +60 -0
  81. data/spec/models/auth_email_template_response_spec.rb +42 -0
  82. data/spec/models/auth_email_template_spec.rb +112 -0
  83. data/spec/models/auth_email_template_test_request_spec.rb +42 -0
  84. data/spec/models/auth_email_template_test_response_spec.rb +42 -0
  85. data/spec/models/auth_email_template_test_result_spec.rb +42 -0
  86. data/spec/models/auth_email_template_version_spec.rb +100 -0
  87. data/spec/models/auth_email_template_versions_response_spec.rb +42 -0
  88. data/spec/models/auth_email_type_spec.rb +30 -0
  89. data/spec/models/bulk_upsert_auth_email_templates_request_spec.rb +48 -0
  90. data/spec/models/bulk_upsert_auth_email_templates_response_spec.rb +42 -0
  91. data/spec/models/send_slack_message_request_spec.rb +102 -0
  92. data/spec/models/send_slack_message_response_spec.rb +42 -0
  93. data/spec/models/send_slack_message_result_spec.rb +66 -0
  94. data/spec/models/slack_message_list_response_meta_spec.rb +54 -0
  95. data/spec/models/slack_message_list_response_spec.rb +42 -0
  96. data/spec/models/slack_message_response_spec.rb +42 -0
  97. data/spec/models/slack_message_spec.rb +132 -0
  98. data/spec/models/slack_message_status_spec.rb +30 -0
  99. data/spec/models/slack_message_summary_spec.rb +96 -0
  100. data/spec/models/upsert_auth_email_template_request_spec.rb +88 -0
  101. data/zyphr.gemspec +1 -1
  102. metadata +126 -6
@@ -0,0 +1,229 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class AuthEmailTemplateTestResult
18
+ attr_accessor :success
19
+
20
+ attr_accessor :message_id
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'success' => :'success',
26
+ :'message_id' => :'message_id'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'success' => :'Boolean',
44
+ :'message_id' => :'String'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AuthEmailTemplateTestResult` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AuthEmailTemplateTestResult`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'success')
71
+ self.success = attributes[:'success']
72
+ end
73
+
74
+ if attributes.key?(:'message_id')
75
+ self.message_id = attributes[:'message_id']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ warn '[DEPRECATED] the `valid?` method is obsolete'
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ success == o.success &&
100
+ message_id == o.message_id
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Integer] Hash code
111
+ def hash
112
+ [success, message_id].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def self.build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ attributes = attributes.transform_keys(&:to_sym)
121
+ transformed_hash = {}
122
+ openapi_types.each_pair do |key, type|
123
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = nil
125
+ elsif type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[attribute_map[key]].is_a?(Array)
129
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
130
+ end
131
+ elsif !attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
133
+ end
134
+ end
135
+ new(transformed_hash)
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def self._deserialize(type, value)
143
+ case type.to_sym
144
+ when :Time
145
+ Time.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :Boolean
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ # models (e.g. Pet) or oneOf
176
+ klass = Zyphr.const_get(type)
177
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.openapi_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end
@@ -0,0 +1,352 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class AuthEmailTemplateVersion
18
+ attr_accessor :version
19
+
20
+ attr_accessor :subject
21
+
22
+ attr_accessor :html
23
+
24
+ attr_accessor :text
25
+
26
+ attr_accessor :mjml_source
27
+
28
+ attr_accessor :design_json
29
+
30
+ attr_accessor :editor_type
31
+
32
+ attr_accessor :from_name
33
+
34
+ attr_accessor :reply_to
35
+
36
+ attr_accessor :is_enabled
37
+
38
+ attr_accessor :created_at
39
+
40
+ class EnumAttributeValidator
41
+ attr_reader :datatype
42
+ attr_reader :allowable_values
43
+
44
+ def initialize(datatype, allowable_values)
45
+ @allowable_values = allowable_values.map do |value|
46
+ case datatype.to_s
47
+ when /Integer/i
48
+ value.to_i
49
+ when /Float/i
50
+ value.to_f
51
+ else
52
+ value
53
+ end
54
+ end
55
+ end
56
+
57
+ def valid?(value)
58
+ !value || allowable_values.include?(value)
59
+ end
60
+ end
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :'version' => :'version',
66
+ :'subject' => :'subject',
67
+ :'html' => :'html',
68
+ :'text' => :'text',
69
+ :'mjml_source' => :'mjml_source',
70
+ :'design_json' => :'design_json',
71
+ :'editor_type' => :'editor_type',
72
+ :'from_name' => :'from_name',
73
+ :'reply_to' => :'reply_to',
74
+ :'is_enabled' => :'is_enabled',
75
+ :'created_at' => :'created_at'
76
+ }
77
+ end
78
+
79
+ # Returns attribute mapping this model knows about
80
+ def self.acceptable_attribute_map
81
+ attribute_map
82
+ end
83
+
84
+ # Returns all the JSON keys this model knows about
85
+ def self.acceptable_attributes
86
+ acceptable_attribute_map.values
87
+ end
88
+
89
+ # Attribute type mapping.
90
+ def self.openapi_types
91
+ {
92
+ :'version' => :'Integer',
93
+ :'subject' => :'String',
94
+ :'html' => :'String',
95
+ :'text' => :'String',
96
+ :'mjml_source' => :'String',
97
+ :'design_json' => :'Hash<String, Object>',
98
+ :'editor_type' => :'String',
99
+ :'from_name' => :'String',
100
+ :'reply_to' => :'String',
101
+ :'is_enabled' => :'Boolean',
102
+ :'created_at' => :'Time'
103
+ }
104
+ end
105
+
106
+ # List of attributes with nullable: true
107
+ def self.openapi_nullable
108
+ Set.new([
109
+ :'text',
110
+ :'mjml_source',
111
+ :'design_json',
112
+ :'editor_type',
113
+ :'from_name',
114
+ :'reply_to',
115
+ ])
116
+ end
117
+
118
+ # Initializes the object
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ def initialize(attributes = {})
121
+ if (!attributes.is_a?(Hash))
122
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AuthEmailTemplateVersion` initialize method"
123
+ end
124
+
125
+ # check to see if the attribute exists and convert string to symbol for hash key
126
+ acceptable_attribute_map = self.class.acceptable_attribute_map
127
+ attributes = attributes.each_with_object({}) { |(k, v), h|
128
+ if (!acceptable_attribute_map.key?(k.to_sym))
129
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AuthEmailTemplateVersion`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
130
+ end
131
+ h[k.to_sym] = v
132
+ }
133
+
134
+ if attributes.key?(:'version')
135
+ self.version = attributes[:'version']
136
+ end
137
+
138
+ if attributes.key?(:'subject')
139
+ self.subject = attributes[:'subject']
140
+ end
141
+
142
+ if attributes.key?(:'html')
143
+ self.html = attributes[:'html']
144
+ end
145
+
146
+ if attributes.key?(:'text')
147
+ self.text = attributes[:'text']
148
+ end
149
+
150
+ if attributes.key?(:'mjml_source')
151
+ self.mjml_source = attributes[:'mjml_source']
152
+ end
153
+
154
+ if attributes.key?(:'design_json')
155
+ if (value = attributes[:'design_json']).is_a?(Hash)
156
+ self.design_json = value
157
+ end
158
+ end
159
+
160
+ if attributes.key?(:'editor_type')
161
+ self.editor_type = attributes[:'editor_type']
162
+ end
163
+
164
+ if attributes.key?(:'from_name')
165
+ self.from_name = attributes[:'from_name']
166
+ end
167
+
168
+ if attributes.key?(:'reply_to')
169
+ self.reply_to = attributes[:'reply_to']
170
+ end
171
+
172
+ if attributes.key?(:'is_enabled')
173
+ self.is_enabled = attributes[:'is_enabled']
174
+ end
175
+
176
+ if attributes.key?(:'created_at')
177
+ self.created_at = attributes[:'created_at']
178
+ end
179
+ end
180
+
181
+ # Show invalid properties with the reasons. Usually used together with valid?
182
+ # @return Array for valid properties with the reasons
183
+ def list_invalid_properties
184
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
185
+ invalid_properties = Array.new
186
+ invalid_properties
187
+ end
188
+
189
+ # Check to see if the all the properties in the model are valid
190
+ # @return true if the model is valid
191
+ def valid?
192
+ warn '[DEPRECATED] the `valid?` method is obsolete'
193
+ editor_type_validator = EnumAttributeValidator.new('String', ["code", "mjml", "design"])
194
+ return false unless editor_type_validator.valid?(@editor_type)
195
+ true
196
+ end
197
+
198
+ # Custom attribute writer method checking allowed values (enum).
199
+ # @param [Object] editor_type Object to be assigned
200
+ def editor_type=(editor_type)
201
+ validator = EnumAttributeValidator.new('String', ["code", "mjml", "design"])
202
+ unless validator.valid?(editor_type)
203
+ fail ArgumentError, "invalid value for \"editor_type\", must be one of #{validator.allowable_values}."
204
+ end
205
+ @editor_type = editor_type
206
+ end
207
+
208
+ # Checks equality by comparing each attribute.
209
+ # @param [Object] Object to be compared
210
+ def ==(o)
211
+ return true if self.equal?(o)
212
+ self.class == o.class &&
213
+ version == o.version &&
214
+ subject == o.subject &&
215
+ html == o.html &&
216
+ text == o.text &&
217
+ mjml_source == o.mjml_source &&
218
+ design_json == o.design_json &&
219
+ editor_type == o.editor_type &&
220
+ from_name == o.from_name &&
221
+ reply_to == o.reply_to &&
222
+ is_enabled == o.is_enabled &&
223
+ created_at == o.created_at
224
+ end
225
+
226
+ # @see the `==` method
227
+ # @param [Object] Object to be compared
228
+ def eql?(o)
229
+ self == o
230
+ end
231
+
232
+ # Calculates hash code according to all attributes.
233
+ # @return [Integer] Hash code
234
+ def hash
235
+ [version, subject, html, text, mjml_source, design_json, editor_type, from_name, reply_to, is_enabled, created_at].hash
236
+ end
237
+
238
+ # Builds the object from hash
239
+ # @param [Hash] attributes Model attributes in the form of hash
240
+ # @return [Object] Returns the model itself
241
+ def self.build_from_hash(attributes)
242
+ return nil unless attributes.is_a?(Hash)
243
+ attributes = attributes.transform_keys(&:to_sym)
244
+ transformed_hash = {}
245
+ openapi_types.each_pair do |key, type|
246
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
247
+ transformed_hash["#{key}"] = nil
248
+ elsif type =~ /\AArray<(.*)>/i
249
+ # check to ensure the input is an array given that the attribute
250
+ # is documented as an array but the input is not
251
+ if attributes[attribute_map[key]].is_a?(Array)
252
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
253
+ end
254
+ elsif !attributes[attribute_map[key]].nil?
255
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
256
+ end
257
+ end
258
+ new(transformed_hash)
259
+ end
260
+
261
+ # Deserializes the data based on type
262
+ # @param string type Data type
263
+ # @param string value Value to be deserialized
264
+ # @return [Object] Deserialized data
265
+ def self._deserialize(type, value)
266
+ case type.to_sym
267
+ when :Time
268
+ Time.parse(value)
269
+ when :Date
270
+ Date.parse(value)
271
+ when :String
272
+ value.to_s
273
+ when :Integer
274
+ value.to_i
275
+ when :Float
276
+ value.to_f
277
+ when :Boolean
278
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
279
+ true
280
+ else
281
+ false
282
+ end
283
+ when :Object
284
+ # generic object (usually a Hash), return directly
285
+ value
286
+ when /\AArray<(?<inner_type>.+)>\z/
287
+ inner_type = Regexp.last_match[:inner_type]
288
+ value.map { |v| _deserialize(inner_type, v) }
289
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
290
+ k_type = Regexp.last_match[:k_type]
291
+ v_type = Regexp.last_match[:v_type]
292
+ {}.tap do |hash|
293
+ value.each do |k, v|
294
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
295
+ end
296
+ end
297
+ else # model
298
+ # models (e.g. Pet) or oneOf
299
+ klass = Zyphr.const_get(type)
300
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
301
+ end
302
+ end
303
+
304
+ # Returns the string representation of the object
305
+ # @return [String] String presentation of the object
306
+ def to_s
307
+ to_hash.to_s
308
+ end
309
+
310
+ # to_body is an alias to to_hash (backward compatibility)
311
+ # @return [Hash] Returns the object in the form of hash
312
+ def to_body
313
+ to_hash
314
+ end
315
+
316
+ # Returns the object in the form of hash
317
+ # @return [Hash] Returns the object in the form of hash
318
+ def to_hash
319
+ hash = {}
320
+ self.class.attribute_map.each_pair do |attr, param|
321
+ value = self.send(attr)
322
+ if value.nil?
323
+ is_nullable = self.class.openapi_nullable.include?(attr)
324
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
325
+ end
326
+
327
+ hash[param] = _to_hash(value)
328
+ end
329
+ hash
330
+ end
331
+
332
+ # Outputs non-array value in the form of hash
333
+ # For object, use to_hash. Otherwise, just return the value
334
+ # @param [Object] value Any valid value
335
+ # @return [Hash] Returns the value in the form of hash
336
+ def _to_hash(value)
337
+ if value.is_a?(Array)
338
+ value.compact.map { |v| _to_hash(v) }
339
+ elsif value.is_a?(Hash)
340
+ {}.tap do |hash|
341
+ value.each { |k, v| hash[k] = _to_hash(v) }
342
+ end
343
+ elsif value.respond_to? :to_hash
344
+ value.to_hash
345
+ else
346
+ value
347
+ end
348
+ end
349
+
350
+ end
351
+
352
+ end