zyphr 0.1.0 → 0.1.2

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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +59 -0
  3. data/docs/BatchPublishWaaSEvents201Response.md +18 -0
  4. data/docs/CreateWaaSApplication201Response.md +18 -0
  5. data/docs/CreateWaaSApplicationRequest.md +22 -0
  6. data/docs/CreateWaaSEndpoint201Response.md +18 -0
  7. data/docs/CreateWaaSEndpointRequest.md +22 -0
  8. data/docs/CreateWaaSEndpointResponse.md +30 -0
  9. data/docs/CreateWaaSEventType201Response.md +18 -0
  10. data/docs/CreateWaaSEventTypeRequest.md +26 -0
  11. data/docs/GenerateWaaSPortalToken201Response.md +18 -0
  12. data/docs/GetWaaSEndpoint200Response.md +18 -0
  13. data/docs/GetWaaSUsage200Response.md +18 -0
  14. data/docs/ListWaaSApplications200Response.md +18 -0
  15. data/docs/ListWaaSEndpointDeliveries200Response.md +18 -0
  16. data/docs/ListWaaSEndpoints200Response.md +18 -0
  17. data/docs/ListWaaSEventTypes200Response.md +18 -0
  18. data/docs/PublishWaaSEvent201Response.md +18 -0
  19. data/docs/UpdateWaaSApplicationRequest.md +22 -0
  20. data/docs/UpdateWaaSEndpointRequest.md +22 -0
  21. data/docs/UpdateWaaSEventTypeRequest.md +24 -0
  22. data/docs/WaaSApplication.md +32 -0
  23. data/docs/WaaSApplicationsApi.md +446 -0
  24. data/docs/WaaSBatchPublishRequest.md +18 -0
  25. data/docs/WaaSBatchPublishResponse.md +22 -0
  26. data/docs/WaaSDeliveriesApi.md +319 -0
  27. data/docs/WaaSDelivery.md +38 -0
  28. data/docs/WaaSEndpoint.md +32 -0
  29. data/docs/WaaSEndpointsApi.md +673 -0
  30. data/docs/WaaSEventType.md +36 -0
  31. data/docs/WaaSEventTypesApi.md +454 -0
  32. data/docs/WaaSEventsApi.md +155 -0
  33. data/docs/WaaSPortalApi.md +81 -0
  34. data/docs/WaaSPortalTokenRequest.md +24 -0
  35. data/docs/WaaSPortalTokenRequestTheme.md +20 -0
  36. data/docs/WaaSPortalTokenResponse.md +20 -0
  37. data/docs/WaaSPublishEventRequest.md +24 -0
  38. data/docs/WaaSPublishEventResponse.md +26 -0
  39. data/docs/WaaSUsageResponse.md +28 -0
  40. data/lib/zyphr/api/waa_s_applications_api.rb +425 -0
  41. data/lib/zyphr/api/waa_s_deliveries_api.rb +316 -0
  42. data/lib/zyphr/api/waa_s_endpoints_api.rb +653 -0
  43. data/lib/zyphr/api/waa_s_event_types_api.rb +452 -0
  44. data/lib/zyphr/api/waa_s_events_api.rb +170 -0
  45. data/lib/zyphr/api/waa_s_portal_api.rb +96 -0
  46. data/lib/zyphr/models/batch_publish_waa_s_events201_response.rb +220 -0
  47. data/lib/zyphr/models/create_waa_s_application201_response.rb +220 -0
  48. data/lib/zyphr/models/create_waa_s_application_request.rb +275 -0
  49. data/lib/zyphr/models/create_waa_s_endpoint201_response.rb +220 -0
  50. data/lib/zyphr/models/create_waa_s_endpoint_request.rb +294 -0
  51. data/lib/zyphr/models/create_waa_s_endpoint_response.rb +277 -0
  52. data/lib/zyphr/models/create_waa_s_event_type201_response.rb +220 -0
  53. data/lib/zyphr/models/create_waa_s_event_type_request.rb +292 -0
  54. data/lib/zyphr/models/generate_waa_s_portal_token201_response.rb +220 -0
  55. data/lib/zyphr/models/get_waa_s_endpoint200_response.rb +220 -0
  56. data/lib/zyphr/models/get_waa_s_usage200_response.rb +220 -0
  57. data/lib/zyphr/models/list_waa_s_applications200_response.rb +222 -0
  58. data/lib/zyphr/models/list_waa_s_endpoint_deliveries200_response.rb +222 -0
  59. data/lib/zyphr/models/list_waa_s_endpoints200_response.rb +222 -0
  60. data/lib/zyphr/models/list_waa_s_event_types200_response.rb +222 -0
  61. data/lib/zyphr/models/publish_waa_s_event201_response.rb +220 -0
  62. data/lib/zyphr/models/update_waa_s_application_request.rb +272 -0
  63. data/lib/zyphr/models/update_waa_s_endpoint_request.rb +274 -0
  64. data/lib/zyphr/models/update_waa_s_event_type_request.rb +247 -0
  65. data/lib/zyphr/models/waa_s_application.rb +317 -0
  66. data/lib/zyphr/models/waa_s_batch_publish_request.rb +248 -0
  67. data/lib/zyphr/models/waa_s_batch_publish_response.rb +240 -0
  68. data/lib/zyphr/models/waa_s_delivery.rb +344 -0
  69. data/lib/zyphr/models/waa_s_endpoint.rb +319 -0
  70. data/lib/zyphr/models/waa_s_event_type.rb +335 -0
  71. data/lib/zyphr/models/waa_s_portal_token_request.rb +267 -0
  72. data/lib/zyphr/models/waa_s_portal_token_request_theme.rb +263 -0
  73. data/lib/zyphr/models/waa_s_portal_token_response.rb +229 -0
  74. data/lib/zyphr/models/waa_s_publish_event_request.rb +302 -0
  75. data/lib/zyphr/models/waa_s_publish_event_response.rb +256 -0
  76. data/lib/zyphr/models/waa_s_usage_response.rb +265 -0
  77. data/lib/zyphr.rb +37 -0
  78. data/spec/api/waa_s_applications_api_spec.rb +110 -0
  79. data/spec/api/waa_s_deliveries_api_spec.rb +94 -0
  80. data/spec/api/waa_s_endpoints_api_spec.rb +154 -0
  81. data/spec/api/waa_s_event_types_api_spec.rb +115 -0
  82. data/spec/api/waa_s_events_api_spec.rb +61 -0
  83. data/spec/api/waa_s_portal_api_spec.rb +48 -0
  84. data/spec/models/batch_publish_waa_s_events201_response_spec.rb +36 -0
  85. data/spec/models/create_waa_s_application201_response_spec.rb +36 -0
  86. data/spec/models/create_waa_s_application_request_spec.rb +48 -0
  87. data/spec/models/create_waa_s_endpoint201_response_spec.rb +36 -0
  88. data/spec/models/create_waa_s_endpoint_request_spec.rb +48 -0
  89. data/spec/models/create_waa_s_endpoint_response_spec.rb +72 -0
  90. data/spec/models/create_waa_s_event_type201_response_spec.rb +36 -0
  91. data/spec/models/create_waa_s_event_type_request_spec.rb +60 -0
  92. data/spec/models/generate_waa_s_portal_token201_response_spec.rb +36 -0
  93. data/spec/models/get_waa_s_endpoint200_response_spec.rb +36 -0
  94. data/spec/models/get_waa_s_usage200_response_spec.rb +36 -0
  95. data/spec/models/list_waa_s_applications200_response_spec.rb +36 -0
  96. data/spec/models/list_waa_s_endpoint_deliveries200_response_spec.rb +36 -0
  97. data/spec/models/list_waa_s_endpoints200_response_spec.rb +36 -0
  98. data/spec/models/list_waa_s_event_types200_response_spec.rb +36 -0
  99. data/spec/models/publish_waa_s_event201_response_spec.rb +36 -0
  100. data/spec/models/update_waa_s_application_request_spec.rb +52 -0
  101. data/spec/models/update_waa_s_endpoint_request_spec.rb +52 -0
  102. data/spec/models/update_waa_s_event_type_request_spec.rb +54 -0
  103. data/spec/models/waa_s_application_spec.rb +82 -0
  104. data/spec/models/waa_s_batch_publish_request_spec.rb +36 -0
  105. data/spec/models/waa_s_batch_publish_response_spec.rb +48 -0
  106. data/spec/models/waa_s_delivery_spec.rb +100 -0
  107. data/spec/models/waa_s_endpoint_spec.rb +82 -0
  108. data/spec/models/waa_s_event_type_spec.rb +94 -0
  109. data/spec/models/waa_s_portal_token_request_spec.rb +54 -0
  110. data/spec/models/waa_s_portal_token_request_theme_spec.rb +46 -0
  111. data/spec/models/waa_s_portal_token_response_spec.rb +42 -0
  112. data/spec/models/waa_s_publish_event_request_spec.rb +54 -0
  113. data/spec/models/waa_s_publish_event_response_spec.rb +60 -0
  114. data/spec/models/waa_s_usage_response_spec.rb +66 -0
  115. data/zyphr.gemspec +1 -1
  116. metadata +150 -2
