zyphr 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -6
  3. data/docs/AuthEmailTemplate.md +42 -0
  4. data/docs/AuthEmailTemplateDefault.md +26 -0
  5. data/docs/AuthEmailTemplateDefaultResponse.md +20 -0
  6. data/docs/AuthEmailTemplateDeleteResponse.md +20 -0
  7. data/docs/{SuccessResultData.md → AuthEmailTemplateDeleteResponseData.md} +2 -2
  8. data/docs/AuthEmailTemplateListResponse.md +20 -0
  9. data/docs/AuthEmailTemplatePreviewDraft.md +28 -0
  10. data/docs/AuthEmailTemplatePreviewRequest.md +20 -0
  11. data/docs/AuthEmailTemplatePreviewResponse.md +20 -0
  12. data/docs/AuthEmailTemplatePreviewResult.md +26 -0
  13. data/docs/AuthEmailTemplateResponse.md +20 -0
  14. data/docs/AuthEmailTemplateTestRequest.md +20 -0
  15. data/docs/AuthEmailTemplateTestResponse.md +20 -0
  16. data/docs/AuthEmailTemplateTestResult.md +20 -0
  17. data/docs/AuthEmailTemplateVersion.md +38 -0
  18. data/docs/AuthEmailTemplateVersionsResponse.md +20 -0
  19. data/docs/AuthEmailTemplatesApi.md +782 -0
  20. data/docs/AuthEmailType.md +15 -0
  21. data/docs/BulkUpsertAuthEmailTemplatesRequest.md +22 -0
  22. data/docs/BulkUpsertAuthEmailTemplatesResponse.md +20 -0
  23. data/docs/ResubscribeResponse.md +1 -1
  24. data/docs/SendSlackMessageRequest.md +40 -0
  25. data/docs/SendSlackMessageResponse.md +20 -0
  26. data/docs/SendSlackMessageResult.md +28 -0
  27. data/docs/SlackApi.md +233 -0
  28. data/docs/SlackMessage.md +50 -0
  29. data/docs/SlackMessageListResponse.md +20 -0
  30. data/docs/SlackMessageListResponseMeta.md +24 -0
  31. data/docs/SlackMessageResponse.md +20 -0
  32. data/docs/SlackMessageStatus.md +15 -0
  33. data/docs/SlackMessageSummary.md +38 -0
  34. data/docs/SuccessResult.md +1 -1
  35. data/docs/UpsertAuthEmailTemplateRequest.md +34 -0
  36. data/lib/zyphr/api/auth_email_templates_api.rb +688 -0
  37. data/lib/zyphr/api/slack_api.rb +233 -0
  38. data/lib/zyphr/models/auth_email_template.rb +372 -0
  39. data/lib/zyphr/models/auth_email_template_default.rb +281 -0
  40. data/lib/zyphr/models/auth_email_template_default_response.rb +229 -0
  41. data/lib/zyphr/models/auth_email_template_delete_response.rb +229 -0
  42. data/lib/zyphr/models/{success_result_data.rb → auth_email_template_delete_response_data.rb} +3 -3
  43. data/lib/zyphr/models/auth_email_template_list_response.rb +231 -0
  44. data/lib/zyphr/models/auth_email_template_preview_draft.rb +272 -0
  45. data/lib/zyphr/models/auth_email_template_preview_request.rb +232 -0
  46. data/lib/zyphr/models/auth_email_template_preview_response.rb +229 -0
  47. data/lib/zyphr/models/auth_email_template_preview_result.rb +258 -0
  48. data/lib/zyphr/models/auth_email_template_response.rb +229 -0
  49. data/lib/zyphr/models/auth_email_template_test_request.rb +249 -0
  50. data/lib/zyphr/models/auth_email_template_test_response.rb +229 -0
  51. data/lib/zyphr/models/auth_email_template_test_result.rb +229 -0
  52. data/lib/zyphr/models/auth_email_template_version.rb +352 -0
  53. data/lib/zyphr/models/auth_email_template_versions_response.rb +231 -0
  54. data/lib/zyphr/models/auth_email_type.rb +41 -0
  55. data/lib/zyphr/models/bulk_upsert_auth_email_templates_request.rb +239 -0
  56. data/lib/zyphr/models/bulk_upsert_auth_email_templates_response.rb +231 -0
  57. data/lib/zyphr/models/resubscribe_response.rb +1 -1
  58. data/lib/zyphr/models/send_slack_message_request.rb +340 -0
  59. data/lib/zyphr/models/send_slack_message_response.rb +229 -0
  60. data/lib/zyphr/models/send_slack_message_result.rb +289 -0
  61. data/lib/zyphr/models/slack_message.rb +406 -0
  62. data/lib/zyphr/models/slack_message_list_response.rb +231 -0
  63. data/lib/zyphr/models/slack_message_list_response_meta.rb +254 -0
  64. data/lib/zyphr/models/slack_message_response.rb +229 -0
  65. data/lib/zyphr/models/slack_message_status.rb +43 -0
  66. data/lib/zyphr/models/slack_message_summary.rb +340 -0
  67. data/lib/zyphr/models/success_result.rb +1 -1
  68. data/lib/zyphr/models/upsert_auth_email_template_request.rb +335 -0
  69. data/lib/zyphr.rb +31 -1
  70. data/spec/api/auth_email_templates_api_spec.rb +157 -0
  71. data/spec/api/slack_api_spec.rb +75 -0
  72. data/spec/models/auth_email_template_default_response_spec.rb +42 -0
  73. data/spec/models/auth_email_template_default_spec.rb +60 -0
  74. data/spec/models/{success_result_data_spec.rb → auth_email_template_delete_response_data_spec.rb} +6 -6
  75. data/spec/models/auth_email_template_delete_response_spec.rb +42 -0
  76. data/spec/models/auth_email_template_list_response_spec.rb +42 -0
  77. data/spec/models/auth_email_template_preview_draft_spec.rb +66 -0
  78. data/spec/models/auth_email_template_preview_request_spec.rb +42 -0
  79. data/spec/models/auth_email_template_preview_response_spec.rb +42 -0
  80. data/spec/models/auth_email_template_preview_result_spec.rb +60 -0
  81. data/spec/models/auth_email_template_response_spec.rb +42 -0
  82. data/spec/models/auth_email_template_spec.rb +112 -0
  83. data/spec/models/auth_email_template_test_request_spec.rb +42 -0
  84. data/spec/models/auth_email_template_test_response_spec.rb +42 -0
  85. data/spec/models/auth_email_template_test_result_spec.rb +42 -0
  86. data/spec/models/auth_email_template_version_spec.rb +100 -0
  87. data/spec/models/auth_email_template_versions_response_spec.rb +42 -0
  88. data/spec/models/auth_email_type_spec.rb +30 -0
  89. data/spec/models/bulk_upsert_auth_email_templates_request_spec.rb +48 -0
  90. data/spec/models/bulk_upsert_auth_email_templates_response_spec.rb +42 -0
  91. data/spec/models/send_slack_message_request_spec.rb +102 -0
  92. data/spec/models/send_slack_message_response_spec.rb +42 -0
  93. data/spec/models/send_slack_message_result_spec.rb +66 -0
  94. data/spec/models/slack_message_list_response_meta_spec.rb +54 -0
  95. data/spec/models/slack_message_list_response_spec.rb +42 -0
  96. data/spec/models/slack_message_response_spec.rb +42 -0
  97. data/spec/models/slack_message_spec.rb +132 -0
  98. data/spec/models/slack_message_status_spec.rb +30 -0
  99. data/spec/models/slack_message_summary_spec.rb +96 -0
  100. data/spec/models/upsert_auth_email_template_request_spec.rb +88 -0
  101. data/zyphr.gemspec +1 -1
  102. metadata +126 -6
