zyphr 0.1.74 → 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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +49 -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 +1855 -152
  11. data/docs/Inbox.md +3 -1
  12. data/docs/InboxLabel.md +26 -0
  13. data/docs/InboxLabelListResponse.md +20 -0
  14. data/docs/InboxLabelResponse.md +20 -0
  15. data/docs/InboxListResponse.md +1 -1
  16. data/docs/InboxListResponseMeta.md +22 -0
  17. data/docs/{ReplyToInboundEmailRequest.md → ReplyEmailRequest.md} +3 -3
  18. data/docs/Thread.md +40 -0
  19. data/docs/ThreadEmail.md +38 -0
  20. data/docs/ThreadEmailAttachmentsInner.md +24 -0
  21. data/docs/ThreadEmailFrom.md +20 -0
  22. data/docs/ThreadEmailListResponse.md +20 -0
  23. data/docs/ThreadEmailResponse.md +20 -0
  24. data/docs/ThreadFolder.md +15 -0
  25. data/docs/ThreadLabelsInner.md +22 -0
  26. data/docs/ThreadLabelsRequest.md +18 -0
  27. data/docs/ThreadListResponse.md +20 -0
  28. data/docs/ThreadListResponseMeta.md +20 -0
  29. data/docs/ThreadResponse.md +20 -0
  30. data/docs/UpdateInboxLabelRequest.md +20 -0
  31. data/docs/UpdateThreadRequest.md +22 -0
  32. data/lib/zyphr/api/inbound_email_api.rb +1774 -168
  33. data/lib/zyphr/models/create_inbox_label_request.rb +272 -0
  34. data/lib/zyphr/models/draft.rb +375 -0
  35. data/lib/zyphr/models/draft_address.rb +249 -0
  36. data/lib/zyphr/models/draft_list_response.rb +231 -0
  37. data/lib/zyphr/models/draft_request.rb +299 -0
  38. data/lib/zyphr/models/draft_response.rb +229 -0
  39. data/lib/zyphr/models/forward_email_request.rb +393 -0
  40. data/lib/zyphr/models/inbox.rb +14 -4
  41. data/lib/zyphr/models/inbox_label.rb +258 -0
  42. data/lib/zyphr/models/inbox_label_list_response.rb +231 -0
  43. data/lib/zyphr/models/inbox_label_response.rb +229 -0
  44. data/lib/zyphr/models/inbox_list_response.rb +1 -1
  45. data/lib/zyphr/models/inbox_list_response_meta.rb +246 -0
  46. data/lib/zyphr/models/{reply_to_inbound_email_request.rb → reply_email_request.rb} +4 -3
  47. data/lib/zyphr/models/thread.rb +352 -0
  48. data/lib/zyphr/models/thread_email.rb +353 -0
  49. data/lib/zyphr/models/thread_email_attachments_inner.rb +248 -0
  50. data/lib/zyphr/models/thread_email_from.rb +230 -0
  51. data/lib/zyphr/models/thread_email_list_response.rb +231 -0
  52. data/lib/zyphr/models/thread_email_response.rb +229 -0
  53. data/lib/zyphr/models/thread_folder.rb +43 -0
  54. data/lib/zyphr/models/thread_labels_inner.rb +239 -0
  55. data/lib/zyphr/models/thread_labels_request.rb +248 -0
  56. data/lib/zyphr/models/thread_list_response.rb +231 -0
  57. data/lib/zyphr/models/thread_list_response_meta.rb +237 -0
  58. data/lib/zyphr/models/thread_response.rb +229 -0
  59. data/lib/zyphr/models/update_inbox_label_request.rb +264 -0
  60. data/lib/zyphr/models/update_thread_request.rb +262 -0
  61. data/lib/zyphr.rb +26 -1
  62. data/spec/api/inbound_email_api_spec.rb +294 -1
  63. data/spec/models/create_inbox_label_request_spec.rb +42 -0
  64. data/spec/models/draft_address_spec.rb +42 -0
  65. data/spec/models/draft_list_response_spec.rb +42 -0
  66. data/spec/models/draft_request_spec.rb +72 -0
  67. data/spec/models/draft_response_spec.rb +42 -0
  68. data/spec/models/draft_spec.rb +90 -0
  69. data/spec/models/forward_email_request_spec.rb +88 -0
  70. data/spec/models/inbox_label_list_response_spec.rb +42 -0
  71. data/spec/models/inbox_label_response_spec.rb +42 -0
  72. data/spec/models/inbox_label_spec.rb +60 -0
  73. data/spec/models/inbox_list_response_meta_spec.rb +48 -0
  74. data/spec/models/inbox_spec.rb +6 -0
  75. data/spec/models/{reply_to_inbound_email_request_spec.rb → reply_email_request_spec.rb} +6 -6
  76. data/spec/models/thread_email_attachments_inner_spec.rb +54 -0
  77. data/spec/models/thread_email_from_spec.rb +42 -0
  78. data/spec/models/thread_email_list_response_spec.rb +42 -0
  79. data/spec/models/thread_email_response_spec.rb +42 -0
  80. data/spec/models/thread_email_spec.rb +100 -0
  81. data/spec/models/thread_folder_spec.rb +30 -0
  82. data/spec/models/thread_labels_inner_spec.rb +48 -0
  83. data/spec/models/thread_labels_request_spec.rb +36 -0
  84. data/spec/models/thread_list_response_meta_spec.rb +42 -0
  85. data/spec/models/thread_list_response_spec.rb +42 -0
  86. data/spec/models/thread_response_spec.rb +42 -0
  87. data/spec/models/thread_spec.rb +102 -0
  88. data/spec/models/update_inbox_label_request_spec.rb +42 -0
  89. data/spec/models/update_thread_request_spec.rb +48 -0
  90. data/zyphr.gemspec +1 -1
  91. metadata +106 -6