@@ -0,0 +1,335 @@
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 WaaSEventType
18
+ attr_accessor :id
19
+
20
+ attr_accessor :application_id
21
+
22
+ attr_accessor :event_type
23
+
24
+ attr_accessor :name
25
+
26
+ attr_accessor :description
27
+
28
+ attr_accessor :category
29
+
30
+ attr_accessor :example_payload
31
+
32
+ attr_accessor :status
33
+
34
+ attr_accessor :created_at
35
+
36
+ attr_accessor :updated_at
37
+
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'id' => :'id',
64
+ :'application_id' => :'application_id',
65
+ :'event_type' => :'event_type',
66
+ :'name' => :'name',
67
+ :'description' => :'description',
68
+ :'category' => :'category',
69
+ :'example_payload' => :'example_payload',
70
+ :'status' => :'status',
71
+ :'created_at' => :'created_at',
72
+ :'updated_at' => :'updated_at'
73
+ }
74
+ end
75
+
76
+ # Returns attribute mapping this model knows about
77
+ def self.acceptable_attribute_map
78
+ attribute_map
79
+ end
80
+
81
+ # Returns all the JSON keys this model knows about
82
+ def self.acceptable_attributes
83
+ acceptable_attribute_map.values
84
+ end
85
+
86
+ # Attribute type mapping.
87
+ def self.openapi_types
88
+ {
89
+ :'id' => :'String',
90
+ :'application_id' => :'String',
91
+ :'event_type' => :'String',
92
+ :'name' => :'String',
93
+ :'description' => :'String',
94
+ :'category' => :'String',
95
+ :'example_payload' => :'Object',
96
+ :'status' => :'String',
97
+ :'created_at' => :'Time',
98
+ :'updated_at' => :'Time'
99
+ }
100
+ end
101
+
102
+ # List of attributes with nullable: true
103
+ def self.openapi_nullable
104
+ Set.new([
105
+ ])
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::WaaSEventType` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ acceptable_attribute_map = self.class.acceptable_attribute_map
117
+ attributes = attributes.each_with_object({}) { |(k, v), h|
118
+ if (!acceptable_attribute_map.key?(k.to_sym))
119
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::WaaSEventType`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
120
+ end
121
+ h[k.to_sym] = v
122
+ }
123
+
124
+ if attributes.key?(:'id')
125
+ self.id = attributes[:'id']
126
+ end
127
+
128
+ if attributes.key?(:'application_id')
129
+ self.application_id = attributes[:'application_id']
130
+ end
131
+
132
+ if attributes.key?(:'event_type')
133
+ self.event_type = attributes[:'event_type']
134
+ end
135
+
136
+ if attributes.key?(:'name')
137
+ self.name = attributes[:'name']
138
+ end
139
+
140
+ if attributes.key?(:'description')
141
+ self.description = attributes[:'description']
142
+ end
143
+
144
+ if attributes.key?(:'category')
145
+ self.category = attributes[:'category']
146
+ end
147
+
148
+ if attributes.key?(:'example_payload')
149
+ self.example_payload = attributes[:'example_payload']
150
+ end
151
+
152
+ if attributes.key?(:'status')
153
+ self.status = attributes[:'status']
154
+ end
155
+
156
+ if attributes.key?(:'created_at')
157
+ self.created_at = attributes[:'created_at']
158
+ end
159
+
160
+ if attributes.key?(:'updated_at')
161
+ self.updated_at = attributes[:'updated_at']
162
+ end
163
+ end
164
+
165
+ # Show invalid properties with the reasons. Usually used together with valid?
166
+ # @return Array for valid properties with the reasons
167
+ def list_invalid_properties
168
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
169
+ invalid_properties = Array.new
170
+ invalid_properties
171
+ end
172
+
173
+ # Check to see if the all the properties in the model are valid
174
+ # @return true if the model is valid
175
+ def valid?
176
+ warn '[DEPRECATED] the `valid?` method is obsolete'
177
+ status_validator = EnumAttributeValidator.new('String', ["active", "deprecated"])
178
+ return false unless status_validator.valid?(@status)
179
+ true
180
+ end
181
+
182
+ # Custom attribute writer method checking allowed values (enum).
183
+ # @param [Object] status Object to be assigned
184
+ def status=(status)
185
+ validator = EnumAttributeValidator.new('String', ["active", "deprecated"])
186
+ unless validator.valid?(status)
187
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
188
+ end
189
+ @status = status
190
+ end
191
+
192
+ # Checks equality by comparing each attribute.
193
+ # @param [Object] Object to be compared
194
+ def ==(o)
195
+ return true if self.equal?(o)
196
+ self.class == o.class &&
197
+ id == o.id &&
198
+ application_id == o.application_id &&
199
+ event_type == o.event_type &&
200
+ name == o.name &&
201
+ description == o.description &&
202
+ category == o.category &&
203
+ example_payload == o.example_payload &&
204
+ status == o.status &&
205
+ created_at == o.created_at &&
206
+ updated_at == o.updated_at
207
+ end
208
+
209
+ # @see the `==` method
210
+ # @param [Object] Object to be compared
211
+ def eql?(o)
212
+ self == o
213
+ end
214
+
215
+ # Calculates hash code according to all attributes.
216
+ # @return [Integer] Hash code
217
+ def hash
218
+ [id, application_id, event_type, name, description, category, example_payload, status, created_at, updated_at].hash
219
+ end
220
+
221
+ # Builds the object from hash
222
+ # @param [Hash] attributes Model attributes in the form of hash
223
+ # @return [Object] Returns the model itself
224
+ def self.build_from_hash(attributes)
225
+ return nil unless attributes.is_a?(Hash)
226
+ attributes = attributes.transform_keys(&:to_sym)
227
+ transformed_hash = {}
228
+ openapi_types.each_pair do |key, type|
229
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
230
+ transformed_hash["#{key}"] = nil
231
+ elsif type =~ /\AArray<(.*)>/i
232
+ # check to ensure the input is an array given that the attribute
233
+ # is documented as an array but the input is not
234
+ if attributes[attribute_map[key]].is_a?(Array)
235
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
236
+ end
237
+ elsif !attributes[attribute_map[key]].nil?
238
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
239
+ end
240
+ end
241
+ new(transformed_hash)
242
+ end
243
+
244
+ # Deserializes the data based on type
245
+ # @param string type Data type
246
+ # @param string value Value to be deserialized
247
+ # @return [Object] Deserialized data
248
+ def self._deserialize(type, value)
249
+ case type.to_sym
250
+ when :Time
251
+ Time.parse(value)
252
+ when :Date
253
+ Date.parse(value)
254
+ when :String
255
+ value.to_s
256
+ when :Integer
257
+ value.to_i
258
+ when :Float
259
+ value.to_f
260
+ when :Boolean
261
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
262
+ true
263
+ else
264
+ false
265
+ end
266
+ when :Object
267
+ # generic object (usually a Hash), return directly
268
+ value
269
+ when /\AArray<(?<inner_type>.+)>\z/
270
+ inner_type = Regexp.last_match[:inner_type]
271
+ value.map { |v| _deserialize(inner_type, v) }
272
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
273
+ k_type = Regexp.last_match[:k_type]
274
+ v_type = Regexp.last_match[:v_type]
275
+ {}.tap do |hash|
276
+ value.each do |k, v|
277
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
278
+ end
279
+ end
280
+ else # model
281
+ # models (e.g. Pet) or oneOf
282
+ klass = Zyphr.const_get(type)
283
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
284
+ end
285
+ end
286
+
287
+ # Returns the string representation of the object
288
+ # @return [String] String presentation of the object
289
+ def to_s
290
+ to_hash.to_s
291
+ end
292
+
293
+ # to_body is an alias to to_hash (backward compatibility)
294
+ # @return [Hash] Returns the object in the form of hash
295
+ def to_body
296
+ to_hash
297
+ end
298
+
299
+ # Returns the object in the form of hash
300
+ # @return [Hash] Returns the object in the form of hash
301
+ def to_hash
302
+ hash = {}
303
+ self.class.attribute_map.each_pair do |attr, param|
304
+ value = self.send(attr)
305
+ if value.nil?
306
+ is_nullable = self.class.openapi_nullable.include?(attr)
307
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
308
+ end
309
+
310
+ hash[param] = _to_hash(value)
311
+ end
312
+ hash
313
+ end
314
+
315
+ # Outputs non-array value in the form of hash
316
+ # For object, use to_hash. Otherwise, just return the value
317
+ # @param [Object] value Any valid value
318
+ # @return [Hash] Returns the value in the form of hash
319
+ def _to_hash(value)
320
+ if value.is_a?(Array)
321
+ value.compact.map { |v| _to_hash(v) }
322
+ elsif value.is_a?(Hash)
323
+ {}.tap do |hash|
324
+ value.each { |k, v| hash[k] = _to_hash(v) }
325
+ end
326
+ elsif value.respond_to? :to_hash
327
+ value.to_hash
328
+ else
329
+ value
330
+ end
331
+ end
332
+
333
+ end
334
+
335
+ end
@@ -0,0 +1,267 @@
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 WaaSPortalTokenRequest
18
+ attr_accessor :tenant_id
19
+
20
+ attr_accessor :allowed_event_types
21
+
22
+ # Token TTL in seconds (default 3600)
23
+ attr_accessor :expires_in
24
+
25
+ attr_accessor :theme
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'tenant_id' => :'tenant_id',
31
+ :'allowed_event_types' => :'allowed_event_types',
32
+ :'expires_in' => :'expires_in',
33
+ :'theme' => :'theme'
34
+ }
35
+ end
36
+
37
+ # Returns attribute mapping this model knows about
38
+ def self.acceptable_attribute_map
39
+ attribute_map
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ acceptable_attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'tenant_id' => :'String',
51
+ :'allowed_event_types' => :'Array<String>',
52
+ :'expires_in' => :'Integer',
53
+ :'theme' => :'WaaSPortalTokenRequestTheme'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::WaaSPortalTokenRequest` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ acceptable_attribute_map = self.class.acceptable_attribute_map
72
+ attributes = attributes.each_with_object({}) { |(k, v), h|
73
+ if (!acceptable_attribute_map.key?(k.to_sym))
74
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::WaaSPortalTokenRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
75
+ end
76
+ h[k.to_sym] = v
77
+ }
78
+
79
+ if attributes.key?(:'tenant_id')
80
+ self.tenant_id = attributes[:'tenant_id']
81
+ else
82
+ self.tenant_id = nil
83
+ end
84
+
85
+ if attributes.key?(:'allowed_event_types')
86
+ if (value = attributes[:'allowed_event_types']).is_a?(Array)
87
+ self.allowed_event_types = value
88
+ end
89
+ end
90
+
91
+ if attributes.key?(:'expires_in')
92
+ self.expires_in = attributes[:'expires_in']
93
+ end
94
+
95
+ if attributes.key?(:'theme')
96
+ self.theme = attributes[:'theme']
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
104
+ invalid_properties = Array.new
105
+ if @tenant_id.nil?
106
+ invalid_properties.push('invalid value for "tenant_id", tenant_id cannot be nil.')
107
+ end
108
+
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ warn '[DEPRECATED] the `valid?` method is obsolete'
116
+ return false if @tenant_id.nil?
117
+ true
118
+ end
119
+
120
+ # Custom attribute writer method with validation
121
+ # @param [Object] tenant_id Value to be assigned
122
+ def tenant_id=(tenant_id)
123
+ if tenant_id.nil?
124
+ fail ArgumentError, 'tenant_id cannot be nil'
125
+ end
126
+
127
+ @tenant_id = tenant_id
128
+ end
129
+
130
+ # Checks equality by comparing each attribute.
131
+ # @param [Object] Object to be compared
132
+ def ==(o)
133
+ return true if self.equal?(o)
134
+ self.class == o.class &&
135
+ tenant_id == o.tenant_id &&
136
+ allowed_event_types == o.allowed_event_types &&
137
+ expires_in == o.expires_in &&
138
+ theme == o.theme
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(o)
144
+ self == o
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Integer] Hash code
149
+ def hash
150
+ [tenant_id, allowed_event_types, expires_in, theme].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def self.build_from_hash(attributes)
157
+ return nil unless attributes.is_a?(Hash)
158
+ attributes = attributes.transform_keys(&:to_sym)
159
+ transformed_hash = {}
160
+ openapi_types.each_pair do |key, type|
161
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
162
+ transformed_hash["#{key}"] = nil
163
+ elsif type =~ /\AArray<(.*)>/i
164
+ # check to ensure the input is an array given that the attribute
165
+ # is documented as an array but the input is not
166
+ if attributes[attribute_map[key]].is_a?(Array)
167
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
168
+ end
169
+ elsif !attributes[attribute_map[key]].nil?
170
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
171
+ end
172
+ end
173
+ new(transformed_hash)
174
+ end
175
+
176
+ # Deserializes the data based on type
177
+ # @param string type Data type
178
+ # @param string value Value to be deserialized
179
+ # @return [Object] Deserialized data
180
+ def self._deserialize(type, value)
181
+ case type.to_sym
182
+ when :Time
183
+ Time.parse(value)
184
+ when :Date
185
+ Date.parse(value)
186
+ when :String
187
+ value.to_s
188
+ when :Integer
189
+ value.to_i
190
+ when :Float
191
+ value.to_f
192
+ when :Boolean
193
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
194
+ true
195
+ else
196
+ false
197
+ end
198
+ when :Object
199
+ # generic object (usually a Hash), return directly
200
+ value
201
+ when /\AArray<(?<inner_type>.+)>\z/
202
+ inner_type = Regexp.last_match[:inner_type]
203
+ value.map { |v| _deserialize(inner_type, v) }
204
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
205
+ k_type = Regexp.last_match[:k_type]
206
+ v_type = Regexp.last_match[:v_type]
207
+ {}.tap do |hash|
208
+ value.each do |k, v|
209
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
210
+ end
211
+ end
212
+ else # model
213
+ # models (e.g. Pet) or oneOf
214
+ klass = Zyphr.const_get(type)
215
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
216
+ end
217
+ end
218
+
219
+ # Returns the string representation of the object
220
+ # @return [String] String presentation of the object
221
+ def to_s
222
+ to_hash.to_s
223
+ end
224
+
225
+ # to_body is an alias to to_hash (backward compatibility)
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_body
228
+ to_hash
229
+ end
230
+
231
+ # Returns the object in the form of hash
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_hash
234
+ hash = {}
235
+ self.class.attribute_map.each_pair do |attr, param|
236
+ value = self.send(attr)
237
+ if value.nil?
238
+ is_nullable = self.class.openapi_nullable.include?(attr)
239
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
240
+ end
241
+
242
+ hash[param] = _to_hash(value)
243
+ end
244
+ hash
245
+ end
246
+
247
+ # Outputs non-array value in the form of hash
248
+ # For object, use to_hash. Otherwise, just return the value
249
+ # @param [Object] value Any valid value
250
+ # @return [Hash] Returns the value in the form of hash
251
+ def _to_hash(value)
252
+ if value.is_a?(Array)
253
+ value.compact.map { |v| _to_hash(v) }
254
+ elsif value.is_a?(Hash)
255
+ {}.tap do |hash|
256
+ value.each { |k, v| hash[k] = _to_hash(v) }
257
+ end
258
+ elsif value.respond_to? :to_hash
259
+ value.to_hash
260
+ else
261
+ value
262
+ end
263
+ end
264
+
265
+ end
266
+
267
+ end