zyphr 0.1.31 → 0.1.32

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/docs/DeleteDomainResponse.md +20 -0
  4. data/docs/DeleteDomainResponseData.md +20 -0
  5. data/docs/DomainResponse.md +5 -1
  6. data/docs/DomainsApi.md +288 -0
  7. data/docs/GetDomain200Response.md +20 -0
  8. data/docs/GetDomain200ResponseMeta.md +18 -0
  9. data/docs/VerificationStatusResponse.md +20 -0
  10. data/docs/VerificationStatusResponseData.md +32 -0
  11. data/docs/VerifyDomainResponse.md +20 -0
  12. data/docs/VerifyDomainResponseData.md +24 -0
  13. data/lib/zyphr/api/domains_api.rb +252 -0
  14. data/lib/zyphr/models/delete_domain_response.rb +263 -0
  15. data/lib/zyphr/models/delete_domain_response_data.rb +263 -0
  16. data/lib/zyphr/models/domain_response.rb +46 -2
  17. data/lib/zyphr/models/get_domain200_response.rb +229 -0
  18. data/lib/zyphr/models/get_domain200_response_meta.rb +220 -0
  19. data/lib/zyphr/models/verification_status_response.rb +263 -0
  20. data/lib/zyphr/models/verification_status_response_data.rb +415 -0
  21. data/lib/zyphr/models/verify_domain_response.rb +263 -0
  22. data/lib/zyphr/models/verify_domain_response_data.rb +339 -0
  23. data/lib/zyphr.rb +8 -0
  24. data/spec/api/domains_api_spec.rb +48 -0
  25. data/spec/models/delete_domain_response_data_spec.rb +42 -0
  26. data/spec/models/delete_domain_response_spec.rb +42 -0
  27. data/spec/models/domain_response_spec.rb +20 -0
  28. data/spec/models/get_domain200_response_meta_spec.rb +36 -0
  29. data/spec/models/get_domain200_response_spec.rb +42 -0
  30. data/spec/models/verification_status_response_data_spec.rb +82 -0
  31. data/spec/models/verification_status_response_spec.rb +42 -0
  32. data/spec/models/verify_domain_response_data_spec.rb +58 -0
  33. data/spec/models/verify_domain_response_spec.rb +42 -0
  34. data/zyphr.gemspec +1 -1
  35. metadata +33 -1
