zyphr 0.1.37 → 0.1.39

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -1
  3. data/docs/AuthOAuthApi.md +12 -12
  4. data/docs/AuthRegistrationApi.md +145 -1
  5. data/docs/AuthUserDirectoryApi.md +627 -0
  6. data/docs/AuthUserProfileApi.md +0 -76
  7. data/docs/InviteEndUserRequest.md +26 -0
  8. data/docs/OAuthProviderName.md +15 -0
  9. data/docs/SetEndUserClaimsRequest.md +18 -0
  10. data/docs/SignInAnonymouslyRequest.md +5 -1
  11. data/docs/SignInWithGameCenterRequest.md +28 -0
  12. data/docs/SignInWithGooglePlayGamesRequest.md +18 -0
  13. data/docs/UpdateEndUserByApplicationRequest.md +26 -0
  14. data/lib/zyphr/api/auth_o_auth_api.rb +12 -12
  15. data/lib/zyphr/api/auth_registration_api.rb +138 -2
  16. data/lib/zyphr/api/auth_user_directory_api.rb +560 -0
  17. data/lib/zyphr/api/auth_user_profile_api.rb +0 -61
  18. data/lib/zyphr/models/invite_end_user_request.rb +309 -0
  19. data/lib/zyphr/models/o_auth_provider_name.rb +43 -0
  20. data/lib/zyphr/models/set_end_user_claims_request.rb +220 -0
  21. data/lib/zyphr/models/sign_in_anonymously_request.rb +43 -4
  22. data/lib/zyphr/models/sign_in_with_game_center_request.rb +373 -0
  23. data/lib/zyphr/models/sign_in_with_google_play_games_request.rb +238 -0
  24. data/lib/zyphr/models/update_end_user_by_application_request.rb +256 -0
  25. data/lib/zyphr.rb +7 -0
  26. data/spec/api/auth_registration_api_spec.rb +25 -1
  27. data/spec/api/auth_user_directory_api_spec.rb +136 -0
  28. data/spec/api/auth_user_profile_api_spec.rb +0 -12
  29. data/spec/models/invite_end_user_request_spec.rb +64 -0
  30. data/spec/models/o_auth_provider_name_spec.rb +30 -0
  31. data/spec/models/set_end_user_claims_request_spec.rb +36 -0
  32. data/spec/models/sign_in_anonymously_request_spec.rb +12 -0
  33. data/spec/models/sign_in_with_game_center_request_spec.rb +66 -0
  34. data/spec/models/sign_in_with_google_play_games_request_spec.rb +36 -0
  35. data/spec/models/update_end_user_by_application_request_spec.rb +60 -0
  36. data/zyphr.gemspec +1 -1
  37. metadata +450 -422
