zyphr 0.1.27 → 0.1.28

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/docs/AddDomain200Response.md +20 -0
  4. data/docs/AddDomain200ResponseMeta.md +20 -0
  5. data/docs/AddDomainRequest.md +18 -0
  6. data/docs/DeleteDomainResponse.md +20 -0
  7. data/docs/DeleteDomainResponseData.md +20 -0
  8. data/docs/DnsRecord.md +26 -0
  9. data/docs/DomainListResponse.md +20 -0
  10. data/docs/DomainListResponseMeta.md +24 -0
  11. data/docs/DomainResponse.md +38 -0
  12. data/docs/DomainsApi.md +436 -0
  13. data/docs/GetDomain200Response.md +20 -0
  14. data/docs/GetDomain200ResponseMeta.md +18 -0
  15. data/docs/VerificationStatusResponse.md +20 -0
  16. data/docs/VerificationStatusResponseData.md +32 -0
  17. data/docs/VerifyDomainResponse.md +20 -0
  18. data/docs/VerifyDomainResponseData.md +24 -0
  19. data/lib/zyphr/api/domains_api.rb +399 -0
  20. data/lib/zyphr/models/add_domain200_response.rb +229 -0
  21. data/lib/zyphr/models/add_domain200_response_meta.rb +229 -0
  22. data/lib/zyphr/models/add_domain_request.rb +238 -0
  23. data/lib/zyphr/models/delete_domain_response.rb +263 -0
  24. data/lib/zyphr/models/delete_domain_response_data.rb +263 -0
  25. data/lib/zyphr/models/dns_record.rb +373 -0
  26. data/lib/zyphr/models/domain_list_response.rb +265 -0
  27. data/lib/zyphr/models/domain_list_response_meta.rb +249 -0
  28. data/lib/zyphr/models/domain_response.rb +463 -0
  29. data/lib/zyphr/models/get_domain200_response.rb +229 -0
  30. data/lib/zyphr/models/get_domain200_response_meta.rb +220 -0
  31. data/lib/zyphr/models/verification_status_response.rb +263 -0
  32. data/lib/zyphr/models/verification_status_response_data.rb +415 -0
  33. data/lib/zyphr/models/verify_domain_response.rb +263 -0
  34. data/lib/zyphr/models/verify_domain_response_data.rb +339 -0
  35. data/lib/zyphr.rb +16 -0
  36. data/spec/api/domains_api_spec.rb +106 -0
  37. data/spec/models/add_domain200_response_meta_spec.rb +42 -0
  38. data/spec/models/add_domain200_response_spec.rb +42 -0
  39. data/spec/models/add_domain_request_spec.rb +36 -0
  40. data/spec/models/delete_domain_response_data_spec.rb +42 -0
  41. data/spec/models/delete_domain_response_spec.rb +42 -0
  42. data/spec/models/dns_record_spec.rb +68 -0
  43. data/spec/models/domain_list_response_meta_spec.rb +54 -0
  44. data/spec/models/domain_list_response_spec.rb +42 -0
  45. data/spec/models/domain_response_spec.rb +100 -0
  46. data/spec/models/get_domain200_response_meta_spec.rb +36 -0
  47. data/spec/models/get_domain200_response_spec.rb +42 -0
  48. data/spec/models/verification_status_response_data_spec.rb +82 -0
  49. data/spec/models/verification_status_response_spec.rb +42 -0
  50. data/spec/models/verify_domain_response_data_spec.rb +58 -0
  51. data/spec/models/verify_domain_response_spec.rb +42 -0
  52. data/zyphr.gemspec +1 -1
  53. metadata +66 -2
