zyphr 0.1.23 → 0.1.25

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -0
  3. data/docs/AuthRegistrationApi.md +137 -0
  4. data/docs/AuthUser.md +6 -0
  5. data/docs/BatchRecipient.md +22 -0
  6. data/docs/ConvertAnonymousUserRequest.md +49 -0
  7. data/docs/ConvertAnonymousUserRequestOneOf.md +24 -0
  8. data/docs/ConvertAnonymousUserRequestOneOf1.md +24 -0
  9. data/docs/ConvertAnonymousUserRequestOneOf1AppleUser.md +18 -0
  10. data/docs/ConvertAnonymousUserRequestOneOf1AppleUserName.md +20 -0
  11. data/docs/CreateTemplateRequest.md +3 -3
  12. data/docs/EmailsApi.md +2 -2
  13. data/docs/SendBatchEmailRequest.md +20 -2
  14. data/docs/SignInAnonymouslyRequest.md +22 -0
  15. data/docs/TemplateResponse.md +3 -1
  16. data/docs/UpdateTemplateRequest.md +3 -3
  17. data/lib/zyphr/api/auth_registration_api.rb +136 -0
  18. data/lib/zyphr/api/emails_api.rb +2 -2
  19. data/lib/zyphr/models/auth_user.rb +33 -1
  20. data/lib/zyphr/models/batch_recipient.rb +258 -0
  21. data/lib/zyphr/models/convert_anonymous_user_request.rb +105 -0
  22. data/lib/zyphr/models/convert_anonymous_user_request_one_of.rb +323 -0
  23. data/lib/zyphr/models/convert_anonymous_user_request_one_of1.rb +324 -0
  24. data/lib/zyphr/models/convert_anonymous_user_request_one_of1_apple_user.rb +221 -0
  25. data/lib/zyphr/models/convert_anonymous_user_request_one_of1_apple_user_name.rb +229 -0
  26. data/lib/zyphr/models/create_template_request.rb +3 -3
  27. data/lib/zyphr/models/send_batch_email_request.rb +162 -22
  28. data/lib/zyphr/models/sign_in_anonymously_request.rb +296 -0
  29. data/lib/zyphr/models/template_response.rb +16 -4
  30. data/lib/zyphr/models/update_template_request.rb +3 -0
  31. data/lib/zyphr.rb +7 -0
  32. data/spec/api/auth_registration_api_spec.rb +24 -0
  33. data/spec/api/emails_api_spec.rb +1 -1
  34. data/spec/models/auth_user_spec.rb +18 -0
  35. data/spec/models/batch_recipient_spec.rb +48 -0
  36. data/spec/models/convert_anonymous_user_request_one_of1_apple_user_name_spec.rb +42 -0
  37. data/spec/models/convert_anonymous_user_request_one_of1_apple_user_spec.rb +36 -0
  38. data/spec/models/convert_anonymous_user_request_one_of1_spec.rb +58 -0
  39. data/spec/models/convert_anonymous_user_request_one_of_spec.rb +58 -0
  40. data/spec/models/convert_anonymous_user_request_spec.rb +32 -0
  41. data/spec/models/send_batch_email_request_spec.rb +55 -1
  42. data/spec/models/sign_in_anonymously_request_spec.rb +48 -0
  43. data/spec/models/template_response_spec.rb +6 -0
  44. data/zyphr.gemspec +1 -1
  45. metadata +391 -363
@@ -294,7 +294,7 @@ module Zyphr
294
294
  end
295
295
 
296
296
  # Send batch emails
297
- # Send up to 100 emails in a single request. Each recipient gets their own message record.
297
+ # Send a single email to up to 100 recipients in one request. Each recipient gets their own message record. Provide either raw content (`subject` plus `html` and/or `text`) or a `template_id` with `template_data`. Per-recipient `variables` are merged on top of the batch-level `template_data`.
298
298
  # @param send_batch_email_request [SendBatchEmailRequest]
299
299
  # @param [Hash] opts the optional parameters
300
300
  # @return [SendBatchEmailResponse]
@@ -304,7 +304,7 @@ module Zyphr
304
304
  end
305
305
 
306
306
  # Send batch emails
307
- # Send up to 100 emails in a single request. Each recipient gets their own message record.
307
+ # Send a single email to up to 100 recipients in one request. Each recipient gets their own message record. Provide either raw content (`subject` plus `html` and/or `text`) or a `template_id` with `template_data`. Per-recipient `variables` are merged on top of the batch-level `template_data`.
308
308
  # @param send_batch_email_request [SendBatchEmailRequest]