@@ -0,0 +1,309 @@
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 ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class InviteEndUserRequest
18
+ attr_accessor :email
19
+
20
+ attr_accessor :name
21
+
22
+ attr_accessor :metadata
23
+
24
+ attr_accessor :send_link
25
+
26
+ attr_accessor :redirect_url
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'email' => :'email',
54
+ :'name' => :'name',
55
+ :'metadata' => :'metadata',
56
+ :'send_link' => :'send_link',
57
+ :'redirect_url' => :'redirect_url'
58
+ }
59
+ end
60
+
61
+ # Returns attribute mapping this model knows about
62
+ def self.acceptable_attribute_map
63
+ attribute_map
64
+ end
65
+
66
+ # Returns all the JSON keys this model knows about
67
+ def self.acceptable_attributes
68
+ acceptable_attribute_map.values
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'email' => :'String',
75
+ :'name' => :'String',
76
+ :'metadata' => :'Object',
77
+ :'send_link' => :'String',
78
+ :'redirect_url' => :'String'
79
+ }
80
+ end
81
+
82
+ # List of attributes with nullable: true
83
+ def self.openapi_nullable
84
+ Set.new([
85
+ ])
86
+ end
87
+
88
+ # Initializes the object
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ def initialize(attributes = {})
91
+ if (!attributes.is_a?(Hash))
92
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::InviteEndUserRequest` initialize method"
93
+ end
94
+
95
+ # check to see if the attribute exists and convert string to symbol for hash key
96
+ acceptable_attribute_map = self.class.acceptable_attribute_map
97
+ attributes = attributes.each_with_object({}) { |(k, v), h|
98
+ if (!acceptable_attribute_map.key?(k.to_sym))
99
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::InviteEndUserRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
100
+ end
101
+ h[k.to_sym] = v
102
+ }
103
+
104
+ if attributes.key?(:'email')
105
+ self.email = attributes[:'email']
106
+ else
107
+ self.email = nil
108
+ end
109
+
110
+ if attributes.key?(:'name')
111
+ self.name = attributes[:'name']
112
+ end
113
+
114
+ if attributes.key?(:'metadata')
115
+ self.metadata = attributes[:'metadata']
116
+ end
117
+
118
+ if attributes.key?(:'send_link')
119
+ self.send_link = attributes[:'send_link']
120
+ else
121
+ self.send_link = 'none'
122
+ end
123
+
124
+ if attributes.key?(:'redirect_url')
125
+ self.redirect_url = attributes[:'redirect_url']
126
+ end
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properties with the reasons
131
+ def list_invalid_properties
132
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
133
+ invalid_properties = Array.new
134
+ if @email.nil?
135
+ invalid_properties.push('invalid value for "email", email cannot be nil.')
136
+ end
137
+
138
+ invalid_properties
139
+ end
140
+
141
+ # Check to see if the all the properties in the model are valid
142
+ # @return true if the model is valid
143
+ def valid?
144
+ warn '[DEPRECATED] the `valid?` method is obsolete'
145
+ return false if @email.nil?
146
+ send_link_validator = EnumAttributeValidator.new('String', ["magic", "password_reset", "none"])
147
+ return false unless send_link_validator.valid?(@send_link)
148
+ true
149
+ end
150
+
151
+ # Custom attribute writer method with validation
152
+ # @param [Object] email Value to be assigned
153
+ def email=(email)
154
+ if email.nil?
155
+ fail ArgumentError, 'email cannot be nil'
156
+ end
157
+
158
+ @email = email
159
+ end
160
+
161
+ # Custom attribute writer method checking allowed values (enum).
162
+ # @param [Object] send_link Object to be assigned
163
+ def send_link=(send_link)
164
+ validator = EnumAttributeValidator.new('String', ["magic", "password_reset", "none"])
165
+ unless validator.valid?(send_link)
166
+ fail ArgumentError, "invalid value for \"send_link\", must be one of #{validator.allowable_values}."
167
+ end
168
+ @send_link = send_link
169
+ end
170
+
171
+ # Checks equality by comparing each attribute.
172
+ # @param [Object] Object to be compared
173
+ def ==(o)
174
+ return true if self.equal?(o)
175
+ self.class == o.class &&
176
+ email == o.email &&
177
+ name == o.name &&
178
+ metadata == o.metadata &&
179
+ send_link == o.send_link &&
180
+ redirect_url == o.redirect_url
181
+ end
182
+
183
+ # @see the `==` method
184
+ # @param [Object] Object to be compared
185
+ def eql?(o)
186
+ self == o
187
+ end
188
+
189
+ # Calculates hash code according to all attributes.
190
+ # @return [Integer] Hash code
191
+ def hash
192
+ [email, name, metadata, send_link, redirect_url].hash
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def self.build_from_hash(attributes)
199
+ return nil unless attributes.is_a?(Hash)
200
+ attributes = attributes.transform_keys(&:to_sym)
201
+ transformed_hash = {}
202
+ openapi_types.each_pair do |key, type|
203
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
204
+ transformed_hash["#{key}"] = nil
205
+ elsif type =~ /\AArray<(.*)>/i
206
+ # check to ensure the input is an array given that the attribute
207
+ # is documented as an array but the input is not
208
+ if attributes[attribute_map[key]].is_a?(Array)
209
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
210
+ end
211
+ elsif !attributes[attribute_map[key]].nil?
212
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
213
+ end
214
+ end
215
+ new(transformed_hash)
216
+ end
217
+
218
+ # Deserializes the data based on type
219
+ # @param string type Data type
220
+ # @param string value Value to be deserialized
221
+ # @return [Object] Deserialized data
222
+ def self._deserialize(type, value)
223
+ case type.to_sym
224
+ when :Time
225
+ Time.parse(value)
226
+ when :Date
227
+ Date.parse(value)
228
+ when :String
229
+ value.to_s
230
+ when :Integer
231
+ value.to_i
232
+ when :Float
233
+ value.to_f
234
+ when :Boolean
235
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
236
+ true
237
+ else
238
+ false
239
+ end
240
+ when :Object
241
+ # generic object (usually a Hash), return directly
242
+ value
243
+ when /\AArray<(?<inner_type>.+)>\z/
244
+ inner_type = Regexp.last_match[:inner_type]
245
+ value.map { |v| _deserialize(inner_type, v) }
246
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
247
+ k_type = Regexp.last_match[:k_type]
248
+ v_type = Regexp.last_match[:v_type]
249
+ {}.tap do |hash|
250
+ value.each do |k, v|
251
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
252
+ end
253
+ end
254
+ else # model
255
+ # models (e.g. Pet) or oneOf
256
+ klass = Zyphr.const_get(type)
257
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
258
+ end
259
+ end
260
+
261
+ # Returns the string representation of the object
262
+ # @return [String] String presentation of the object
263
+ def to_s
264
+ to_hash.to_s
265
+ end
266
+
267
+ # to_body is an alias to to_hash (backward compatibility)
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_body
270
+ to_hash
271
+ end
272
+
273
+ # Returns the object in the form of hash
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_hash
276
+ hash = {}
277
+ self.class.attribute_map.each_pair do |attr, param|
278
+ value = self.send(attr)
279
+ if value.nil?
280
+ is_nullable = self.class.openapi_nullable.include?(attr)
281
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
282
+ end
283
+
284
+ hash[param] = _to_hash(value)
285
+ end
286
+ hash
287
+ end
288
+
289
+ # Outputs non-array value in the form of hash
290
+ # For object, use to_hash. Otherwise, just return the value
291
+ # @param [Object] value Any valid value
292
+ # @return [Hash] Returns the value in the form of hash
293
+ def _to_hash(value)
294
+ if value.is_a?(Array)
295
+ value.compact.map { |v| _to_hash(v) }
296
+ elsif value.is_a?(Hash)
297
+ {}.tap do |hash|
298
+ value.each { |k, v| hash[k] = _to_hash(v) }
299
+ end
300
+ elsif value.respond_to? :to_hash
301
+ value.to_hash
302
+ else
303
+ value
304
+ end
305
+ end
306
+
307
+ end
308
+
309
+ end
@@ -0,0 +1,43 @@
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 ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class OAuthProviderName
18
+ GOOGLE = "google".freeze
19
+ APPLE = "apple".freeze
20
+ FACEBOOK = "facebook".freeze
21
+ GITHUB = "github".freeze
22
+ MICROSOFT = "microsoft".freeze
23
+
24
+ def self.all_vars
25
+ @all_vars ||= [GOOGLE, APPLE, FACEBOOK, GITHUB, MICROSOFT].freeze
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def self.build_from_hash(value)
32
+ new.build_from_hash(value)
33
+ end
34
+
35
+ # Builds the enum from string
36
+ # @param [String] The enum value in the form of the string
37
+ # @return [String] The enum value
38
+ def build_from_hash(value)
39
+ return value if OAuthProviderName.all_vars.include?(value)
40
+ raise "Invalid ENUM value #{value} for class #OAuthProviderName"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,220 @@
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 ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class SetEndUserClaimsRequest
18
+ attr_accessor :claims
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'claims' => :'claims'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'claims' => :'Object'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::SetEndUserClaimsRequest` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ acceptable_attribute_map = self.class.acceptable_attribute_map
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!acceptable_attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::SetEndUserClaimsRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'claims')
67
+ self.claims = attributes[:'claims']
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
75
+ invalid_properties = Array.new
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ warn '[DEPRECATED] the `valid?` method is obsolete'
83
+ true
84
+ end
85
+
86
+ # Checks equality by comparing each attribute.
87
+ # @param [Object] Object to be compared
88
+ def ==(o)
89
+ return true if self.equal?(o)
90
+ self.class == o.class &&
91
+ claims == o.claims
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(o)
97
+ self == o
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Integer] Hash code
102
+ def hash
103
+ [claims].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def self.build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ transformed_hash = {}
113
+ openapi_types.each_pair do |key, type|
114
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
115
+ transformed_hash["#{key}"] = nil
116
+ elsif type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[attribute_map[key]].is_a?(Array)
120
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
121
+ end
122
+ elsif !attributes[attribute_map[key]].nil?
123
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
124
+ end
125
+ end
126
+ new(transformed_hash)
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def self._deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = Zyphr.const_get(type)
168
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -23,12 +23,20 @@ module Zyphr
23
23
 
