zyphr 0.1.80 → 0.1.81
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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/docs/AuthEmailTemplate.md +0 -2
- data/docs/AuthEmailTemplatePreviewDraft.md +0 -2
- data/docs/AuthEmailTemplateVersion.md +0 -2
- data/docs/AuthEmailTemplatesApi.md +2 -2
- data/docs/CreateTemplateRequest.md +12 -4
- data/docs/Template.md +8 -0
- data/docs/TemplateClassification.md +15 -0
- data/docs/TemplateEditorType.md +15 -0
- data/docs/TemplatesApi.md +1 -1
- data/docs/UpdateTemplateRequest.md +9 -3
- data/docs/UpsertAuthEmailTemplateRequest.md +0 -2
- data/lib/zyphr/api/auth_email_templates_api.rb +4 -4
- data/lib/zyphr/api/templates_api.rb +2 -2
- data/lib/zyphr/models/auth_email_template.rb +3 -13
- data/lib/zyphr/models/auth_email_template_preview_draft.rb +1 -11
- data/lib/zyphr/models/auth_email_template_version.rb +3 -13
- data/lib/zyphr/models/create_template_request.rb +87 -7
- data/lib/zyphr/models/template.rb +78 -1
- data/lib/zyphr/models/template_classification.rb +40 -0
- data/lib/zyphr/models/template_editor_type.rb +40 -0
- data/lib/zyphr/models/update_template_request.rb +62 -6
- data/lib/zyphr/models/upsert_auth_email_template_request.rb +4 -14
- data/lib/zyphr.rb +2 -0
- data/spec/api/auth_email_templates_api_spec.rb +2 -2
- data/spec/api/templates_api_spec.rb +1 -1
- data/spec/models/auth_email_template_preview_draft_spec.rb +0 -6
- data/spec/models/auth_email_template_spec.rb +1 -7
- data/spec/models/auth_email_template_version_spec.rb +1 -7
- data/spec/models/create_template_request_spec.rb +28 -0
- data/spec/models/template_classification_spec.rb +30 -0
- data/spec/models/template_editor_type_spec.rb +30 -0
- data/spec/models/template_spec.rb +28 -0
- data/spec/models/update_template_request_spec.rb +18 -0
- data/spec/models/upsert_auth_email_template_request_spec.rb +1 -7
- data/zyphr.gemspec +1 -1
- metadata +10 -2
|
@@ -20,23 +20,59 @@ module Zyphr
|
|
|
20
20
|
|
|
21
21
|
attr_accessor :description
|
|
22
22
|
|
|
23
|
-
#
|
|
23
|
+
# Channel the template is for. Set on create only; it cannot be changed later. Names are unique per channel within a project.
|
|
24
|
+
attr_accessor :channel
|
|
25
|
+
|
|
26
|
+
# Email subject line (push: the notification title). Supports Handlebars `{{var}}` interpolation. Values are inserted as written, not HTML-escaped: the subject is not HTML.
|
|
24
27
|
attr_accessor :subject
|
|
25
28
|
|
|
26
|
-
# HTML body. Supports Handlebars `{{var}}` interpolation; values are always HTML-escaped on render. **Triple-brace `{{{var}}}` (raw HTML output) is not supported** for XSS-prevention reasons — input containing `{{{var}}}` is rewritten to `{{var}}` on save and the response includes a top-level `warnings` array describing what changed. To inject pre-rendered HTML, render the entire `html` field outside Zyphr and POST it to `/v1/email/send` directly without `template_id`.
|
|
29
|
+
# HTML body. Supports Handlebars `{{var}}` interpolation; values are always HTML-escaped on render (the subject and text are not). **Triple-brace `{{{var}}}` (raw HTML output) is not supported** for XSS-prevention reasons — input containing `{{{var}}}` is rewritten to `{{var}}` on save and the response includes a top-level `warnings` array describing what changed. To inject pre-rendered HTML, render the entire `html` field outside Zyphr and POST it to `/v1/email/send` directly without `template_id`.
|
|
27
30
|
attr_accessor :html
|
|
28
31
|
|
|
29
|
-
# Plain text body. Supports Handlebars `{{var}}` interpolation
|
|
32
|
+
# Plain text body (SMS and push: the message body). Supports Handlebars `{{var}}` interpolation. Values are inserted as written, not HTML-escaped. Triple-brace syntax is rewritten to double-brace on save (same policy as the `html` field).
|
|
30
33
|
attr_accessor :text
|
|
31
34
|
|
|
35
|
+
# The visual editor's document, stored so the template can be reopened in the editor. At most 1 MB. Sending always uses `html`. A document with `\"format\": \"zyphr-email/1\"` (from the current visual editor) is exported to `html` by the API when it is saved, replacing any `html` sent with it, and a document that can't be exported is rejected with 400. Other documents are stored as given and never rendered.
|
|
36
|
+
attr_accessor :design_json
|
|
37
|
+
|
|
38
|
+
attr_accessor :editor_type
|
|
39
|
+
|
|
40
|
+
attr_accessor :classification
|
|
41
|
+
|
|
42
|
+
class EnumAttributeValidator
|
|
43
|
+
attr_reader :datatype
|
|
44
|
+
attr_reader :allowable_values
|
|
45
|
+
|
|
46
|
+
def initialize(datatype, allowable_values)
|
|
47
|
+
@allowable_values = allowable_values.map do |value|
|
|
48
|
+
case datatype.to_s
|
|
49
|
+
when /Integer/i
|
|
50
|
+
value.to_i
|
|
51
|
+
when /Float/i
|
|
52
|
+
value.to_f
|
|
53
|
+
else
|
|
54
|
+
value
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def valid?(value)
|
|
60
|
+
!value || allowable_values.include?(value)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
32
64
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
33
65
|
def self.attribute_map
|
|
34
66
|
{
|
|
35
67
|
:'name' => :'name',
|
|
36
68
|
:'description' => :'description',
|
|
69
|
+
:'channel' => :'channel',
|
|
37
70
|
:'subject' => :'subject',
|
|
38
71
|
:'html' => :'html',
|
|
39
|
-
:'text' => :'text'
|
|
72
|
+
:'text' => :'text',
|
|
73
|
+
:'design_json' => :'design_json',
|
|
74
|
+
:'editor_type' => :'editor_type',
|
|
75
|
+
:'classification' => :'classification'
|
|
40
76
|
}
|
|
41
77
|
end
|
|
42
78
|
|
|
@@ -55,15 +91,21 @@ module Zyphr
|
|
|
55
91
|
{
|
|
56
92
|
:'name' => :'String',
|
|
57
93
|
:'description' => :'String',
|
|
94
|
+
:'channel' => :'String',
|
|
58
95
|
:'subject' => :'String',
|
|
59
96
|
:'html' => :'String',
|
|
60
|
-
:'text' => :'String'
|
|
97
|
+
:'text' => :'String',
|
|
98
|
+
:'design_json' => :'Hash<String, Object>',
|
|
99
|
+
:'editor_type' => :'TemplateEditorType',
|
|
100
|
+
:'classification' => :'TemplateClassification'
|
|
61
101
|
}
|
|
62
102
|
end
|
|
63
103
|
|
|
64
104
|
# List of attributes with nullable: true
|
|
65
105
|
def self.openapi_nullable
|
|
66
106
|
Set.new([
|
|
107
|
+
:'design_json',
|
|
108
|
+
:'classification'
|
|
67
109
|
])
|
|
68
110
|
end
|
|
69
111
|
|
|
@@ -93,6 +135,12 @@ module Zyphr
|
|
|
93
135
|
self.description = attributes[:'description']
|
|
94
136
|
end
|
|
95
137
|
|
|
138
|
+
if attributes.key?(:'channel')
|
|
139
|
+
self.channel = attributes[:'channel']
|
|
140
|
+
else
|
|
141
|
+
self.channel = 'email'
|
|
142
|
+
end
|
|
143
|
+
|
|
96
144
|
if attributes.key?(:'subject')
|
|
97
145
|
self.subject = attributes[:'subject']
|
|
98
146
|
end
|
|
@@ -104,6 +152,22 @@ module Zyphr
|
|
|
104
152
|
if attributes.key?(:'text')
|
|
105
153
|
self.text = attributes[:'text']
|
|
106
154
|
end
|
|
155
|
+
|
|
156
|
+
if attributes.key?(:'design_json')
|
|
157
|
+
if (value = attributes[:'design_json']).is_a?(Hash)
|
|
158
|
+
self.design_json = value
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if attributes.key?(:'editor_type')
|
|
163
|
+
self.editor_type = attributes[:'editor_type']
|
|
164
|
+
else
|
|
165
|
+
self.editor_type = 'code'
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
if attributes.key?(:'classification')
|
|
169
|
+
self.classification = attributes[:'classification']
|
|
170
|
+
end
|
|
107
171
|
end
|
|
108
172
|
|
|
109
173
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -129,6 +193,8 @@ module Zyphr
|
|
|
129
193
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
130
194
|
return false if @name.nil?
|
|
131
195
|
return false if @name !~ Regexp.new(/^[a-zA-Z0-9_-]+$/)
|
|
196
|
+
channel_validator = EnumAttributeValidator.new('String', ["email", "sms", "push"])
|
|
197
|
+
return false unless channel_validator.valid?(@channel)
|
|
132
198
|
true
|
|
133
199
|
end
|
|
134
200
|
|
|
@@ -147,6 +213,16 @@ module Zyphr
|
|
|
147
213
|
@name = name
|
|
148
214
|
end
|
|
149
215
|
|
|
216
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
217
|
+
# @param [Object] channel Object to be assigned
|
|
218
|
+
def channel=(channel)
|
|
219
|
+
validator = EnumAttributeValidator.new('String', ["email", "sms", "push"])
|
|
220
|
+
unless validator.valid?(channel)
|
|
221
|
+
fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}."
|
|
222
|
+
end
|
|
223
|
+
@channel = channel
|
|
224
|
+
end
|
|
225
|
+
|
|
150
226
|
# Checks equality by comparing each attribute.
|
|
151
227
|
# @param [Object] Object to be compared
|
|
152
228
|
def ==(o)
|
|
@@ -154,9 +230,13 @@ module Zyphr
|
|
|
154
230
|
self.class == o.class &&
|
|
155
231
|
name == o.name &&
|
|
156
232
|
description == o.description &&
|
|
233
|
+
channel == o.channel &&
|
|
157
234
|
subject == o.subject &&
|
|
158
235
|
html == o.html &&
|
|
159
|
-
text == o.text
|
|
236
|
+
text == o.text &&
|
|
237
|
+
design_json == o.design_json &&
|
|
238
|
+
editor_type == o.editor_type &&
|
|
239
|
+
classification == o.classification
|
|
160
240
|
end
|
|
161
241
|
|
|
162
242
|
# @see the `==` method
|
|
@@ -168,7 +248,7 @@ module Zyphr
|
|
|
168
248
|
# Calculates hash code according to all attributes.
|
|
169
249
|
# @return [Integer] Hash code
|
|
170
250
|
def hash
|
|
171
|
-
[name, description, subject, html, text].hash
|
|
251
|
+
[name, description, channel, subject, html, text, design_json, editor_type, classification].hash
|
|
172
252
|
end
|
|
173
253
|
|
|
174
254
|
# Builds the object from hash
|
|
@@ -19,6 +19,8 @@ module Zyphr
|
|
|
19
19
|
|
|
20
20
|
attr_accessor :name
|
|
21
21
|
|
|
22
|
+
attr_accessor :channel
|
|
23
|
+
|
|
22
24
|
attr_accessor :description
|
|
23
25
|
|
|
24
26
|
attr_accessor :subject
|
|
@@ -32,21 +34,54 @@ module Zyphr
|
|
|
32
34
|
|
|
33
35
|
attr_accessor :version
|
|
34
36
|
|
|
37
|
+
# Omitted from list responses, which also omit `html` and `text`.
|
|
38
|
+
attr_accessor :design_json
|
|
39
|
+
|
|
40
|
+
attr_accessor :editor_type
|
|
41
|
+
|
|
42
|
+
attr_accessor :classification
|
|
43
|
+
|
|
35
44
|
attr_accessor :created_at
|
|
36
45
|
|
|
37
46
|
attr_accessor :updated_at
|
|
38
47
|
|
|
48
|
+
class EnumAttributeValidator
|
|
49
|
+
attr_reader :datatype
|
|
50
|
+
attr_reader :allowable_values
|
|
51
|
+
|
|
52
|
+
def initialize(datatype, allowable_values)
|
|
53
|
+
@allowable_values = allowable_values.map do |value|
|
|
54
|
+
case datatype.to_s
|
|
55
|
+
when /Integer/i
|
|
56
|
+
value.to_i
|
|
57
|
+
when /Float/i
|
|
58
|
+
value.to_f
|
|
59
|
+
else
|
|
60
|
+
value
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def valid?(value)
|
|
66
|
+
!value || allowable_values.include?(value)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
39
70
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
40
71
|
def self.attribute_map
|
|
41
72
|
{
|
|
42
73
|
:'id' => :'id',
|
|
43
74
|
:'name' => :'name',
|
|
75
|
+
:'channel' => :'channel',
|
|
44
76
|
:'description' => :'description',
|
|
45
77
|
:'subject' => :'subject',
|
|
46
78
|
:'html' => :'html',
|
|
47
79
|
:'text' => :'text',
|
|
48
80
|
:'variables' => :'variables',
|
|
49
81
|
:'version' => :'version',
|
|
82
|
+
:'design_json' => :'design_json',
|
|
83
|
+
:'editor_type' => :'editor_type',
|
|
84
|
+
:'classification' => :'classification',
|
|
50
85
|
:'created_at' => :'created_at',
|
|
51
86
|
:'updated_at' => :'updated_at'
|
|
52
87
|
}
|
|
@@ -67,12 +102,16 @@ module Zyphr
|
|
|
67
102
|
{
|
|
68
103
|
:'id' => :'String',
|
|
69
104
|
:'name' => :'String',
|
|
105
|
+
:'channel' => :'String',
|
|
70
106
|
:'description' => :'String',
|
|
71
107
|
:'subject' => :'String',
|
|
72
108
|
:'html' => :'String',
|
|
73
109
|
:'text' => :'String',
|
|
74
110
|
:'variables' => :'Array<String>',
|
|
75
111
|
:'version' => :'Integer',
|
|
112
|
+
:'design_json' => :'Hash<String, Object>',
|
|
113
|
+
:'editor_type' => :'TemplateEditorType',
|
|
114
|
+
:'classification' => :'TemplateClassification',
|
|
76
115
|
:'created_at' => :'Time',
|
|
77
116
|
:'updated_at' => :'Time'
|
|
78
117
|
}
|
|
@@ -86,6 +125,8 @@ module Zyphr
|
|
|
86
125
|
:'html',
|
|
87
126
|
:'text',
|
|
88
127
|
:'variables',
|
|
128
|
+
:'design_json',
|
|
129
|
+
:'classification',
|
|
89
130
|
])
|
|
90
131
|
end
|
|
91
132
|
|
|
@@ -113,6 +154,10 @@ module Zyphr
|
|
|
113
154
|
self.name = attributes[:'name']
|
|
114
155
|
end
|
|
115
156
|
|
|
157
|
+
if attributes.key?(:'channel')
|
|
158
|
+
self.channel = attributes[:'channel']
|
|
159
|
+
end
|
|
160
|
+
|
|
116
161
|
if attributes.key?(:'description')
|
|
117
162
|
self.description = attributes[:'description']
|
|
118
163
|
end
|
|
@@ -139,6 +184,22 @@ module Zyphr
|
|
|
139
184
|
self.version = attributes[:'version']
|
|
140
185
|
end
|
|
141
186
|
|
|
187
|
+
if attributes.key?(:'design_json')
|
|
188
|
+
if (value = attributes[:'design_json']).is_a?(Hash)
|
|
189
|
+
self.design_json = value
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
if attributes.key?(:'editor_type')
|
|
194
|
+
self.editor_type = attributes[:'editor_type']
|
|
195
|
+
else
|
|
196
|
+
self.editor_type = 'code'
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
if attributes.key?(:'classification')
|
|
200
|
+
self.classification = attributes[:'classification']
|
|
201
|
+
end
|
|
202
|
+
|
|
142
203
|
if attributes.key?(:'created_at')
|
|
143
204
|
self.created_at = attributes[:'created_at']
|
|
144
205
|
end
|
|
@@ -160,9 +221,21 @@ module Zyphr
|
|
|
160
221
|
# @return true if the model is valid
|
|
161
222
|
def valid?
|
|
162
223
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
224
|
+
channel_validator = EnumAttributeValidator.new('String', ["email", "sms", "push"])
|
|
225
|
+
return false unless channel_validator.valid?(@channel)
|
|
163
226
|
true
|
|
164
227
|
end
|
|
165
228
|
|
|
229
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
230
|
+
# @param [Object] channel Object to be assigned
|
|
231
|
+
def channel=(channel)
|
|
232
|
+
validator = EnumAttributeValidator.new('String', ["email", "sms", "push"])
|
|
233
|
+
unless validator.valid?(channel)
|
|
234
|
+
fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}."
|
|
235
|
+
end
|
|
236
|
+
@channel = channel
|
|
237
|
+
end
|
|
238
|
+
|
|
166
239
|
# Checks equality by comparing each attribute.
|
|
167
240
|
# @param [Object] Object to be compared
|
|
168
241
|
def ==(o)
|
|
@@ -170,12 +243,16 @@ module Zyphr
|
|
|
170
243
|
self.class == o.class &&
|
|
171
244
|
id == o.id &&
|
|
172
245
|
name == o.name &&
|
|
246
|
+
channel == o.channel &&
|
|
173
247
|
description == o.description &&
|
|
174
248
|
subject == o.subject &&
|
|
175
249
|
html == o.html &&
|
|
176
250
|
text == o.text &&
|
|
177
251
|
variables == o.variables &&
|
|
178
252
|
version == o.version &&
|
|
253
|
+
design_json == o.design_json &&
|
|
254
|
+
editor_type == o.editor_type &&
|
|
255
|
+
classification == o.classification &&
|
|
179
256
|
created_at == o.created_at &&
|
|
180
257
|
updated_at == o.updated_at
|
|
181
258
|
end
|
|
@@ -189,7 +266,7 @@ module Zyphr
|
|
|
189
266
|
# Calculates hash code according to all attributes.
|
|
190
267
|
# @return [Integer] Hash code
|
|
191
268
|
def hash
|
|
192
|
-
[id, name, description, subject, html, text, variables, version, created_at, updated_at].hash
|
|
269
|
+
[id, name, channel, description, subject, html, text, variables, version, design_json, editor_type, classification, created_at, updated_at].hash
|
|
193
270
|
end
|
|
194
271
|
|
|
195
272
|
# Builds the object from hash
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Zyphr API
|
|
3
|
+
|
|
4
|
+
#Zyphr is a developer platform for user authentication and transactional messaging. One API covers auth (passkeys, social sign-in, passwordless, MFA, sessions, organizations) plus email, push notifications, SMS, in-app messages, and webhooks. ## 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. > **Test keys are being retired.** `zy_test_*` keys are no longer issued, and existing ones stop working on **21 October 2026**. They never delivered mail — sends were mocked and marked sent without reaching a provider, so they could not verify domain authentication, rendering, or deliverability. To test your integration, use a `zy_live_*` key against a verified domain and send to an address you control. ## 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 TemplateClassification
|
|
18
|
+
TRANSACTIONAL = "transactional".freeze
|
|
19
|
+
MARKETING = "marketing".freeze
|
|
20
|
+
|
|
21
|
+
def self.all_vars
|
|
22
|
+
@all_vars ||= [TRANSACTIONAL, MARKETING].freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Builds the enum from string
|
|
26
|
+
# @param [String] The enum value in the form of the string
|
|
27
|
+
# @return [String] The enum value
|
|
28
|
+
def self.build_from_hash(value)
|
|
29
|
+
new.build_from_hash(value)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Builds the enum from string
|
|
33
|
+
# @param [String] The enum value in the form of the string
|
|
34
|
+
# @return [String] The enum value
|
|
35
|
+
def build_from_hash(value)
|
|
36
|
+
return value if TemplateClassification.all_vars.include?(value)
|
|
37
|
+
raise "Invalid ENUM value #{value} for class #TemplateClassification"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Zyphr API
|
|
3
|
+
|
|
4
|
+
#Zyphr is a developer platform for user authentication and transactional messaging. One API covers auth (passkeys, social sign-in, passwordless, MFA, sessions, organizations) plus email, push notifications, SMS, in-app messages, and webhooks. ## 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. > **Test keys are being retired.** `zy_test_*` keys are no longer issued, and existing ones stop working on **21 October 2026**. They never delivered mail — sends were mocked and marked sent without reaching a provider, so they could not verify domain authentication, rendering, or deliverability. To test your integration, use a `zy_live_*` key against a verified domain and send to an address you control. ## 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 TemplateEditorType
|
|
18
|
+
CODE = "code".freeze
|
|
19
|
+
VISUAL = "visual".freeze
|
|
20
|
+
|
|
21
|
+
def self.all_vars
|
|
22
|
+
@all_vars ||= [CODE, VISUAL].freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Builds the enum from string
|
|
26
|
+
# @param [String] The enum value in the form of the string
|
|
27
|
+
# @return [String] The enum value
|
|
28
|
+
def self.build_from_hash(value)
|
|
29
|
+
new.build_from_hash(value)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Builds the enum from string
|
|
33
|
+
# @param [String] The enum value in the form of the string
|
|
34
|
+
# @return [String] The enum value
|
|
35
|
+
def build_from_hash(value)
|
|
36
|
+
return value if TemplateEditorType.all_vars.include?(value)
|
|
37
|
+
raise "Invalid ENUM value #{value} for class #TemplateEditorType"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -19,15 +19,44 @@ module Zyphr
|
|
|
19
19
|
|
|
20
20
|
attr_accessor :description
|
|
21
21
|
|
|
22
|
-
# Email subject line. Supports Handlebars `{{var}}` interpolation
|
|
22
|
+
# Email subject line (push: the notification title). Supports Handlebars `{{var}}` interpolation; values are not HTML-escaped.
|
|
23
23
|
attr_accessor :subject
|
|
24
24
|
|
|
25
25
|
# HTML body. Supports Handlebars `{{var}}` interpolation; values are always HTML-escaped on render. Triple-brace `{{{var}}}` is not supported — input is rewritten to `{{var}}` on save and the response includes a top-level `warnings` array describing the rewrite. See `CreateTemplateRequest.html` for full rationale.
|
|
26
26
|
attr_accessor :html
|
|
27
27
|
|
|
28
|
-
# Plain text body. Supports Handlebars `{{var}}` interpolation;
|
|
28
|
+
# Plain text body. Supports Handlebars `{{var}}` interpolation; values are not HTML-escaped. Same triple-brace rewrite policy as `html`.
|
|
29
29
|
attr_accessor :text
|
|
30
30
|
|
|
31
|
+
# The visual editor's document, stored so the template can be reopened in the editor. At most 1 MB. Sending always uses `html`. A document with `\"format\": \"zyphr-email/1\"` (from the current visual editor) is exported to `html` by the API when it is saved, replacing any `html` sent with it, and a document that can't be exported is rejected with 400. Other documents are stored as given and never rendered.
|
|
32
|
+
attr_accessor :design_json
|
|
33
|
+
|
|
34
|
+
attr_accessor :editor_type
|
|
35
|
+
|
|
36
|
+
attr_accessor :classification
|
|
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
|
+
|
|
31
60
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
32
61
|
def self.attribute_map
|
|
33
62
|
{
|
|
@@ -35,7 +64,10 @@ module Zyphr
|
|
|
35
64
|
:'description' => :'description',
|
|
36
65
|
:'subject' => :'subject',
|
|
37
66
|
:'html' => :'html',
|
|
38
|
-
:'text' => :'text'
|
|
67
|
+
:'text' => :'text',
|
|
68
|
+
:'design_json' => :'design_json',
|
|
69
|
+
:'editor_type' => :'editor_type',
|
|
70
|
+
:'classification' => :'classification'
|
|
39
71
|
}
|
|
40
72
|
end
|
|
41
73
|
|
|
@@ -56,13 +88,18 @@ module Zyphr
|
|
|
56
88
|
:'description' => :'String',
|
|
57
89
|
:'subject' => :'String',
|
|
58
90
|
:'html' => :'String',
|
|
59
|
-
:'text' => :'String'
|
|
91
|
+
:'text' => :'String',
|
|
92
|
+
:'design_json' => :'Hash<String, Object>',
|
|
93
|
+
:'editor_type' => :'TemplateEditorType',
|
|
94
|
+
:'classification' => :'TemplateClassification'
|
|
60
95
|
}
|
|
61
96
|
end
|
|
62
97
|
|
|
63
98
|
# List of attributes with nullable: true
|
|
64
99
|
def self.openapi_nullable
|
|
65
100
|
Set.new([
|
|
101
|
+
:'design_json',
|
|
102
|
+
:'classification'
|
|
66
103
|
])
|
|
67
104
|
end
|
|
68
105
|
|
|
@@ -101,6 +138,22 @@ module Zyphr
|
|
|
101
138
|
if attributes.key?(:'text')
|
|
102
139
|
self.text = attributes[:'text']
|
|
103
140
|
end
|
|
141
|
+
|
|
142
|
+
if attributes.key?(:'design_json')
|
|
143
|
+
if (value = attributes[:'design_json']).is_a?(Hash)
|
|
144
|
+
self.design_json = value
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
if attributes.key?(:'editor_type')
|
|
149
|
+
self.editor_type = attributes[:'editor_type']
|
|
150
|
+
else
|
|
151
|
+
self.editor_type = 'code'
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
if attributes.key?(:'classification')
|
|
155
|
+
self.classification = attributes[:'classification']
|
|
156
|
+
end
|
|
104
157
|
end
|
|
105
158
|
|
|
106
159
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -148,7 +201,10 @@ module Zyphr
|
|
|
148
201
|
description == o.description &&
|
|
149
202
|
subject == o.subject &&
|
|
150
203
|
html == o.html &&
|
|
151
|
-
text == o.text
|
|
204
|
+
text == o.text &&
|
|
205
|
+
design_json == o.design_json &&
|
|
206
|
+
editor_type == o.editor_type &&
|
|
207
|
+
classification == o.classification
|
|
152
208
|
end
|
|
153
209
|
|
|
154
210
|
# @see the `==` method
|
|
@@ -160,7 +216,7 @@ module Zyphr
|
|
|
160
216
|
# Calculates hash code according to all attributes.
|
|
161
217
|
# @return [Integer] Hash code
|
|
162
218
|
def hash
|
|
163
|
-
[name, description, subject, html, text].hash
|
|
219
|
+
[name, description, subject, html, text, design_json, editor_type, classification].hash
|
|
164
220
|
end
|
|
165
221
|
|
|
166
222
|
# Builds the object from hash
|
|
@@ -14,7 +14,7 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module Zyphr
|
|
17
|
-
# Subject is required. Provide
|
|
17
|
+
# Subject is required. Provide `html`, or a visual editor `design_json` (`format: zyphr-email/1`), which is exported to `html` on save. `text` is optional: when empty, the plain-text part is generated from the rendered HTML at send. A visual design always generates it.
|
|
18
18
|
class UpsertAuthEmailTemplateRequest
|
|
19
19
|
attr_accessor :subject
|
|
20
20
|
|
|
@@ -22,8 +22,6 @@ module Zyphr
|
|
|
22
22
|
|
|
23
23
|
attr_accessor :text
|
|
24
24
|
|
|
25
|
-
attr_accessor :mjml_source
|
|
26
|
-
|
|
27
25
|
attr_accessor :design_json
|
|
28
26
|
|
|
29
27
|
attr_accessor :editor_type
|
|
@@ -62,7 +60,6 @@ module Zyphr
|
|
|
62
60
|
:'subject' => :'subject',
|
|
63
61
|
:'html' => :'html',
|
|
64
62
|
:'text' => :'text',
|
|
65
|
-
:'mjml_source' => :'mjml_source',
|
|
66
63
|
:'design_json' => :'design_json',
|
|
67
64
|
:'editor_type' => :'editor_type',
|
|
68
65
|
:'from_name' => :'from_name',
|
|
@@ -87,7 +84,6 @@ module Zyphr
|
|
|
87
84
|
:'subject' => :'String',
|
|
88
85
|
:'html' => :'String',
|
|
89
86
|
:'text' => :'String',
|
|
90
|
-
:'mjml_source' => :'String',
|
|
91
87
|
:'design_json' => :'Hash<String, Object>',
|
|
92
88
|
:'editor_type' => :'String',
|
|
93
89
|
:'from_name' => :'String',
|
|
@@ -100,7 +96,6 @@ module Zyphr
|
|
|
100
96
|
def self.openapi_nullable
|
|
101
97
|
Set.new([
|
|
102
98
|
:'text',
|
|
103
|
-
:'mjml_source',
|
|
104
99
|
:'design_json',
|
|
105
100
|
:'editor_type',
|
|
106
101
|
:'from_name',
|
|
@@ -136,10 +131,6 @@ module Zyphr
|
|
|
136
131
|
self.text = attributes[:'text']
|
|
137
132
|
end
|
|
138
133
|
|
|
139
|
-
if attributes.key?(:'mjml_source')
|
|
140
|
-
self.mjml_source = attributes[:'mjml_source']
|
|
141
|
-
end
|
|
142
|
-
|
|
143
134
|
if attributes.key?(:'design_json')
|
|
144
135
|
if (value = attributes[:'design_json']).is_a?(Hash)
|
|
145
136
|
self.design_json = value
|
|
@@ -175,7 +166,7 @@ module Zyphr
|
|
|
175
166
|
# @return true if the model is valid
|
|
176
167
|
def valid?
|
|
177
168
|
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
178
|
-
editor_type_validator = EnumAttributeValidator.new('String', ["code", "
|
|
169
|
+
editor_type_validator = EnumAttributeValidator.new('String', ["code", "visual"])
|
|
179
170
|
return false unless editor_type_validator.valid?(@editor_type)
|
|
180
171
|
true
|
|
181
172
|
end
|
|
@@ -183,7 +174,7 @@ module Zyphr
|
|
|
183
174
|
# Custom attribute writer method checking allowed values (enum).
|
|
184
175
|
# @param [Object] editor_type Object to be assigned
|
|
185
176
|
def editor_type=(editor_type)
|
|
186
|
-
validator = EnumAttributeValidator.new('String', ["code", "
|
|
177
|
+
validator = EnumAttributeValidator.new('String', ["code", "visual"])
|
|
187
178
|
unless validator.valid?(editor_type)
|
|
188
179
|
fail ArgumentError, "invalid value for \"editor_type\", must be one of #{validator.allowable_values}."
|
|
189
180
|
end
|
|
@@ -198,7 +189,6 @@ module Zyphr
|
|
|
198
189
|
subject == o.subject &&
|
|
199
190
|
html == o.html &&
|
|
200
191
|
text == o.text &&
|
|
201
|
-
mjml_source == o.mjml_source &&
|
|
202
192
|
design_json == o.design_json &&
|
|
203
193
|
editor_type == o.editor_type &&
|
|
204
194
|
from_name == o.from_name &&
|
|
@@ -215,7 +205,7 @@ module Zyphr
|
|
|
215
205
|
# Calculates hash code according to all attributes.
|
|
216
206
|
# @return [Integer] Hash code
|
|
217
207
|
def hash
|
|
218
|
-
[subject, html, text,
|
|
208
|
+
[subject, html, text, design_json, editor_type, from_name, reply_to, is_enabled].hash
|
|
219
209
|
end
|
|
220
210
|
|
|
221
211
|
# Builds the object from hash
|
data/lib/zyphr.rb
CHANGED
|
@@ -405,6 +405,8 @@ require 'zyphr/models/switch_organization_response_data'
|
|
|
405
405
|
require 'zyphr/models/switch_organization_response_data_tokens'
|
|
406
406
|
require 'zyphr/models/switch_organization_response_data_user'
|
|
407
407
|
require 'zyphr/models/template'
|
|
408
|
+
require 'zyphr/models/template_classification'
|
|
409
|
+
require 'zyphr/models/template_editor_type'
|
|
408
410
|
require 'zyphr/models/template_list_response'
|
|
409
411
|
require 'zyphr/models/template_render_response'
|
|
410
412
|
require 'zyphr/models/template_rendered_content'
|
|
@@ -34,7 +34,7 @@ describe 'AuthEmailTemplatesApi' do
|
|
|
34
34
|
|
|
35
35
|
# unit tests for bulk_upsert_auth_email_templates
|
|
36
36
|
# Bulk-upsert auth email templates
|
|
37
|
-
# Atomic upsert of any subset of magic_link, password_reset, email_verification, email_otp, invitation. Validates all inputs before any write; if any one fails validation or
|
|
37
|
+
# Atomic upsert of any subset of magic_link, password_reset, email_verification, email_otp, invitation. Validates all inputs before any write; if any one fails validation or design export, none are saved. Designed for one-shot migration imports from Auth0/Firebase/Clerk/Cognito.
|
|
38
38
|
# @param bulk_upsert_auth_email_templates_request
|
|
39
39
|
# @param [Hash] opts the optional parameters
|
|
40
40
|
# @return [BulkUpsertAuthEmailTemplatesResponse]
|
|
@@ -143,7 +143,7 @@ describe 'AuthEmailTemplatesApi' do
|
|
|
143
143
|
|
|
144
144
|
# unit tests for upsert_auth_email_template
|
|
145
145
|
# Create or update an auth email template
|
|
146
|
-
# Idempotent upsert keyed by application + type.
|
|
146
|
+
# Idempotent upsert keyed by application + type. A visual editor `design_json` (`format: zyphr-email/1`) is exported to `html` on save; a design that can't be exported returns 400.
|
|
147
147
|
# @param type
|
|
148
148
|
# @param upsert_auth_email_template_request
|
|
149
149
|
# @param [Hash] opts the optional parameters
|
|
@@ -34,7 +34,7 @@ describe 'TemplatesApi' do
|
|
|
34
34
|
|
|
35
35
|
# unit tests for create_template
|
|
36
36
|
# Create template
|
|
37
|
-
# Create
|
|
37
|
+
# Create an email, SMS or push template. The name must be unique per channel within the project.
|
|
38
38
|
# @param create_template_request
|
|
39
39
|
# @param [Hash] opts the optional parameters
|
|
40
40
|
# @return [TemplateResponse]
|