309
309
  # @param [Hash] opts the optional parameters
310
310
  # @return [Array<(SendBatchEmailResponse, Integer, Hash)>] SendBatchEmailResponse data, response status code and response headers
@@ -35,6 +35,15 @@ module Zyphr
35
35
 
36
36
  attr_accessor :mfa_enabled
37
37
 
38
+ # True if the user signed in anonymously and has not yet been converted to a full account.
39
+ attr_accessor :is_anonymous
40
+
41
+ # Per-device identifier supplied at anonymous sign-in. Preserved across conversion so client-side \"this device has scores from me\" detection survives the upgrade. NULL for users who never signed in anonymously.
42
+ attr_accessor :anonymous_device_id
43
+
44
+ # Set on the user's first authenticated request after anonymous sign-in (excluding /auth/refresh). MAU billing for anonymous-origin users keys off this timestamp instead of created_at.
45
+ attr_accessor :first_activity_at
46
+
38
47
  attr_accessor :created_at
39
48
 
40
49
  attr_accessor :updated_at
@@ -76,6 +85,9 @@ module Zyphr
76
85
  :'phone_verified' => :'phone_verified',
77
86
  :'status' => :'status',
78
87
  :'mfa_enabled' => :'mfa_enabled',
88
+ :'is_anonymous' => :'is_anonymous',
89
+ :'anonymous_device_id' => :'anonymous_device_id',
90
+ :'first_activity_at' => :'first_activity_at',
79
91
  :'created_at' => :'created_at',
80
92
  :'updated_at' => :'updated_at',
81
93
  :'last_login_at' => :'last_login_at'
@@ -105,6 +117,9 @@ module Zyphr
105
117
  :'phone_verified' => :'Boolean',
106
118
  :'status' => :'String',
107
119
  :'mfa_enabled' => :'Boolean',
120
+ :'is_anonymous' => :'Boolean',
121
+ :'anonymous_device_id' => :'String',
122
+ :'first_activity_at' => :'Time',
108
123
  :'created_at' => :'Time',
109
124
  :'updated_at' => :'Time',
110
125
  :'last_login_at' => :'Time'
@@ -118,6 +133,8 @@ module Zyphr
118
133
  :'name',
119
134
  :'avatar_url',
120
135
  :'phone_number',
136
+ :'anonymous_device_id',
137
+ :'first_activity_at',
121
138
  :'last_login_at'
122
139
  ])
123
140
  end
@@ -180,6 +197,18 @@ module Zyphr
180
197
  self.mfa_enabled = attributes[:'mfa_enabled']
181
198
  end
182
199
 
200
+ if attributes.key?(:'is_anonymous')
201
+ self.is_anonymous = attributes[:'is_anonymous']
202
+ end
203
+
204
+ if attributes.key?(:'anonymous_device_id')
205
+ self.anonymous_device_id = attributes[:'anonymous_device_id']
206
+ end
207
+
208
+ if attributes.key?(:'first_activity_at')
209
+ self.first_activity_at = attributes[:'first_activity_at']
210
+ end
211
+
183
212
  if attributes.key?(:'created_at')
184
213
  self.created_at = attributes[:'created_at']
185
214
  end
@@ -235,6 +264,9 @@ module Zyphr
235
264
  phone_verified == o.phone_verified &&
236
265
  status == o.status &&
237
266
  mfa_enabled == o.mfa_enabled &&
267
+ is_anonymous == o.is_anonymous &&
268
+ anonymous_device_id == o.anonymous_device_id &&
269
+ first_activity_at == o.first_activity_at &&
238
270
  created_at == o.created_at &&
239
271
  updated_at == o.updated_at &&
240
272
  last_login_at == o.last_login_at
@@ -249,7 +281,7 @@ module Zyphr
249
281
  # Calculates hash code according to all attributes.
250
282
  # @return [Integer] Hash code
251
283
  def hash
252
- [id, email, name, email_verified, avatar_url, metadata, phone_number, phone_verified, status, mfa_enabled, created_at, updated_at, last_login_at].hash
284
+ [id, email, name, email_verified, avatar_url, metadata, phone_number, phone_verified, status, mfa_enabled, is_anonymous, anonymous_device_id, first_activity_at, created_at, updated_at, last_login_at].hash
253
285
  end
254
286
 
255
287
  # Builds the object from hash