24
24
  attr_accessor :metadata
25
25
 
26
+ # Optional organization to scope the anonymous user into. Must exist in the key's environment. When set, the returned token carries org_id and orgs.
27
+ attr_accessor :organization_id
28
+
29
+ # Optional membership role for the org add. Requires organization_id. Opaque, up to 80 characters.
30
+ attr_accessor :organization_role
31
+
26
32
  # Attribute mapping from ruby-style variable name to JSON key.
27
33
  def self.attribute_map
28
34
  {
29
35
  :'device_id' => :'device_id',
30
36
  :'name' => :'name',
31
- :'metadata' => :'metadata'
37
+ :'metadata' => :'metadata',
38
+ :'organization_id' => :'organization_id',
39
+ :'organization_role' => :'organization_role'
32
40
  }
33
41
  end
34
42
 
@@ -47,7 +55,9 @@ module Zyphr
47
55
  {
48
56
  :'device_id' => :'String',
49
57
  :'name' => :'String',
50
- :'metadata' => :'Hash<String, Object>'
58
+ :'metadata' => :'Hash<String, Object>',
59
+ :'organization_id' => :'String',
60
+ :'organization_role' => :'String'
51
61
  }
52
62
  end
53
63
 
@@ -88,6 +98,14 @@ module Zyphr
88
98
  self.metadata = value