@@ -0,0 +1,272 @@
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 CreateInboxLabelRequest
18
+ # Unique in the project, ignoring case
19
+ attr_accessor :name
20
+
21
+ attr_accessor :color
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'name' => :'name',
27
+ :'color' => :'color'
28
+ }
29
+ end
30
+
31
+ # Returns attribute mapping this model knows about
32
+ def self.acceptable_attribute_map
33
+ attribute_map
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ acceptable_attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'name' => :'String',
45
+ :'color' => :'String'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ :'color'
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::CreateInboxLabelRequest` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ acceptable_attribute_map = self.class.acceptable_attribute_map
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!acceptable_attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::CreateInboxLabelRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'name')
73
+ self.name = attributes[:'name']
74
+ else
75
+ self.name = nil
76
+ end
77
+
78
+ if attributes.key?(:'color')
79
+ self.color = attributes[:'color']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
87
+ invalid_properties = Array.new
88
+ if @name.nil?
89
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
90
+ end
91
+
92
+ if @name.to_s.length > 64
93
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 64.')
94
+ end
95
+
96
+ if !@color.nil? && @color.to_s.length > 32
97
+ invalid_properties.push('invalid value for "color", the character length must be smaller than or equal to 32.')
98
+ end
99
+
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ warn '[DEPRECATED] the `valid?` method is obsolete'
107
+ return false if @name.nil?
108
+ return false if @name.to_s.length > 64
109
+ return false if !@color.nil? && @color.to_s.length > 32
110
+ true
111
+ end
112
+
113
+ # Custom attribute writer method with validation
114
+ # @param [Object] name Value to be assigned
115
+ def name=(name)
116
+ if name.nil?
117
+ fail ArgumentError, 'name cannot be nil'
118
+ end
119
+
120
+ if name.to_s.length > 64
121
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 64.'
122
+ end
123
+
124
+ @name = name
125
+ end
126
+
127
+ # Custom attribute writer method with validation
128
+ # @param [Object] color Value to be assigned
129
+ def color=(color)
130
+ if !color.nil? && color.to_s.length > 32
131
+ fail ArgumentError, 'invalid value for "color", the character length must be smaller than or equal to 32.'
132
+ end
133
+
134
+ @color = color
135
+ end
136
+
137
+ # Checks equality by comparing each attribute.
138
+ # @param [Object] Object to be compared
139
+ def ==(o)
140
+ return true if self.equal?(o)
141
+ self.class == o.class &&
142
+ name == o.name &&
143
+ color == o.color
144
+ end
145
+
146
+ # @see the `==` method
147
+ # @param [Object] Object to be compared
148
+ def eql?(o)
149
+ self == o
150
+ end
151
+
152
+ # Calculates hash code according to all attributes.
153
+ # @return [Integer] Hash code
154
+ def hash
155
+ [name, color].hash
156
+ end
157
+
158
+ # Builds the object from hash
159
+ # @param [Hash] attributes Model attributes in the form of hash
160
+ # @return [Object] Returns the model itself
161
+ def self.build_from_hash(attributes)
162
+ return nil unless attributes.is_a?(Hash)
163
+ attributes = attributes.transform_keys(&:to_sym)
164
+ transformed_hash = {}
165
+ openapi_types.each_pair do |key, type|
166
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
167
+ transformed_hash["#{key}"] = nil
168
+ elsif type =~ /\AArray<(.*)>/i
169
+ # check to ensure the input is an array given that the attribute
170
+ # is documented as an array but the input is not
171
+ if attributes[attribute_map[key]].is_a?(Array)
172
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
173
+ end
174
+ elsif !attributes[attribute_map[key]].nil?
175
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
176
+ end
177
+ end
178
+ new(transformed_hash)
179
+ end
180
+
181
+ # Deserializes the data based on type
182
+ # @param string type Data type
183
+ # @param string value Value to be deserialized
184
+ # @return [Object] Deserialized data
185
+ def self._deserialize(type, value)
186
+ case type.to_sym
187
+ when :Time
188
+ Time.parse(value)
189
+ when :Date
190
+ Date.parse(value)
191
+ when :String
192
+ value.to_s
193
+ when :Integer
194
+ value.to_i
195
+ when :Float
196
+ value.to_f
197
+ when :Boolean
198
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
199
+ true
200
+ else
201
+ false
202
+ end
203
+ when :Object
204
+ # generic object (usually a Hash), return directly
205
+ value
206
+ when /\AArray<(?<inner_type>.+)>\z/
207
+ inner_type = Regexp.last_match[:inner_type]
208
+ value.map { |v| _deserialize(inner_type, v) }
209
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
210
+ k_type = Regexp.last_match[:k_type]
211
+ v_type = Regexp.last_match[:v_type]
212
+ {}.tap do |hash|
213
+ value.each do |k, v|
214
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
215
+ end
216
+ end
217
+ else # model
218
+ # models (e.g. Pet) or oneOf
219
+ klass = Zyphr.const_get(type)
220
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
221
+ end
222
+ end
223
+
224
+ # Returns the string representation of the object
225
+ # @return [String] String presentation of the object
226
+ def to_s
227
+ to_hash.to_s
228
+ end
229
+
230
+ # to_body is an alias to to_hash (backward compatibility)
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_body
233
+ to_hash
234
+ end
235
+
236
+ # Returns the object in the form of hash
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_hash
239
+ hash = {}
240
+ self.class.attribute_map.each_pair do |attr, param|
241
+ value = self.send(attr)
242
+ if value.nil?
243
+ is_nullable = self.class.openapi_nullable.include?(attr)
244
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
245
+ end
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+
270
+ end
271
+
272
+ end
@@ -0,0 +1,375 @@
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
+ # An unsent email. A draft with a `thread_id` is a reply to that thread.
18
+ class Draft
19
+ attr_accessor :id
20
+
21
+ attr_accessor :thread_id
22
+
23
+ attr_accessor :from
24
+
25
+ # Null on a reply draft; Zyphr sets it from the thread when sent.
26
+ attr_accessor :to
27
+
28
+ attr_accessor :reply_to
29
+
30
+ attr_accessor :subject
31
+
32
+ attr_accessor :text
33
+
34
+ attr_accessor :html
35
+
36
+ attr_accessor :created_at
37
+
38
+ attr_accessor :updated_at
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'id' => :'id',
44
+ :'thread_id' => :'thread_id',
45
+ :'from' => :'from',
46
+ :'to' => :'to',
47
+ :'reply_to' => :'reply_to',
48
+ :'subject' => :'subject',
49
+ :'text' => :'text',
50
+ :'html' => :'html',
51
+ :'created_at' => :'created_at',
52
+ :'updated_at' => :'updated_at'
53
+ }
54
+ end
55
+
56
+ # Returns attribute mapping this model knows about
57
+ def self.acceptable_attribute_map
58
+ attribute_map
59
+ end
60
+
61
+ # Returns all the JSON keys this model knows about
62
+ def self.acceptable_attributes
63
+ acceptable_attribute_map.values
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'id' => :'String',
70
+ :'thread_id' => :'String',
71
+ :'from' => :'DraftAddress',
72
+ :'to' => :'DraftAddress',
73
+ :'reply_to' => :'String',
74
+ :'subject' => :'String',
75
+ :'text' => :'String',
76
+ :'html' => :'String',
77
+ :'created_at' => :'Time',
78
+ :'updated_at' => :'Time'
79
+ }
80
+ end
81
+
82
+ # List of attributes with nullable: true
83
+ def self.openapi_nullable
84
+ Set.new([
85
+ :'thread_id',
86
+ :'from',
87
+ :'to',
88
+ :'reply_to',
89
+ :'subject',
90
+ :'text',
91
+ :'html',
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::Draft` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ acceptable_attribute_map = self.class.acceptable_attribute_map
104
+ attributes = attributes.each_with_object({}) { |(k, v), h|
105
+ if (!acceptable_attribute_map.key?(k.to_sym))
106
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::Draft`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
107
+ end
108
+ h[k.to_sym] = v
109
+ }
110
+
111
+ if attributes.key?(:'id')
112
+ self.id = attributes[:'id']
113
+ else
114
+ self.id = nil
115
+ end
116
+
117
+ if attributes.key?(:'thread_id')
118
+ self.thread_id = attributes[:'thread_id']
119
+ else
120
+ self.thread_id = nil
121
+ end
122
+
123
+ if attributes.key?(:'from')
124
+ self.from = attributes[:'from']
125
+ else
126
+ self.from = nil
127
+ end
128
+
129
+ if attributes.key?(:'to')
130
+ self.to = attributes[:'to']
131
+ else
132
+ self.to = nil
133
+ end
134
+
135
+ if attributes.key?(:'reply_to')
136
+ self.reply_to = attributes[:'reply_to']
137
+ else
138
+ self.reply_to = nil
139
+ end
140
+
141
+ if attributes.key?(:'subject')
142
+ self.subject = attributes[:'subject']
143
+ else
144
+ self.subject = nil
145
+ end
146
+
147
+ if attributes.key?(:'text')
148
+ self.text = attributes[:'text']
149
+ else
150
+ self.text = nil
151
+ end
152
+
153
+ if attributes.key?(:'html')
154
+ self.html = attributes[:'html']
155
+ else
156
+ self.html = nil
157
+ end
158
+
159
+ if attributes.key?(:'created_at')
160
+ self.created_at = attributes[:'created_at']
161
+ else
162
+ self.created_at = nil
163
+ end
164
+
165
+ if attributes.key?(:'updated_at')
166
+ self.updated_at = attributes[:'updated_at']
167
+ else
168
+ self.updated_at = nil
169
+ end
170
+ end
171
+
172
+ # Show invalid properties with the reasons. Usually used together with valid?
173
+ # @return Array for valid properties with the reasons
174
+ def list_invalid_properties
175
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
176
+ invalid_properties = Array.new
177
+ if @id.nil?
178
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
179
+ end
180
+
181
+ if @created_at.nil?
182
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
183
+ end
184
+
185
+ if @updated_at.nil?
186
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
187
+ end
188
+
189
+ invalid_properties
190
+ end
191
+
192
+ # Check to see if the all the properties in the model are valid
193
+ # @return true if the model is valid
194
+ def valid?
195
+ warn '[DEPRECATED] the `valid?` method is obsolete'
196
+ return false if @id.nil?
197
+ return false if @created_at.nil?
198
+ return false if @updated_at.nil?
199
+ true
200
+ end
201
+
202
+ # Custom attribute writer method with validation
203
+ # @param [Object] id Value to be assigned
204
+ def id=(id)
205
+ if id.nil?
206
+ fail ArgumentError, 'id cannot be nil'
207
+ end
208
+
209
+ @id = id
210
+ end
211
+
212
+ # Custom attribute writer method with validation
213
+ # @param [Object] created_at Value to be assigned
214
+ def created_at=(created_at)
215
+ if created_at.nil?
216
+ fail ArgumentError, 'created_at cannot be nil'
217
+ end
218
+
219
+ @created_at = created_at
220
+ end
221
+
222
+ # Custom attribute writer method with validation
223
+ # @param [Object] updated_at Value to be assigned
224
+ def updated_at=(updated_at)
225
+ if updated_at.nil?
226
+ fail ArgumentError, 'updated_at cannot be nil'
227
+ end
228
+
229
+ @updated_at = updated_at
230
+ end
231
+
232
+ # Checks equality by comparing each attribute.
233
+ # @param [Object] Object to be compared
234
+ def ==(o)
235
+ return true if self.equal?(o)
236
+ self.class == o.class &&
237
+ id == o.id &&
238
+ thread_id == o.thread_id &&
239
+ from == o.from &&
240
+ to == o.to &&
241
+ reply_to == o.reply_to &&
242
+ subject == o.subject &&
243
+ text == o.text &&
244
+ html == o.html &&
245
+ created_at == o.created_at &&
246
+ updated_at == o.updated_at
247
+ end
248
+
249
+ # @see the `==` method
250
+ # @param [Object] Object to be compared
251
+ def eql?(o)
252
+ self == o
253
+ end
254
+
255
+ # Calculates hash code according to all attributes.
256
+ # @return [Integer] Hash code
257
+ def hash
258
+ [id, thread_id, from, to, reply_to, subject, text, html, created_at, updated_at].hash
259
+ end
260
+
261
+ # Builds the object from hash
262
+ # @param [Hash] attributes Model attributes in the form of hash
263
+ # @return [Object] Returns the model itself
264
+ def self.build_from_hash(attributes)
265
+ return nil unless attributes.is_a?(Hash)
266
+ attributes = attributes.transform_keys(&:to_sym)
267
+ transformed_hash = {}
268
+ openapi_types.each_pair do |key, type|
269
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
270
+ transformed_hash["#{key}"] = nil
271
+ elsif type =~ /\AArray<(.*)>/i
272
+ # check to ensure the input is an array given that the attribute
273
+ # is documented as an array but the input is not
274
+ if attributes[attribute_map[key]].is_a?(Array)
275
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
276
+ end
277
+ elsif !attributes[attribute_map[key]].nil?
278
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
279
+ end
280
+ end
281
+ new(transformed_hash)
282
+ end
283
+
284
+ # Deserializes the data based on type
285
+ # @param string type Data type
286
+ # @param string value Value to be deserialized
287
+ # @return [Object] Deserialized data
288
+ def self._deserialize(type, value)
289
+ case type.to_sym
290
+ when :Time
291
+ Time.parse(value)
292
+ when :Date
293
+ Date.parse(value)
294
+ when :String
295
+ value.to_s
296
+ when :Integer
297
+ value.to_i
298
+ when :Float
299
+ value.to_f
300
+ when :Boolean
301
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
302
+ true
303
+ else
304
+ false
305
+ end
306
+ when :Object
307
+ # generic object (usually a Hash), return directly
308
+ value
309
+ when /\AArray<(?<inner_type>.+)>\z/
310
+ inner_type = Regexp.last_match[:inner_type]
311
+ value.map { |v| _deserialize(inner_type, v) }
312
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
313
+ k_type = Regexp.last_match[:k_type]
314
+ v_type = Regexp.last_match[:v_type]
315
+ {}.tap do |hash|
316
+ value.each do |k, v|
317
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
318
+ end
319
+ end
320
+ else # model
321
+ # models (e.g. Pet) or oneOf
322
+ klass = Zyphr.const_get(type)
323
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
324
+ end
325
+ end
326
+
327
+ # Returns the string representation of the object
328
+ # @return [String] String presentation of the object
329
+ def to_s
330
+ to_hash.to_s
331
+ end
332
+
333
+ # to_body is an alias to to_hash (backward compatibility)
334
+ # @return [Hash] Returns the object in the form of hash
335
+ def to_body
336
+ to_hash
337
+ end
338
+
339
+ # Returns the object in the form of hash
340
+ # @return [Hash] Returns the object in the form of hash
341
+ def to_hash
342
+ hash = {}
343
+ self.class.attribute_map.each_pair do |attr, param|
344
+ value = self.send(attr)
345
+ if value.nil?
346
+ is_nullable = self.class.openapi_nullable.include?(attr)
347
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
348
+ end
349
+
350
+ hash[param] = _to_hash(value)
351
+ end
352
+ hash
353
+ end
354
+
355
+ # Outputs non-array value in the form of hash
356
+ # For object, use to_hash. Otherwise, just return the value
357
+ # @param [Object] value Any valid value
358
+ # @return [Hash] Returns the value in the form of hash
359
+ def _to_hash(value)
360
+ if value.is_a?(Array)
361
+ value.compact.map { |v| _to_hash(v) }
362
+ elsif value.is_a?(Hash)
363
+ {}.tap do |hash|
364
+ value.each { |k, v| hash[k] = _to_hash(v) }
365
+ end
366
+ elsif value.respond_to? :to_hash
367
+ value.to_hash
368
+ else
369
+ value
370
+ end
371
+ end
372
+
373
+ end
374
+
375
+ end