@@ -0,0 +1,258 @@
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 BatchRecipient
18
+ attr_accessor :email
19
+
20
+ attr_accessor :name
21
+
22
+ # Per-recipient template variables. Merged on top of the batch-level `template_data`, so per-recipient values win on key collisions.
23
+ attr_accessor :variables
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'email' => :'email',
29
+ :'name' => :'name',
30
+ :'variables' => :'variables'
31
+ }
32
+ end
33
+
34
+ # Returns attribute mapping this model knows about
35
+ def self.acceptable_attribute_map
36
+ attribute_map
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ acceptable_attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'email' => :'String',
48
+ :'name' => :'String',
49
+ :'variables' => :'Hash<String, Object>'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::BatchRecipient` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ acceptable_attribute_map = self.class.acceptable_attribute_map
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!acceptable_attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::BatchRecipient`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'email')
76
+ self.email = attributes[:'email']
77
+ else
78
+ self.email = nil
79
+ end
80
+
81
+ if attributes.key?(:'name')
82
+ self.name = attributes[:'name']
83
+ end
84
+
85
+ if attributes.key?(:'variables')
86
+ if (value = attributes[:'variables']).is_a?(Hash)
87
+ self.variables = value
88
+ end
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
96
+ invalid_properties = Array.new
97
+ if @email.nil?
98
+ invalid_properties.push('invalid value for "email", email cannot be nil.')
99
+ end
100
+
101
+ invalid_properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ warn '[DEPRECATED] the `valid?` method is obsolete'
108
+ return false if @email.nil?
109
+ true
110
+ end
111
+
112
+ # Custom attribute writer method with validation
113
+ # @param [Object] email Value to be assigned
114
+ def email=(email)
115
+ if email.nil?
116
+ fail ArgumentError, 'email cannot be nil'
117
+ end
118
+
119
+ @email = email
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ email == o.email &&
128
+ name == o.name &&
129
+ variables == o.variables
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [email, name, variables].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ transformed_hash = {}
151
+ openapi_types.each_pair do |key, type|
152
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = nil
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[attribute_map[key]].is_a?(Array)
158
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
159
+ end
160
+ elsif !attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
162
+ end
163
+ end
164
+ new(transformed_hash)
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def self._deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = Zyphr.const_get(type)
206
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end
@@ -0,0 +1,105 @@
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
+ module ConvertAnonymousUserRequest
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'ConvertAnonymousUserRequestOneOf',
23
+ :'ConvertAnonymousUserRequestOneOf1'
24
+ ]
25
+ end
26
+
27
+ # Builds the object
28
+ # @param [Mixed] Data to be matched against the list of oneOf items
29
+ # @return [Object] Returns the model or the data itself
30
+ def build(data)
31
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
32
+ # Note:
33
+ # - We do not attempt to check whether exactly one item matches.
34
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
+ # - TODO: scalar values are de facto behaving as if they were nullable.
37
+ # - TODO: logging when debugging is set.
38
+ openapi_one_of.each do |klass|
39
+ begin
40
+ next if klass == :AnyType # "nullable: true"
41
+ typed_data = find_and_cast_into_type(klass, data)
42
+ return typed_data if typed_data
43
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
44
+ end
45
+ end
46
+
47
+ openapi_one_of.include?(:AnyType) ? data : nil
48
+ end
49
+
50
+ private
51
+
52
+ SchemaMismatchError = Class.new(StandardError)
53
+
54
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
55
+ def find_and_cast_into_type(klass, data)
56
+ return if data.nil?
57
+
58
+ case klass.to_s
59
+ when 'Boolean'
60
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
61
+ when 'Float'
62
+ return data if data.instance_of?(Float)
63
+ when 'Integer'
64
+ return data if data.instance_of?(Integer)
65
+ when 'Time'
66
+ return Time.parse(data)
67
+ when 'Date'
68
+ return Date.parse(data)
69
+ when 'String'
70
+ return data if data.instance_of?(String)
71
+ when 'Object' # "type: object"
72
+ return data if data.instance_of?(Hash)
73
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
74
+ if data.instance_of?(Array)
75
+ sub_type = Regexp.last_match[:sub_type]
76
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
77
+ end
78
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
79
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
80
+ sub_type = Regexp.last_match[:sub_type]
81
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
82
+ end
83
+ else # model
84
+ const = Zyphr.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
87
+ model = const.build(data)
88
+ return model if model
89
+ else
90
+ # raise if data contains keys that are not known to the model
91
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
92
+ model = const.build_from_hash(data)
93
+ return model if model
94
+ end
95
+ end
96
+ end
97
+
98
+ raise # if no match by now, raise
99
+ rescue
100
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
101
+ end
102
+ end
103
+ end
104
+
105
+ end