89
99
  end
90
100
  end
101
+
102
+ if attributes.key?(:'organization_id')
103
+ self.organization_id = attributes[:'organization_id']
104
+ end
105
+
106
+ if attributes.key?(:'organization_role')
107
+ self.organization_role = attributes[:'organization_role']
108
+ end
91
109
  end
92
110
 
93
111
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -111,6 +129,10 @@ module Zyphr
111
129
  invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 256.')
112
130
  end
113
131
 
132
+ if !@organization_role.nil? && @organization_role.to_s.length > 80
133
+ invalid_properties.push('invalid value for "organization_role", the character length must be smaller than or equal to 80.')
134
+ end
135
+
114
136
  invalid_properties
115
137
  end
116
138
 
@@ -122,6 +144,7 @@ module Zyphr
122
144
  return false if @device_id.to_s.length > 256
123
145
  return false if @device_id.to_s.length < 8
124
146
  return false if !@name.nil? && @name.to_s.length > 256
147
+ return false if !@organization_role.nil? && @organization_role.to_s.length > 80
125
148
  true
126
149
  end
127
150
 
@@ -157,6 +180,20 @@ module Zyphr
157
180
  @name = name
158
181
  end
159
182
 
183
+ # Custom attribute writer method with validation
184
+ # @param [Object] organization_role Value to be assigned
185
+ def organization_role=(organization_role)
186
+ if organization_role.nil?
187
+ fail ArgumentError, 'organization_role cannot be nil'
188
+ end
189
+
190
+ if organization_role.to_s.length > 80
191
+ fail ArgumentError, 'invalid value for "organization_role", the character length must be smaller than or equal to 80.'
192
+ end
193
+
194
+ @organization_role = organization_role
195
+ end
196
+
160
197
  # Checks equality by comparing each attribute.
161
198
  # @param [Object] Object to be compared
162
199
  def ==(o)
@@ -164,7 +201,9 @@ module Zyphr
164
201
  self.class == o.class &&
165
202
  device_id == o.device_id &&
166
203
  name == o.name &&
167
- metadata == o.metadata
204
+ metadata == o.metadata &&
205
+ organization_id == o.organization_id &&
206
+ organization_role == o.organization_role
168
207
  end
169
208
 
170
209
  # @see the `==` method
@@ -176,7 +215,7 @@ module Zyphr
176
215
  # Calculates hash code according to all attributes.
177
216
  # @return [Integer] Hash code
178
217
  def hash
179
- [device_id, name, metadata].hash
218
+ [device_id, name, metadata, organization_id, organization_role].hash
180
219
  end
181
220
 
182
221
  # Builds the object from hash