@@ -0,0 +1,399 @@
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 'cgi'
14
+
15
+ module Zyphr
16
+ class DomainsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Add a sending domain
23
+ # Register a new sending domain on the account. Returns the full set of DNS records that must be published before email can send from this domain. **Idempotent:** calling this with a domain already registered on the current project returns the existing domain (200) instead of erroring, so re-runs from IaC tooling are safe.
24
+ # @param add_domain_request [AddDomainRequest]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [AddDomain200Response]
27
+ def add_domain(add_domain_request, opts = {})
28
+ data, _status_code, _headers = add_domain_with_http_info(add_domain_request, opts)
29
+ data
30
+ end
31
+
32
+ # Add a sending domain
33
+ # Register a new sending domain on the account. Returns the full set of DNS records that must be published before email can send from this domain. **Idempotent:** calling this with a domain already registered on the current project returns the existing domain (200) instead of erroring, so re-runs from IaC tooling are safe.
34
+ # @param add_domain_request [AddDomainRequest]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(AddDomain200Response, Integer, Hash)>] AddDomain200Response data, response status code and response headers
37
+ def add_domain_with_http_info(add_domain_request, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: DomainsApi.add_domain ...'
40
+ end
41
+ # verify the required parameter 'add_domain_request' is set
42
+ if @api_client.config.client_side_validation && add_domain_request.nil?
43
+ fail ArgumentError, "Missing the required parameter 'add_domain_request' when calling DomainsApi.add_domain"
44
+ end
45
+ # resource path
46
+ local_var_path = '/v1/domains'
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
55
+ # HTTP header 'Content-Type'
56
+ content_type = @api_client.select_header_content_type(['application/json'])
57
+ if !content_type.nil?
58
+ header_params['Content-Type'] = content_type
59
+ end
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(add_domain_request)
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'AddDomain200Response'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"DomainsApi.add_domain",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: DomainsApi#add_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+
90
+ # Remove a sending domain
91
+ # Remove a sending domain from the project. The domain is also detached from any SES identity that was provisioned for it. Returns 409 if the domain is still referenced by other resources (templates, scheduled sends, etc.) — those must be removed first.
92
+ # @param id [String]
93
+ # @param [Hash] opts the optional parameters
94
+ # @return [DeleteDomainResponse]
95
+ def delete_domain(id, opts = {})
96
+ data, _status_code, _headers = delete_domain_with_http_info(id, opts)
97
+ data
98
+ end
99
+
100
+ # Remove a sending domain
101
+ # Remove a sending domain from the project. The domain is also detached from any SES identity that was provisioned for it. Returns 409 if the domain is still referenced by other resources (templates, scheduled sends, etc.) — those must be removed first.
102
+ # @param id [String]
103
+ # @param [Hash] opts the optional parameters
104
+ # @return [Array<(DeleteDomainResponse, Integer, Hash)>] DeleteDomainResponse data, response status code and response headers
105
+ def delete_domain_with_http_info(id, opts = {})
106
+ if @api_client.config.debugging
107
+ @api_client.config.logger.debug 'Calling API: DomainsApi.delete_domain ...'
108
+ end
109
+ # verify the required parameter 'id' is set
110
+ if @api_client.config.client_side_validation && id.nil?
111
+ fail ArgumentError, "Missing the required parameter 'id' when calling DomainsApi.delete_domain"
112
+ end
113
+ # resource path
114
+ local_var_path = '/v1/domains/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
115
+
116
+ # query parameters
117
+ query_params = opts[:query_params] || {}
118
+
119
+ # header parameters
120
+ header_params = opts[:header_params] || {}
121
+ # HTTP header 'Accept' (if needed)
122
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
123
+
124
+ # form parameters
125
+ form_params = opts[:form_params] || {}
126
+
127
+ # http body (model)
128
+ post_body = opts[:debug_body]
129
+
130
+ # return_type
131
+ return_type = opts[:debug_return_type] || 'DeleteDomainResponse'
132
+
133
+ # auth_names
134
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
135
+
136
+ new_options = opts.merge(
137
+ :operation => :"DomainsApi.delete_domain",
138
+ :header_params => header_params,
139
+ :query_params => query_params,
140
+ :form_params => form_params,
141
+ :body => post_body,
142
+ :auth_names => auth_names,
143
+ :return_type => return_type
144
+ )
145
+
146
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
147
+ if @api_client.config.debugging
148
+ @api_client.config.logger.debug "API called: DomainsApi#delete_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
149
+ end
150
+ return data, status_code, headers
151
+ end
152
+
153
+ # Get a sending domain
154
+ # Retrieve a single sending domain by ID, including DNS records and verification counters.
155
+ # @param id [String]
156
+ # @param [Hash] opts the optional parameters
157
+ # @return [GetDomain200Response]
158
+ def get_domain(id, opts = {})
159
+ data, _status_code, _headers = get_domain_with_http_info(id, opts)
160
+ data
161
+ end
162
+
163
+ # Get a sending domain
164
+ # Retrieve a single sending domain by ID, including DNS records and verification counters.
165
+ # @param id [String]
166
+ # @param [Hash] opts the optional parameters
167
+ # @return [Array<(GetDomain200Response, Integer, Hash)>] GetDomain200Response data, response status code and response headers
168
+ def get_domain_with_http_info(id, opts = {})
169
+ if @api_client.config.debugging
170
+ @api_client.config.logger.debug 'Calling API: DomainsApi.get_domain ...'
171
+ end
172
+ # verify the required parameter 'id' is set
173
+ if @api_client.config.client_side_validation && id.nil?
174
+ fail ArgumentError, "Missing the required parameter 'id' when calling DomainsApi.get_domain"
175
+ end
176
+ # resource path
177
+ local_var_path = '/v1/domains/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
178
+
179
+ # query parameters
180
+ query_params = opts[:query_params] || {}
181
+
182
+ # header parameters
183
+ header_params = opts[:header_params] || {}
184
+ # HTTP header 'Accept' (if needed)
185
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
186
+
187
+ # form parameters
188
+ form_params = opts[:form_params] || {}
189
+
190
+ # http body (model)
191
+ post_body = opts[:debug_body]
192
+
193
+ # return_type
194
+ return_type = opts[:debug_return_type] || 'GetDomain200Response'
195
+
196
+ # auth_names
197
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
198
+
199
+ new_options = opts.merge(
200
+ :operation => :"DomainsApi.get_domain",
201
+ :header_params => header_params,
202
+ :query_params => query_params,
203
+ :form_params => form_params,
204
+ :body => post_body,
205
+ :auth_names => auth_names,
206
+ :return_type => return_type
207
+ )
208
+
209
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
210
+ if @api_client.config.debugging
211
+ @api_client.config.logger.debug "API called: DomainsApi#get_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
212
+ end
213
+ return data, status_code, headers
214
+ end
215
+
216
+ # Get domain verification status
217
+ # Returns the current verification status with per-record `verified` flags and aggregate counters. Useful when polling for terminal status from an AI agent (the recommended pattern is to subscribe to the `domain.verified` webhook event instead — see sc-5444).
218
+ # @param id [String] Domain ID
219
+ # @param [Hash] opts the optional parameters
220
+ # @return [VerificationStatusResponse]
221
+ def get_domain_verification_status(id, opts = {})
222
+ data, _status_code, _headers = get_domain_verification_status_with_http_info(id, opts)
223
+ data
224
+ end
225
+
226
+ # Get domain verification status
227
+ # Returns the current verification status with per-record &#x60;verified&#x60; flags and aggregate counters. Useful when polling for terminal status from an AI agent (the recommended pattern is to subscribe to the &#x60;domain.verified&#x60; webhook event instead — see sc-5444).
228
+ # @param id [String] Domain ID
229
+ # @param [Hash] opts the optional parameters
230
+ # @return [Array<(VerificationStatusResponse, Integer, Hash)>] VerificationStatusResponse data, response status code and response headers
231
+ def get_domain_verification_status_with_http_info(id, opts = {})
232
+ if @api_client.config.debugging
233
+ @api_client.config.logger.debug 'Calling API: DomainsApi.get_domain_verification_status ...'
234
+ end
235
+ # verify the required parameter 'id' is set
236
+ if @api_client.config.client_side_validation && id.nil?
237
+ fail ArgumentError, "Missing the required parameter 'id' when calling DomainsApi.get_domain_verification_status"
238
+ end
239
+ # resource path
240
+ local_var_path = '/v1/domains/{id}/verification-status'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
241
+
242
+ # query parameters
243
+ query_params = opts[:query_params] || {}
244
+
245
+ # header parameters
246
+ header_params = opts[:header_params] || {}
247
+ # HTTP header 'Accept' (if needed)
248
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
249
+
250
+ # form parameters
251
+ form_params = opts[:form_params] || {}
252
+
253
+ # http body (model)
254
+ post_body = opts[:debug_body]
255
+
256
+ # return_type
257
+ return_type = opts[:debug_return_type] || 'VerificationStatusResponse'
258
+
259
+ # auth_names
260
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
261
+
262
+ new_options = opts.merge(
263
+ :operation => :"DomainsApi.get_domain_verification_status",
264
+ :header_params => header_params,
265
+ :query_params => query_params,
266
+ :form_params => form_params,
267
+ :body => post_body,
268
+ :auth_names => auth_names,
269
+ :return_type => return_type
270
+ )
271
+
272
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
273
+ if @api_client.config.debugging
274
+ @api_client.config.logger.debug "API called: DomainsApi#get_domain_verification_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
275
+ end
276
+ return data, status_code, headers
277
+ end
278
+
279
+ # List sending domains
280
+ # List sending domains on the current project, with verification status and DNS records.
281
+ # @param [Hash] opts the optional parameters
282
+ # @return [DomainListResponse]
283
+ def list_domains(opts = {})
284
+ data, _status_code, _headers = list_domains_with_http_info(opts)
285
+ data
286
+ end
287
+
288
+ # List sending domains
289
+ # List sending domains on the current project, with verification status and DNS records.
290
+ # @param [Hash] opts the optional parameters
291
+ # @return [Array<(DomainListResponse, Integer, Hash)>] DomainListResponse data, response status code and response headers
292
+ def list_domains_with_http_info(opts = {})
293
+ if @api_client.config.debugging
294
+ @api_client.config.logger.debug 'Calling API: DomainsApi.list_domains ...'
295
+ end
296
+ # resource path
297
+ local_var_path = '/v1/domains'
298
+
299
+ # query parameters
300
+ query_params = opts[:query_params] || {}
301
+
302
+ # header parameters
303
+ header_params = opts[:header_params] || {}
304
+ # HTTP header 'Accept' (if needed)
305
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
306
+
307
+ # form parameters
308
+ form_params = opts[:form_params] || {}
309
+
310
+ # http body (model)
311
+ post_body = opts[:debug_body]
312
+
313
+ # return_type
314
+ return_type = opts[:debug_return_type] || 'DomainListResponse'
315
+
316
+ # auth_names
317
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
318
+
319
+ new_options = opts.merge(
320
+ :operation => :"DomainsApi.list_domains",
321
+ :header_params => header_params,
322
+ :query_params => query_params,
323
+ :form_params => form_params,
324
+ :body => post_body,
325
+ :auth_names => auth_names,
326
+ :return_type => return_type
327
+ )
328
+
329
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
330
+ if @api_client.config.debugging
331
+ @api_client.config.logger.debug "API called: DomainsApi#list_domains\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
332
+ end
333
+ return data, status_code, headers
334
+ end
335
+
336
+ # Trigger domain verification
337
+ # Queue an asynchronous DNS verification check. Returns immediately with a `job_id`. Poll `GET /v1/domains/{id}/verification-status` (or the higher-level `GET /v1/domains/{id}`) for the result, or subscribe to the `domain.verified` webhook event when sc-5444 ships. Returns 409 if a verification is already in progress for this domain (within the last 2 minutes).
338
+ # @param id [String]
339
+ # @param [Hash] opts the optional parameters
340
+ # @return [VerifyDomainResponse]
341
+ def verify_domain(id, opts = {})
342
+ data, _status_code, _headers = verify_domain_with_http_info(id, opts)
343
+ data
344
+ end
345
+
346
+ # Trigger domain verification
347
+ # Queue an asynchronous DNS verification check. Returns immediately with a &#x60;job_id&#x60;. Poll &#x60;GET /v1/domains/{id}/verification-status&#x60; (or the higher-level &#x60;GET /v1/domains/{id}&#x60;) for the result, or subscribe to the &#x60;domain.verified&#x60; webhook event when sc-5444 ships. Returns 409 if a verification is already in progress for this domain (within the last 2 minutes).
348
+ # @param id [String]
349
+ # @param [Hash] opts the optional parameters
350
+ # @return [Array<(VerifyDomainResponse, Integer, Hash)>] VerifyDomainResponse data, response status code and response headers
351
+ def verify_domain_with_http_info(id, opts = {})
352
+ if @api_client.config.debugging
353
+ @api_client.config.logger.debug 'Calling API: DomainsApi.verify_domain ...'
354
+ end
355
+ # verify the required parameter 'id' is set
356
+ if @api_client.config.client_side_validation && id.nil?
357
+ fail ArgumentError, "Missing the required parameter 'id' when calling DomainsApi.verify_domain"
358
+ end
359
+ # resource path
360
+ local_var_path = '/v1/domains/{id}/verify'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
361
+
362
+ # query parameters
363
+ query_params = opts[:query_params] || {}
364
+
365
+ # header parameters
366
+ header_params = opts[:header_params] || {}
367
+ # HTTP header 'Accept' (if needed)
368
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
369
+
370
+ # form parameters
371
+ form_params = opts[:form_params] || {}
372
+
373
+ # http body (model)
374
+ post_body = opts[:debug_body]
375
+
376
+ # return_type
377
+ return_type = opts[:debug_return_type] || 'VerifyDomainResponse'
378
+
379
+ # auth_names
380
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
381
+
382
+ new_options = opts.merge(
383
+ :operation => :"DomainsApi.verify_domain",
384
+ :header_params => header_params,
385
+ :query_params => query_params,
386
+ :form_params => form_params,
387
+ :body => post_body,
388
+ :auth_names => auth_names,
389
+ :return_type => return_type
390
+ )
391
+
392
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
393
+ if @api_client.config.debugging
394
+ @api_client.config.logger.debug "API called: DomainsApi#verify_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
395
+ end
396
+ return data, status_code, headers
397
+ end
398
+ end
399
+ end
@@ -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 AddDomain200Response
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' => :'AddDomain200ResponseMeta'
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::AddDomain200Response` 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::AddDomain200Response`. 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