zyphr 0.1.75 → 0.1.76

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -1
  3. data/docs/CreateInboxLabelRequest.md +20 -0
  4. data/docs/Draft.md +36 -0
  5. data/docs/DraftAddress.md +20 -0
  6. data/docs/DraftListResponse.md +20 -0
  7. data/docs/DraftRequest.md +30 -0
  8. data/docs/DraftResponse.md +20 -0
  9. data/docs/ForwardEmailRequest.md +34 -0
  10. data/docs/InboundEmailApi.md +1853 -157
  11. data/docs/InboxLabel.md +26 -0
  12. data/docs/InboxLabelListResponse.md +20 -0
  13. data/docs/InboxLabelResponse.md +20 -0
  14. data/docs/{ReplyToInboundEmailRequest.md → ReplyEmailRequest.md} +3 -3
  15. data/docs/Thread.md +40 -0
  16. data/docs/ThreadEmail.md +38 -0
  17. data/docs/ThreadEmailAttachmentsInner.md +24 -0
  18. data/docs/ThreadEmailFrom.md +20 -0
  19. data/docs/ThreadEmailListResponse.md +20 -0
  20. data/docs/ThreadEmailResponse.md +20 -0
  21. data/docs/ThreadFolder.md +15 -0
  22. data/docs/ThreadLabelsInner.md +22 -0
  23. data/docs/ThreadLabelsRequest.md +18 -0
  24. data/docs/ThreadListResponse.md +20 -0
  25. data/docs/ThreadListResponseMeta.md +20 -0
  26. data/docs/ThreadResponse.md +20 -0
  27. data/docs/UpdateInboxLabelRequest.md +20 -0
  28. data/docs/UpdateThreadRequest.md +22 -0
  29. data/lib/zyphr/api/inbound_email_api.rb +1768 -168
  30. data/lib/zyphr/models/create_inbox_label_request.rb +272 -0
  31. data/lib/zyphr/models/draft.rb +375 -0
  32. data/lib/zyphr/models/draft_address.rb +249 -0
  33. data/lib/zyphr/models/draft_list_response.rb +231 -0
  34. data/lib/zyphr/models/draft_request.rb +299 -0
  35. data/lib/zyphr/models/draft_response.rb +229 -0
  36. data/lib/zyphr/models/forward_email_request.rb +393 -0
  37. data/lib/zyphr/models/inbox_label.rb +258 -0
  38. data/lib/zyphr/models/inbox_label_list_response.rb +231 -0
  39. data/lib/zyphr/models/inbox_label_response.rb +229 -0
  40. data/lib/zyphr/models/{reply_to_inbound_email_request.rb → reply_email_request.rb} +4 -3
  41. data/lib/zyphr/models/thread.rb +352 -0
  42. data/lib/zyphr/models/thread_email.rb +353 -0
  43. data/lib/zyphr/models/thread_email_attachments_inner.rb +248 -0
  44. data/lib/zyphr/models/thread_email_from.rb +230 -0
  45. data/lib/zyphr/models/thread_email_list_response.rb +231 -0
  46. data/lib/zyphr/models/thread_email_response.rb +229 -0
  47. data/lib/zyphr/models/thread_folder.rb +43 -0
  48. data/lib/zyphr/models/thread_labels_inner.rb +239 -0
  49. data/lib/zyphr/models/thread_labels_request.rb +248 -0
  50. data/lib/zyphr/models/thread_list_response.rb +231 -0
  51. data/lib/zyphr/models/thread_list_response_meta.rb +237 -0
  52. data/lib/zyphr/models/thread_response.rb +229 -0
  53. data/lib/zyphr/models/update_inbox_label_request.rb +264 -0
  54. data/lib/zyphr/models/update_thread_request.rb +262 -0
  55. data/lib/zyphr.rb +25 -1
  56. data/spec/api/inbound_email_api_spec.rb +292 -1
  57. data/spec/models/create_inbox_label_request_spec.rb +42 -0
  58. data/spec/models/draft_address_spec.rb +42 -0
  59. data/spec/models/draft_list_response_spec.rb +42 -0
  60. data/spec/models/draft_request_spec.rb +72 -0
  61. data/spec/models/draft_response_spec.rb +42 -0
  62. data/spec/models/draft_spec.rb +90 -0
  63. data/spec/models/forward_email_request_spec.rb +88 -0
  64. data/spec/models/inbox_label_list_response_spec.rb +42 -0
  65. data/spec/models/inbox_label_response_spec.rb +42 -0
  66. data/spec/models/inbox_label_spec.rb +60 -0
  67. data/spec/models/{reply_to_inbound_email_request_spec.rb → reply_email_request_spec.rb} +6 -6
  68. data/spec/models/thread_email_attachments_inner_spec.rb +54 -0
  69. data/spec/models/thread_email_from_spec.rb +42 -0
  70. data/spec/models/thread_email_list_response_spec.rb +42 -0
  71. data/spec/models/thread_email_response_spec.rb +42 -0
  72. data/spec/models/thread_email_spec.rb +100 -0
  73. data/spec/models/thread_folder_spec.rb +30 -0
  74. data/spec/models/thread_labels_inner_spec.rb +48 -0
  75. data/spec/models/thread_labels_request_spec.rb +36 -0
  76. data/spec/models/thread_list_response_meta_spec.rb +42 -0
  77. data/spec/models/thread_list_response_spec.rb +42 -0
  78. data/spec/models/thread_response_spec.rb +42 -0
  79. data/spec/models/thread_spec.rb +102 -0
  80. data/spec/models/update_inbox_label_request_spec.rb +42 -0
  81. data/spec/models/update_thread_request_spec.rb +48 -0
  82. data/zyphr.gemspec +1 -1
  83. metadata +102 -6