@@ -0,0 +1,263 @@
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 DeleteDomainResponseData
18
+ attr_accessor :id
19
+
20
+ attr_accessor :deleted
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'id' => :'id',
26
+ :'deleted' => :'deleted'
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
+ :'id' => :'String',
44
+ :'deleted' => :'Boolean'
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::DeleteDomainResponseData` 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::DeleteDomainResponseData`. 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?(:'id')
71
+ self.id = attributes[:'id']
72
+ else
73
+ self.id = nil
74
+ end
75
+
76
+ if attributes.key?(:'deleted')
77
+ self.deleted = attributes[:'deleted']
78
+ else
79
+ self.deleted = nil
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 @id.nil?
89
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
90
+ end
91
+
92
+ if @deleted.nil?
93
+ invalid_properties.push('invalid value for "deleted", deleted cannot be nil.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
+ return false if @id.nil?
104
+ return false if @deleted.nil?
105
+ true
106
+ end
107
+
108
+ # Custom attribute writer method with validation
109
+ # @param [Object] id Value to be assigned
110
+ def id=(id)
111
+ if id.nil?
112
+ fail ArgumentError, 'id cannot be nil'
113
+ end
114
+
115
+ @id = id
116
+ end
117
+
118
+ # Custom attribute writer method with validation
119
+ # @param [Object] deleted Value to be assigned
120
+ def deleted=(deleted)
121
+ if deleted.nil?
122
+ fail ArgumentError, 'deleted cannot be nil'
123
+ end
124
+
125
+ @deleted = deleted
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ id == o.id &&
134
+ deleted == o.deleted
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [id, deleted].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ attributes = attributes.transform_keys(&:to_sym)
155
+ transformed_hash = {}
156
+ openapi_types.each_pair do |key, type|
157
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
158
+ transformed_hash["#{key}"] = nil
159
+ elsif type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[attribute_map[key]].is_a?(Array)
163
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
164
+ end
165
+ elsif !attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
167
+ end
168
+ end
169
+ new(transformed_hash)
170
+ end
171
+
172
+ # Deserializes the data based on type
173
+ # @param string type Data type
174
+ # @param string value Value to be deserialized
175
+ # @return [Object] Deserialized data
176
+ def self._deserialize(type, value)
177
+ case type.to_sym
178
+ when :Time
179
+ Time.parse(value)
180
+ when :Date
181
+ Date.parse(value)
182
+ when :String
183
+ value.to_s
184
+ when :Integer
185
+ value.to_i
186
+ when :Float
187
+ value.to_f
188
+ when :Boolean
189
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
+ true
191
+ else
192
+ false
193
+ end
194
+ when :Object
195
+ # generic object (usually a Hash), return directly
196
+ value
197
+ when /\AArray<(?<inner_type>.+)>\z/
198
+ inner_type = Regexp.last_match[:inner_type]
199
+ value.map { |v| _deserialize(inner_type, v) }
200
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
201
+ k_type = Regexp.last_match[:k_type]
202
+ v_type = Regexp.last_match[:v_type]
203
+ {}.tap do |hash|
204
+ value.each do |k, v|
205
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
206
+ end
207
+ end
208
+ else # model
209
+ # models (e.g. Pet) or oneOf
210
+ klass = Zyphr.const_get(type)
211
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
212
+ end
213
+ end
214
+
215
+ # Returns the string representation of the object
216
+ # @return [String] String presentation of the object
217
+ def to_s
218
+ to_hash.to_s
219
+ end
220
+
221
+ # to_body is an alias to to_hash (backward compatibility)
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_body
224
+ to_hash
225
+ end
226
+
227
+ # Returns the object in the form of hash
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_hash
230
+ hash = {}
231
+ self.class.attribute_map.each_pair do |attr, param|
232
+ value = self.send(attr)
233
+ if value.nil?
234
+ is_nullable = self.class.openapi_nullable.include?(attr)
235
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
236
+ end
237
+
238
+ hash[param] = _to_hash(value)
239
+ end
240
+ hash
241
+ end
242
+
243
+ # Outputs non-array value in the form of hash
244
+ # For object, use to_hash. Otherwise, just return the value
245
+ # @param [Object] value Any valid value
246
+ # @return [Hash] Returns the value in the form of hash
247
+ def _to_hash(value)
248
+ if value.is_a?(Array)
249
+ value.compact.map { |v| _to_hash(v) }
250
+ elsif value.is_a?(Hash)
251
+ {}.tap do |hash|
252
+ value.each { |k, v| hash[k] = _to_hash(v) }
253
+ end
254
+ elsif value.respond_to? :to_hash
255
+ value.to_hash
256
+ else
257
+ value
258
+ end
259
+ end
260
+
261
+ end
262
+
263
+ end
@@ -33,7 +33,13 @@ module Zyphr
33
33
  # Token used for the verification TXT record (also visible in `dns_records[]`)
34
34
  attr_accessor :verification_token
35
35
 
36
- # Timestamp when verification first succeeded
36
+ # AWS SES identity-verification sub-status. Surfaced so callers can see WHY top-level `status` is still `pending` when all DNS records report `verified: true` — typically because SES DKIM propagation hasn't completed yet (can take a few minutes after DNS records land). Top-level `status` only flips to `verified` once both this and `ses_dkim_status` are `success`.
37
+ attr_accessor :ses_identity_status
38
+
39
+ # AWS SES DKIM verification sub-status. See `ses_identity_status`.
40
+ attr_accessor :ses_dkim_status
41
+
42
+ # Timestamp when verification first succeeded. Cleared to null if status later reverts away from `verified` (e.g. DNS records observed but SES DKIM not yet propagated).
37
43
  attr_accessor :verified_at
38
44
 
39
45
  # Timestamp of the most recent verification attempt
@@ -75,6 +81,8 @@ module Zyphr
75
81
  :'records_verified' => :'records_verified',
76
82
  :'records_total' => :'records_total',
77
83
  :'verification_token' => :'verification_token',
84
+ :'ses_identity_status' => :'ses_identity_status',
85
+ :'ses_dkim_status' => :'ses_dkim_status',
78
86
  :'verified_at' => :'verified_at',
79
87
  :'last_checked_at' => :'last_checked_at',
80
88
  :'created_at' => :'created_at',
@@ -102,6 +110,8 @@ module Zyphr
102
110
  :'records_verified' => :'Integer',
103
111
  :'records_total' => :'Integer',
104
112
  :'verification_token' => :'String',
113
+ :'ses_identity_status' => :'String',
114
+ :'ses_dkim_status' => :'String',
105
115
  :'verified_at' => :'Time',
106
116
  :'last_checked_at' => :'Time',
107
117
  :'created_at' => :'Time',
@@ -175,6 +185,14 @@ module Zyphr
175
185
  self.verification_token = attributes[:'verification_token']
176
186
  end
177
187
 
188
+ if attributes.key?(:'ses_identity_status')
189
+ self.ses_identity_status = attributes[:'ses_identity_status']
190
+ end
191
+
192
+ if attributes.key?(:'ses_dkim_status')
193
+ self.ses_dkim_status = attributes[:'ses_dkim_status']
194
+ end
195
+
178
196
  if attributes.key?(:'verified_at')
179
197
  self.verified_at = attributes[:'verified_at']
180
198
  end
@@ -242,6 +260,10 @@ module Zyphr
242
260
  return false if @dns_records.nil?
243
261
  return false if @records_verified.nil?
244
262
  return false if @records_total.nil?
263
+ ses_identity_status_validator = EnumAttributeValidator.new('String', ["pending", "success", "failed", "temporary_failure", "not_started"])
264
+ return false unless ses_identity_status_validator.valid?(@ses_identity_status)
265
+ ses_dkim_status_validator = EnumAttributeValidator.new('String', ["pending", "success", "failed", "temporary_failure", "not_started"])
266
+ return false unless ses_dkim_status_validator.valid?(@ses_dkim_status)
245
267
  return false if @created_at.nil?
246
268
  true
247
269
  end
@@ -306,6 +328,26 @@ module Zyphr
306
328
  @records_total = records_total
307
329
  end
308
330
 
331
+ # Custom attribute writer method checking allowed values (enum).
332
+ # @param [Object] ses_identity_status Object to be assigned
333
+ def ses_identity_status=(ses_identity_status)
334
+ validator = EnumAttributeValidator.new('String', ["pending", "success", "failed", "temporary_failure", "not_started"])
335
+ unless validator.valid?(ses_identity_status)
336
+ fail ArgumentError, "invalid value for \"ses_identity_status\", must be one of #{validator.allowable_values}."
337
+ end
338
+ @ses_identity_status = ses_identity_status
339
+ end
340
+
341
+ # Custom attribute writer method checking allowed values (enum).
342
+ # @param [Object] ses_dkim_status Object to be assigned
343
+ def ses_dkim_status=(ses_dkim_status)
344
+ validator = EnumAttributeValidator.new('String', ["pending", "success", "failed", "temporary_failure", "not_started"])
345
+ unless validator.valid?(ses_dkim_status)
346
+ fail ArgumentError, "invalid value for \"ses_dkim_status\", must be one of #{validator.allowable_values}."
347
+ end
348
+ @ses_dkim_status = ses_dkim_status
349
+ end
350
+
309
351
  # Custom attribute writer method with validation
310
352
  # @param [Object] created_at Value to be assigned
311
353
  def created_at=(created_at)
@@ -328,6 +370,8 @@ module Zyphr
328
370
  records_verified == o.records_verified &&
329
371
  records_total == o.records_total &&
330
372
  verification_token == o.verification_token &&
373
+ ses_identity_status == o.ses_identity_status &&
374
+ ses_dkim_status == o.ses_dkim_status &&
331
375
  verified_at == o.verified_at &&
332
376
  last_checked_at == o.last_checked_at &&
333
377
  created_at == o.created_at &&
@@ -343,7 +387,7 @@ module Zyphr
343
387
  # Calculates hash code according to all attributes.
344
388
  # @return [Integer] Hash code
345
389
  def hash
346
- [id, domain, status, dns_records, records_verified, records_total, verification_token, verified_at, last_checked_at, created_at, updated_at].hash
390
+ [id, domain, status, dns_records, records_verified, records_total, verification_token, ses_identity_status, ses_dkim_status, verified_at, last_checked_at, created_at, updated_at].hash
347
391
  end
348
392
 
349
393
  # Builds the object from hash
@@ -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 GetDomain200Response
18
+ attr_accessor :data
19
+
20
+ attr_accessor :meta
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'data' => :'data',
26
+ :'meta' => :'meta'
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
+ :'data' => :'DomainResponse',
44
+ :'meta' => :'GetDomain200ResponseMeta'
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::GetDomain200Response` 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::GetDomain200Response`. 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?(:'data')
71
+ self.data = attributes[:'data']
72
+ end
73
+
74
+ if attributes.key?(:'meta')
75
+ self.meta = attributes[:'meta']
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
+ data == o.data &&
100
+ meta == o.meta
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
+ [data, meta].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