@@ -0,0 +1,272 @@
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
+ # In-flight editor values. When provided, the preview is rendered against these instead of the persisted template. Useful for live-preview while editing.
18
+ class AuthEmailTemplatePreviewDraft
19
+ attr_accessor :subject
20
+
21
+ attr_accessor :html
22
+
23
+ attr_accessor :text
24
+
25
+ attr_accessor :mjml_source
26
+
27
+ attr_accessor :from_name
28
+
29
+ attr_accessor :reply_to
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'subject' => :'subject',
35
+ :'html' => :'html',
36
+ :'text' => :'text',
37
+ :'mjml_source' => :'mjml_source',
38
+ :'from_name' => :'from_name',
39
+ :'reply_to' => :'reply_to'
40
+ }
41
+ end
42
+
43
+ # Returns attribute mapping this model knows about
44
+ def self.acceptable_attribute_map
45
+ attribute_map
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ acceptable_attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'subject' => :'String',
57
+ :'html' => :'String',
58
+ :'text' => :'String',
59
+ :'mjml_source' => :'String',
60
+ :'from_name' => :'String',
61
+ :'reply_to' => :'String'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ :'subject',
69
+ :'html',
70
+ :'text',
71
+ :'mjml_source',
72
+ :'from_name',
73
+ :'reply_to'
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AuthEmailTemplatePreviewDraft` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ acceptable_attribute_map = self.class.acceptable_attribute_map
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!acceptable_attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AuthEmailTemplatePreviewDraft`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'subject')
94
+ self.subject = attributes[:'subject']
95
+ end
96
+
97
+ if attributes.key?(:'html')
98
+ self.html = attributes[:'html']
99
+ end
100
+
101
+ if attributes.key?(:'text')
102
+ self.text = attributes[:'text']
103
+ end
104
+
105
+ if attributes.key?(:'mjml_source')
106
+ self.mjml_source = attributes[:'mjml_source']
107
+ end
108
+
109
+ if attributes.key?(:'from_name')
110
+ self.from_name = attributes[:'from_name']
111
+ end
112
+
113
+ if attributes.key?(:'reply_to')
114
+ self.reply_to = attributes[:'reply_to']
115
+ end
116
+ end
117
+
118
+ # Show invalid properties with the reasons. Usually used together with valid?
119
+ # @return Array for valid properties with the reasons
120
+ def list_invalid_properties
121
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
122
+ invalid_properties = Array.new
123
+ invalid_properties
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ warn '[DEPRECATED] the `valid?` method is obsolete'
130
+ true
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(o)
136
+ return true if self.equal?(o)
137
+ self.class == o.class &&
138
+ subject == o.subject &&
139
+ html == o.html &&
140
+ text == o.text &&
141
+ mjml_source == o.mjml_source &&
142
+ from_name == o.from_name &&
143
+ reply_to == o.reply_to
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
+ [subject, html, text, mjml_source, from_name, reply_to].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,232 @@
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 AuthEmailTemplatePreviewRequest
18
+ # Variables to interpolate. If omitted, sample values are used.
19
+ attr_accessor :variables
20
+
21
+ attr_accessor :draft
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'variables' => :'variables',
27
+ :'draft' => :'draft'
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
+ :'variables' => :'Hash<String, Object>',
45
+ :'draft' => :'AuthEmailTemplatePreviewDraft'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AuthEmailTemplatePreviewRequest` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ acceptable_attribute_map = self.class.acceptable_attribute_map
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!acceptable_attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AuthEmailTemplatePreviewRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'variables')
72
+ if (value = attributes[:'variables']).is_a?(Hash)
73
+ self.variables = value
74
+ end
75
+ end
76
+
77
+ if attributes.key?(:'draft')
78
+ self.draft = attributes[:'draft']
79
+ end
80
+ end
81
+
82
+ # Show invalid properties with the reasons. Usually used together with valid?
83
+ # @return Array for valid properties with the reasons
84
+ def list_invalid_properties
85
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
86
+ invalid_properties = Array.new
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ warn '[DEPRECATED] the `valid?` method is obsolete'
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ variables == o.variables &&
103
+ draft == o.draft
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Integer] Hash code
114
+ def hash
115
+ [variables, draft].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ attributes = attributes.transform_keys(&:to_sym)
124
+ transformed_hash = {}
125
+ openapi_types.each_pair do |key, type|
126
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
127
+ transformed_hash["#{key}"] = nil
128
+ elsif type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[attribute_map[key]].is_a?(Array)
132
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
133
+ end
134
+ elsif !attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
136
+ end
137
+ end
138
+ new(transformed_hash)
139
+ end
140
+
141
+ # Deserializes the data based on type
142
+ # @param string type Data type
143
+ # @param string value Value to be deserialized
144
+ # @return [Object] Deserialized data
145
+ def self._deserialize(type, value)
146
+ case type.to_sym
147
+ when :Time
148
+ Time.parse(value)
149
+ when :Date
150
+ Date.parse(value)
151
+ when :String
152
+ value.to_s
153
+ when :Integer
154
+ value.to_i
155
+ when :Float
156
+ value.to_f
157
+ when :Boolean
158
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
159
+ true
160
+ else
161
+ false
162
+ end
163
+ when :Object
164
+ # generic object (usually a Hash), return directly
165
+ value
166
+ when /\AArray<(?<inner_type>.+)>\z/
167
+ inner_type = Regexp.last_match[:inner_type]
168
+ value.map { |v| _deserialize(inner_type, v) }
169
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
+ k_type = Regexp.last_match[:k_type]
171
+ v_type = Regexp.last_match[:v_type]
172
+ {}.tap do |hash|
173
+ value.each do |k, v|
174
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
+ end
176
+ end
177
+ else # model
178
+ # models (e.g. Pet) or oneOf
179
+ klass = Zyphr.const_get(type)
180
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ if value.nil?
203
+ is_nullable = self.class.openapi_nullable.include?(attr)
204
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
205
+ end
206
+
207
+ hash[param] = _to_hash(value)
208
+ end
209
+ hash
210
+ end
211
+
212
+ # Outputs non-array value in the form of hash
213
+ # For object, use to_hash. Otherwise, just return the value
214
+ # @param [Object] value Any valid value
215
+ # @return [Hash] Returns the value in the form of hash
216
+ def _to_hash(value)
217
+ if value.is_a?(Array)
218
+ value.compact.map { |v| _to_hash(v) }
219
+ elsif value.is_a?(Hash)
220
+ {}.tap do |hash|
221
+ value.each { |k, v| hash[k] = _to_hash(v) }
222
+ end
223
+ elsif value.respond_to? :to_hash
224
+ value.to_hash
225
+ else
226
+ value
227
+ end
228
+ end
229
+
230
+ end
231
+
232
+ end