@@ -0,0 +1,352 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a developer platform for user authentication and transactional messaging. One API covers auth (passkeys, social sign-in, passwordless, MFA, sessions, organizations) plus email, push notifications, SMS, in-app messages, and webhooks. ## 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. > **Test keys are being retired.** `zy_test_*` keys are no longer issued, and existing ones stop working on **21 October 2026**. They never delivered mail — sends were mocked and marked sent without reaching a provider, so they could not verify domain authentication, rendering, or deliverability. To test your integration, use a `zy_live_*` key against a verified domain and send to an address you control. ## 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 ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## 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
+ # A conversation of received mail and your replies, linked by email headers
18
+ class Thread
19
+ attr_accessor :id
20
+
21
+ # Inbox of the email that started the thread
22
+ attr_accessor :inbox_id
23
+
24
+ attr_accessor :subject
25
+
26
+ attr_accessor :folder
27
+
28
+ # False whenever new mail arrives
29
+ attr_accessor :read
30
+
31
+ attr_accessor :assignee_user_id
32
+
33
+ attr_accessor :labels
34
+
35
+ # Addresses that have written in, first-seen order (up to 10)
36
+ attr_accessor :participants
37
+
38
+ attr_accessor :message_count
39
+
40
+ attr_accessor :last_message_at
41
+
42
+ attr_accessor :created_at
43
+
44
+ attr_accessor :updated_at
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'id' => :'id',
72
+ :'inbox_id' => :'inbox_id',
73
+ :'subject' => :'subject',
74
+ :'folder' => :'folder',
75
+ :'read' => :'read',
76
+ :'assignee_user_id' => :'assignee_user_id',
77
+ :'labels' => :'labels',
78
+ :'participants' => :'participants',
79
+ :'message_count' => :'message_count',
80
+ :'last_message_at' => :'last_message_at',
81
+ :'created_at' => :'created_at',
82
+ :'updated_at' => :'updated_at'
83
+ }
84
+ end
85
+
86
+ # Returns attribute mapping this model knows about
87
+ def self.acceptable_attribute_map
88
+ attribute_map
89
+ end
90
+
91
+ # Returns all the JSON keys this model knows about
92
+ def self.acceptable_attributes
93
+ acceptable_attribute_map.values
94
+ end
95
+
96
+ # Attribute type mapping.
97
+ def self.openapi_types
98
+ {
99
+ :'id' => :'String',
100
+ :'inbox_id' => :'String',
101
+ :'subject' => :'String',
102
+ :'folder' => :'ThreadFolder',
103
+ :'read' => :'Boolean',
104
+ :'assignee_user_id' => :'String',
105
+ :'labels' => :'Array<ThreadLabelsInner>',
106
+ :'participants' => :'Array<String>',
107
+ :'message_count' => :'Integer',
108
+ :'last_message_at' => :'Time',
109
+ :'created_at' => :'Time',
110
+ :'updated_at' => :'Time'
111
+ }
112
+ end
113
+
114
+ # List of attributes with nullable: true
115
+ def self.openapi_nullable
116
+ Set.new([
117
+ :'inbox_id',
118
+ :'subject',
119
+ :'assignee_user_id',
120
+ ])
121
+ end
122
+
123
+ # Initializes the object
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ def initialize(attributes = {})
126
+ if (!attributes.is_a?(Hash))
127
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::Thread` initialize method"
128
+ end
129
+
130
+ # check to see if the attribute exists and convert string to symbol for hash key
131
+ acceptable_attribute_map = self.class.acceptable_attribute_map
132
+ attributes = attributes.each_with_object({}) { |(k, v), h|
133
+ if (!acceptable_attribute_map.key?(k.to_sym))
134
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::Thread`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
135
+ end
136
+ h[k.to_sym] = v
137
+ }
138
+
139
+ if attributes.key?(:'id')
140
+ self.id = attributes[:'id']
141
+ end
142
+
143
+ if attributes.key?(:'inbox_id')
144
+ self.inbox_id = attributes[:'inbox_id']
145
+ end
146
+
147
+ if attributes.key?(:'subject')
148
+ self.subject = attributes[:'subject']
149
+ end
150
+
151
+ if attributes.key?(:'folder')
152
+ self.folder = attributes[:'folder']
153
+ end
154
+
155
+ if attributes.key?(:'read')
156
+ self.read = attributes[:'read']
157
+ end
158
+
159
+ if attributes.key?(:'assignee_user_id')
160
+ self.assignee_user_id = attributes[:'assignee_user_id']
161
+ end
162
+
163
+ if attributes.key?(:'labels')
164
+ if (value = attributes[:'labels']).is_a?(Array)
165
+ self.labels = value
166
+ end
167
+ end
168
+
169
+ if attributes.key?(:'participants')
170
+ if (value = attributes[:'participants']).is_a?(Array)
171
+ self.participants = value
172
+ end
173
+ end
174
+
175
+ if attributes.key?(:'message_count')
176
+ self.message_count = attributes[:'message_count']
177
+ end
178
+
179
+ if attributes.key?(:'last_message_at')
180
+ self.last_message_at = attributes[:'last_message_at']
181
+ end
182
+
183
+ if attributes.key?(:'created_at')
184
+ self.created_at = attributes[:'created_at']
185
+ end
186
+
187
+ if attributes.key?(:'updated_at')
188
+ self.updated_at = attributes[:'updated_at']
189
+ end
190
+ end
191
+
192
+ # Show invalid properties with the reasons. Usually used together with valid?
193
+ # @return Array for valid properties with the reasons
194
+ def list_invalid_properties
195
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
196
+ invalid_properties = Array.new
197
+ invalid_properties
198
+ end
199
+
200
+ # Check to see if the all the properties in the model are valid
201
+ # @return true if the model is valid
202
+ def valid?
203
+ warn '[DEPRECATED] the `valid?` method is obsolete'
204
+ true
205
+ end
206
+
207
+ # Checks equality by comparing each attribute.
208
+ # @param [Object] Object to be compared
209
+ def ==(o)
210
+ return true if self.equal?(o)
211
+ self.class == o.class &&
212
+ id == o.id &&
213
+ inbox_id == o.inbox_id &&
214
+ subject == o.subject &&
215
+ folder == o.folder &&
216
+ read == o.read &&
217
+ assignee_user_id == o.assignee_user_id &&
218
+ labels == o.labels &&
219
+ participants == o.participants &&
220
+ message_count == o.message_count &&
221
+ last_message_at == o.last_message_at &&
222
+ created_at == o.created_at &&
223
+ updated_at == o.updated_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
+ [id, inbox_id, subject, folder, read, assignee_user_id, labels, participants, message_count, last_message_at, created_at, updated_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
@@ -0,0 +1,353 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a developer platform for user authentication and transactional messaging. One API covers auth (passkeys, social sign-in, passwordless, MFA, sessions, organizations) plus email, push notifications, SMS, in-app messages, and webhooks. ## 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. > **Test keys are being retired.** `zy_test_*` keys are no longer issued, and existing ones stop working on **21 October 2026**. They never delivered mail — sends were mocked and marked sent without reaching a provider, so they could not verify domain authentication, rendering, or deliverability. To test your integration, use a `zy_live_*` key against a verified domain and send to an address you control. ## 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 ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## 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 ThreadEmail
18
+ attr_accessor :id
19
+
20
+ # `inbound` is a received email (an `/inbound-emails` id); `outbound` is one you sent (an `/emails` id)
21
+ attr_accessor :direction
22
+
23
+ attr_accessor :from
24
+
25
+ attr_accessor :to
26
+
27
+ attr_accessor :cc
28
+
29
+ attr_accessor :subject
30
+
31
+ attr_accessor :text
32
+
33
+ attr_accessor :html
34
+
35
+ attr_accessor :status
36
+
37
+ # Received attachments; download with `GET /inbound-emails/{id}/attachments/{attachmentId}`
38
+ attr_accessor :attachments
39
+
40
+ attr_accessor :created_at
41
+
42
+ class EnumAttributeValidator
43
+ attr_reader :datatype
44
+ attr_reader :allowable_values
45
+
46
+ def initialize(datatype, allowable_values)
47
+ @allowable_values = allowable_values.map do |value|
48
+ case datatype.to_s
49
+ when /Integer/i
50
+ value.to_i
51
+ when /Float/i
52
+ value.to_f
53
+ else
54
+ value
55
+ end
56
+ end
57
+ end
58
+
59
+ def valid?(value)
60
+ !value || allowable_values.include?(value)
61
+ end
62
+ end
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'id' => :'id',
68
+ :'direction' => :'direction',
69
+ :'from' => :'from',
70
+ :'to' => :'to',
71
+ :'cc' => :'cc',
72
+ :'subject' => :'subject',
73
+ :'text' => :'text',
74
+ :'html' => :'html',
75
+ :'status' => :'status',
76
+ :'attachments' => :'attachments',
77
+ :'created_at' => :'created_at'
78
+ }
79
+ end
80
+
81
+ # Returns attribute mapping this model knows about
82
+ def self.acceptable_attribute_map
83
+ attribute_map
84
+ end
85
+
86
+ # Returns all the JSON keys this model knows about
87
+ def self.acceptable_attributes
88
+ acceptable_attribute_map.values
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.openapi_types
93
+ {
94
+ :'id' => :'String',
95
+ :'direction' => :'String',
96
+ :'from' => :'ThreadEmailFrom',
97
+ :'to' => :'ThreadEmailFrom',
98
+ :'cc' => :'Array<String>',
99
+ :'subject' => :'String',
100
+ :'text' => :'String',
101
+ :'html' => :'String',
102
+ :'status' => :'String',
103
+ :'attachments' => :'Array<ThreadEmailAttachmentsInner>',
104
+ :'created_at' => :'Time'
105
+ }
106
+ end
107
+
108
+ # List of attributes with nullable: true
109
+ def self.openapi_nullable
110
+ Set.new([
111
+ :'subject',
112
+ :'text',
113
+ :'html',
114
+ ])
115
+ end
116
+
117
+ # Initializes the object
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ def initialize(attributes = {})
120
+ if (!attributes.is_a?(Hash))
121
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::ThreadEmail` initialize method"
122
+ end
123
+
124
+ # check to see if the attribute exists and convert string to symbol for hash key
125
+ acceptable_attribute_map = self.class.acceptable_attribute_map
126
+ attributes = attributes.each_with_object({}) { |(k, v), h|
127
+ if (!acceptable_attribute_map.key?(k.to_sym))
128
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::ThreadEmail`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
129
+ end
130
+ h[k.to_sym] = v
131
+ }
132
+
133
+ if attributes.key?(:'id')
134
+ self.id = attributes[:'id']
135
+ end
136
+
137
+ if attributes.key?(:'direction')
138
+ self.direction = attributes[:'direction']
139
+ end
140
+
141
+ if attributes.key?(:'from')
142
+ self.from = attributes[:'from']
143
+ end
144
+
145
+ if attributes.key?(:'to')
146
+ self.to = attributes[:'to']
147
+ end
148
+
149
+ if attributes.key?(:'cc')
150
+ if (value = attributes[:'cc']).is_a?(Array)
151
+ self.cc = value
152
+ end
153
+ end
154
+
155
+ if attributes.key?(:'subject')
156
+ self.subject = attributes[:'subject']
157
+ end
158
+
159
+ if attributes.key?(:'text')
160
+ self.text = attributes[:'text']
161
+ end
162
+
163
+ if attributes.key?(:'html')
164
+ self.html = attributes[:'html']
165
+ end
166
+
167
+ if attributes.key?(:'status')
168
+ self.status = attributes[:'status']
169
+ end
170
+
171
+ if attributes.key?(:'attachments')
172
+ if (value = attributes[:'attachments']).is_a?(Array)
173
+ self.attachments = value
174
+ end
175
+ end
176
+
177
+ if attributes.key?(:'created_at')
178
+ self.created_at = attributes[:'created_at']
179
+ end
180
+ end
181
+
182
+ # Show invalid properties with the reasons. Usually used together with valid?
183
+ # @return Array for valid properties with the reasons
184
+ def list_invalid_properties
185
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
186
+ invalid_properties = Array.new
187
+ invalid_properties
188
+ end
189
+
190
+ # Check to see if the all the properties in the model are valid
191
+ # @return true if the model is valid
192
+ def valid?
193
+ warn '[DEPRECATED] the `valid?` method is obsolete'
194
+ direction_validator = EnumAttributeValidator.new('String', ["inbound", "outbound"])
195
+ return false unless direction_validator.valid?(@direction)
196
+ true
197
+ end
198
+
199
+ # Custom attribute writer method checking allowed values (enum).
200
+ # @param [Object] direction Object to be assigned
201
+ def direction=(direction)
202
+ validator = EnumAttributeValidator.new('String', ["inbound", "outbound"])
203
+ unless validator.valid?(direction)
204
+ fail ArgumentError, "invalid value for \"direction\", must be one of #{validator.allowable_values}."
205
+ end
206
+ @direction = direction
207
+ end
208
+
209
+ # Checks equality by comparing each attribute.
210
+ # @param [Object] Object to be compared
211
+ def ==(o)
212
+ return true if self.equal?(o)
213
+ self.class == o.class &&
214
+ id == o.id &&
215
+ direction == o.direction &&
216
+ from == o.from &&
217
+ to == o.to &&
218
+ cc == o.cc &&
219
+ subject == o.subject &&
220
+ text == o.text &&
221
+ html == o.html &&
222
+ status == o.status &&
223
+ attachments == o.attachments &&
224
+ created_at == o.created_at
225
+ end
226
+
227
+ # @see the `==` method
228
+ # @param [Object] Object to be compared
229
+ def eql?(o)
230
+ self == o
231
+ end
232
+
233
+ # Calculates hash code according to all attributes.
234
+ # @return [Integer] Hash code
235
+ def hash
236
+ [id, direction, from, to, cc, subject, text, html, status, attachments, created_at].hash
237
+ end
238
+
239
+ # Builds the object from hash
240
+ # @param [Hash] attributes Model attributes in the form of hash
241
+ # @return [Object] Returns the model itself
242
+ def self.build_from_hash(attributes)
243
+ return nil unless attributes.is_a?(Hash)
244
+ attributes = attributes.transform_keys(&:to_sym)
245
+ transformed_hash = {}
246
+ openapi_types.each_pair do |key, type|
247
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
248
+ transformed_hash["#{key}"] = nil
249
+ elsif type =~ /\AArray<(.*)>/i
250
+ # check to ensure the input is an array given that the attribute
251
+ # is documented as an array but the input is not
252
+ if attributes[attribute_map[key]].is_a?(Array)
253
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
254
+ end
255
+ elsif !attributes[attribute_map[key]].nil?
256
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
257
+ end
258
+ end
259
+ new(transformed_hash)
260
+ end
261
+
262
+ # Deserializes the data based on type
263
+ # @param string type Data type
264
+ # @param string value Value to be deserialized
265
+ # @return [Object] Deserialized data
266
+ def self._deserialize(type, value)
267
+ case type.to_sym
268
+ when :Time
269
+ Time.parse(value)
270
+ when :Date
271
+ Date.parse(value)
272
+ when :String
273
+ value.to_s
274
+ when :Integer
275
+ value.to_i
276
+ when :Float
277
+ value.to_f
278
+ when :Boolean
279
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
280
+ true
281
+ else
282
+ false
283
+ end
284
+ when :Object
285
+ # generic object (usually a Hash), return directly
286
+ value
287
+ when /\AArray<(?<inner_type>.+)>\z/
288
+ inner_type = Regexp.last_match[:inner_type]
289
+ value.map { |v| _deserialize(inner_type, v) }
290
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
291
+ k_type = Regexp.last_match[:k_type]
292
+ v_type = Regexp.last_match[:v_type]
293
+ {}.tap do |hash|
294
+ value.each do |k, v|
295
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
296
+ end
297
+ end
298
+ else # model
299
+ # models (e.g. Pet) or oneOf
300
+ klass = Zyphr.const_get(type)
301
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
302
+ end
303
+ end
304
+
305
+ # Returns the string representation of the object
306
+ # @return [String] String presentation of the object
307
+ def to_s
308
+ to_hash.to_s
309
+ end
310
+
311
+ # to_body is an alias to to_hash (backward compatibility)
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_body
314
+ to_hash
315
+ end
316
+
317
+ # Returns the object in the form of hash
318
+ # @return [Hash] Returns the object in the form of hash
319
+ def to_hash
320
+ hash = {}
321
+ self.class.attribute_map.each_pair do |attr, param|
322
+ value = self.send(attr)
323
+ if value.nil?
324
+ is_nullable = self.class.openapi_nullable.include?(attr)
325
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
326
+ end
327
+
328
+ hash[param] = _to_hash(value)
329
+ end
330
+ hash
331
+ end
332
+
333
+ # Outputs non-array value in the form of hash
334
+ # For object, use to_hash. Otherwise, just return the value
335
+ # @param [Object] value Any valid value
336
+ # @return [Hash] Returns the value in the form of hash
337
+ def _to_hash(value)
338
+ if value.is_a?(Array)
339
+ value.compact.map { |v| _to_hash(v) }
340
+ elsif value.is_a?(Hash)
341
+ {}.tap do |hash|
342
+ value.each { |k, v| hash[k] = _to_hash(v) }
343
+ end
344
+ elsif value.respond_to? :to_hash
345
+ value.to_hash
346
+ else
347
+ value
348
+ end
349
+ end
350
+
351
+ end
352
+
353
+ end