zyphr 0.1.79 → 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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/docs/AuthEmailTemplate.md +0 -2
  4. data/docs/AuthEmailTemplatePreviewDraft.md +0 -2
  5. data/docs/AuthEmailTemplateVersion.md +0 -2
  6. data/docs/AuthEmailTemplatesApi.md +2 -2
  7. data/docs/AuthEmailVerificationApi.md +12 -16
  8. data/docs/AuthMagicLinksApi.md +1 -1
  9. data/docs/AuthPasswordResetApi.md +1 -1
  10. data/docs/CreateTemplateRequest.md +12 -4
  11. data/docs/ForgotPasswordRequest.md +1 -1
  12. data/docs/MagicLinkSendRequest.md +1 -1
  13. data/docs/ResendEmailVerificationRequest.md +1 -1
  14. data/docs/SendEmailVerificationRequest.md +1 -1
  15. data/docs/Template.md +8 -0
  16. data/docs/TemplateClassification.md +15 -0
  17. data/docs/TemplateEditorType.md +15 -0
  18. data/docs/TemplatesApi.md +1 -1
  19. data/docs/UpdateTemplateRequest.md +9 -3
  20. data/docs/UpsertAuthEmailTemplateRequest.md +0 -2
  21. data/lib/zyphr/api/auth_email_templates_api.rb +4 -4
  22. data/lib/zyphr/api/auth_email_verification_api.rb +20 -12
  23. data/lib/zyphr/api/templates_api.rb +2 -2
  24. data/lib/zyphr/models/auth_email_template.rb +3 -13
  25. data/lib/zyphr/models/auth_email_template_preview_draft.rb +1 -11
  26. data/lib/zyphr/models/auth_email_template_version.rb +3 -13
  27. data/lib/zyphr/models/create_template_request.rb +87 -7
  28. data/lib/zyphr/models/forgot_password_request.rb +18 -0
  29. data/lib/zyphr/models/magic_link_send_request.rb +18 -0
  30. data/lib/zyphr/models/resend_email_verification_request.rb +18 -1
  31. data/lib/zyphr/models/send_email_verification_request.rb +18 -1
  32. data/lib/zyphr/models/template.rb +78 -1
  33. data/lib/zyphr/models/template_classification.rb +40 -0
  34. data/lib/zyphr/models/template_editor_type.rb +40 -0
  35. data/lib/zyphr/models/update_template_request.rb +62 -6
  36. data/lib/zyphr/models/upsert_auth_email_template_request.rb +4 -14
  37. data/lib/zyphr.rb +2 -0
  38. data/spec/api/auth_email_templates_api_spec.rb +2 -2
  39. data/spec/api/auth_email_verification_api_spec.rb +2 -2
  40. data/spec/api/templates_api_spec.rb +1 -1
  41. data/spec/models/auth_email_template_preview_draft_spec.rb +0 -6
  42. data/spec/models/auth_email_template_spec.rb +1 -7
  43. data/spec/models/auth_email_template_version_spec.rb +1 -7
  44. data/spec/models/create_template_request_spec.rb +28 -0
  45. data/spec/models/template_classification_spec.rb +30 -0
  46. data/spec/models/template_editor_type_spec.rb +30 -0
  47. data/spec/models/template_spec.rb +28 -0
  48. data/spec/models/update_template_request_spec.rb +18 -0
  49. data/spec/models/upsert_auth_email_template_request_spec.rb +1 -7
  50. data/zyphr.gemspec +1 -1
  51. metadata +10 -2
@@ -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 :from_name
28
26
 
29
27
  attr_accessor :reply_to
@@ -34,7 +32,6 @@ module Zyphr
34
32
  :'subject' => :'subject',
35
33
  :'html' => :'html',
36
34
  :'text' => :'text',
37
- :'mjml_source' => :'mjml_source',
38
35
  :'from_name' => :'from_name',
39
36
  :'reply_to' => :'reply_to'
40
37
  }
@@ -56,7 +53,6 @@ module Zyphr
56
53
  :'subject' => :'String',
57
54
  :'html' => :'String',
58
55
  :'text' => :'String',
59
- :'mjml_source' => :'String',
60
56
  :'from_name' => :'String',
61
57
  :'reply_to' => :'String'
62
58
  }
@@ -68,7 +64,6 @@ module Zyphr
68
64
  :'subject',
69
65
  :'html',
70
66
  :'text',
71
- :'mjml_source',
72
67
  :'from_name',
73
68
  :'reply_to'
74
69
  ])
@@ -102,10 +97,6 @@ module Zyphr
102
97
  self.text = attributes[:'text']
103
98
  end
104
99
 
105
- if attributes.key?(:'mjml_source')
106
- self.mjml_source = attributes[:'mjml_source']
107
- end
108
-
109
100
  if attributes.key?(:'from_name')
110
101
  self.from_name = attributes[:'from_name']
111
102
  end
@@ -138,7 +129,6 @@ module Zyphr
138
129
  subject == o.subject &&
139
130
  html == o.html &&
140
131
  text == o.text &&
141
- mjml_source == o.mjml_source &&
142
132
  from_name == o.from_name &&
143
133
  reply_to == o.reply_to
144
134
  end
@@ -152,7 +142,7 @@ module Zyphr
152
142
  # Calculates hash code according to all attributes.
153
143
  # @return [Integer] Hash code
154
144
  def hash
155
- [subject, html, text, mjml_source, from_name, reply_to].hash
145
+ [subject, html, text, from_name, reply_to].hash
156
146
  end
157
147
 
158
148
  # Builds the object from hash
@@ -23,8 +23,6 @@ module Zyphr
23
23
 
24
24
  attr_accessor :text
25
25
 
26
- attr_accessor :mjml_source
27
-
28
26
  attr_accessor :design_json
29
27
 
30
28
  attr_accessor :editor_type
@@ -66,7 +64,6 @@ module Zyphr
66
64
  :'subject' => :'subject',
67
65
  :'html' => :'html',
68
66
  :'text' => :'text',
69
- :'mjml_source' => :'mjml_source',
70
67
  :'design_json' => :'design_json',
71
68
  :'editor_type' => :'editor_type',
72
69
  :'from_name' => :'from_name',
@@ -93,7 +90,6 @@ module Zyphr
93
90
  :'subject' => :'String',
94
91
  :'html' => :'String',
95
92
  :'text' => :'String',
96
- :'mjml_source' => :'String',
97
93
  :'design_json' => :'Hash<String, Object>',
98
94
  :'editor_type' => :'String',
99
95
  :'from_name' => :'String',
@@ -107,7 +103,6 @@ module Zyphr
107
103
  def self.openapi_nullable
108
104
  Set.new([
109
105
  :'text',
110
- :'mjml_source',
111
106
  :'design_json',
112
107
  :'editor_type',
113
108
  :'from_name',
@@ -147,10 +142,6 @@ module Zyphr
147
142
  self.text = attributes[:'text']
148
143
  end
149
144
 
150
- if attributes.key?(:'mjml_source')
151
- self.mjml_source = attributes[:'mjml_source']
152
- end
153
-
154
145
  if attributes.key?(:'design_json')
155
146
  if (value = attributes[:'design_json']).is_a?(Hash)
156
147
  self.design_json = value
@@ -190,7 +181,7 @@ module Zyphr
190
181
  # @return true if the model is valid
191
182
  def valid?
192
183
  warn '[DEPRECATED] the `valid?` method is obsolete'
193
- editor_type_validator = EnumAttributeValidator.new('String', ["code", "mjml", "design"])
184
+ editor_type_validator = EnumAttributeValidator.new('String', ["code", "visual"])
194
185
  return false unless editor_type_validator.valid?(@editor_type)
195
186
  true
196
187
  end
@@ -198,7 +189,7 @@ module Zyphr
198
189
  # Custom attribute writer method checking allowed values (enum).
199
190
  # @param [Object] editor_type Object to be assigned
200
191
  def editor_type=(editor_type)
201
- validator = EnumAttributeValidator.new('String', ["code", "mjml", "design"])
192
+ validator = EnumAttributeValidator.new('String', ["code", "visual"])
202
193
  unless validator.valid?(editor_type)
203
194
  fail ArgumentError, "invalid value for \"editor_type\", must be one of #{validator.allowable_values}."
204
195
  end
@@ -214,7 +205,6 @@ module Zyphr
214
205
  subject == o.subject &&
215
206
  html == o.html &&
216
207
  text == o.text &&
217
- mjml_source == o.mjml_source &&
218
208
  design_json == o.design_json &&
219
209
  editor_type == o.editor_type &&
220
210
  from_name == o.from_name &&
@@ -232,7 +222,7 @@ module Zyphr
232
222
  # Calculates hash code according to all attributes.
233
223
  # @return [Integer] Hash code
234
224
  def hash
235
- [version, subject, html, text, mjml_source, design_json, editor_type, from_name, reply_to, is_enabled, created_at].hash
225
+ [version, subject, html, text, design_json, editor_type, from_name, reply_to, is_enabled, created_at].hash
236
226
  end
237
227
 
238
228
  # Builds the object from hash
@@ -20,23 +20,59 @@ module Zyphr
20
20
 
21
21
  attr_accessor :description
22
22
 
23
- # Email subject line. Supports Handlebars `{{var}}` interpolation; values are HTML-escaped on render (see `html` field for the full escape policy).
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; triple-brace syntax is rewritten to double-brace on save (same policy as the `html` field).
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
@@ -17,6 +17,7 @@ module Zyphr
17
17
  class ForgotPasswordRequest
18
18
  attr_accessor :email
19
19
 
20
+ # Where the emailed link points (`?token=<raw>` is appended). Required: Zyphr does not host auth pages. Must match the application's redirect_uris when any are registered.
20
21
  attr_accessor :redirect_url
21
22
 
22
23
  # When true, Zyphr mints the token but sends no email, and returns the link in `data.link` so you can render and send the email yourself (for example through `POST /v1/emails`). Requires `redirect_url`.
@@ -80,6 +81,8 @@ module Zyphr
80
81
 
81
82
  if attributes.key?(:'redirect_url')
82
83
  self.redirect_url = attributes[:'redirect_url']
84
+ else
85
+ self.redirect_url = nil
83
86
  end
84
87
 
85
88
  if attributes.key?(:'return_link')
@@ -98,6 +101,10 @@ module Zyphr
98
101
  invalid_properties.push('invalid value for "email", email cannot be nil.')
99
102
  end
100
103
 
104
+ if @redirect_url.nil?
105
+ invalid_properties.push('invalid value for "redirect_url", redirect_url cannot be nil.')
106
+ end
107
+
101
108
  invalid_properties
102
109
  end
103
110
 
@@ -106,6 +113,7 @@ module Zyphr
106
113
  def valid?
107
114
  warn '[DEPRECATED] the `valid?` method is obsolete'
108
115
  return false if @email.nil?
116
+ return false if @redirect_url.nil?
109
117
  true
110
118
  end
111
119
 
@@ -119,6 +127,16 @@ module Zyphr
119
127
  @email = email
120
128
  end
121
129
 
130
+ # Custom attribute writer method with validation
131
+ # @param [Object] redirect_url Value to be assigned
132
+ def redirect_url=(redirect_url)
133
+ if redirect_url.nil?
134
+ fail ArgumentError, 'redirect_url cannot be nil'
135
+ end
136
+
137
+ @redirect_url = redirect_url
138
+ end
139
+
122
140
  # Checks equality by comparing each attribute.
123
141
  # @param [Object] Object to be compared
124
142
  def ==(o)
@@ -17,6 +17,7 @@ module Zyphr
17
17
  class MagicLinkSendRequest
18
18
  attr_accessor :email
19
19
 
20
+ # Where the emailed link points (`?token=<raw>` is appended). Required: Zyphr does not host auth pages. Must match the application's redirect_uris when any are registered.
20
21
  attr_accessor :redirect_url
21
22
 
22
23
  # When true, Zyphr mints the token but sends no email, and returns the link in `data.link` so you can render and send the email yourself (for example through `POST /v1/emails`). Requires `redirect_url`.
@@ -80,6 +81,8 @@ module Zyphr
80
81
 
81
82
  if attributes.key?(:'redirect_url')
82
83
  self.redirect_url = attributes[:'redirect_url']
84
+ else
85
+ self.redirect_url = nil
83
86
  end
84
87
 
85
88
  if attributes.key?(:'return_link')
@@ -98,6 +101,10 @@ module Zyphr
98
101
  invalid_properties.push('invalid value for "email", email cannot be nil.')
99
102
  end
100
103
 
104
+ if @redirect_url.nil?
105
+ invalid_properties.push('invalid value for "redirect_url", redirect_url cannot be nil.')
106
+ end
107
+
101
108
  invalid_properties
102
109
  end
103
110
 
@@ -106,6 +113,7 @@ module Zyphr
106
113
  def valid?
107
114
  warn '[DEPRECATED] the `valid?` method is obsolete'
108
115
  return false if @email.nil?
116
+ return false if @redirect_url.nil?
109
117
  true
110
118
  end
111
119
 
@@ -119,6 +127,16 @@ module Zyphr
119
127
  @email = email
120
128
  end
121
129
 
130
+ # Custom attribute writer method with validation
131
+ # @param [Object] redirect_url Value to be assigned
132
+ def redirect_url=(redirect_url)
133
+ if redirect_url.nil?
134
+ fail ArgumentError, 'redirect_url cannot be nil'
135
+ end
136
+
137
+ @redirect_url = redirect_url
138
+ end
139
+
122
140
  # Checks equality by comparing each attribute.
123
141
  # @param [Object] Object to be compared
124
142
  def ==(o)
@@ -15,7 +15,7 @@ require 'time'
15
15
 
16
16
  module Zyphr
17
17
  class ResendEmailVerificationRequest
18
- # URL to redirect to after verification. Same rules as `POST /auth/verify-email/send`.
18
+ # Required. URL to redirect to after verification. Same rules as `POST /auth/verify-email/send`.
19
19
  attr_accessor :redirect_url
20
20
 
21
21
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -66,6 +66,8 @@ module Zyphr
66
66
 
67
67
  if attributes.key?(:'redirect_url')
68
68
  self.redirect_url = attributes[:'redirect_url']
69
+ else
70
+ self.redirect_url = nil
69
71
  end
70
72
  end
71
73
 
@@ -74,6 +76,10 @@ module Zyphr
74
76
  def list_invalid_properties
75
77
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
76
78
  invalid_properties = Array.new
79
+ if @redirect_url.nil?
80
+ invalid_properties.push('invalid value for "redirect_url", redirect_url cannot be nil.')
81
+ end
82
+
77
83
  invalid_properties
78
84
  end
79
85
 
@@ -81,9 +87,20 @@ module Zyphr
81
87
  # @return true if the model is valid
82
88
  def valid?
83
89
  warn '[DEPRECATED] the `valid?` method is obsolete'
90
+ return false if @redirect_url.nil?
84
91
  true
85
92
  end
86
93
 
94
+ # Custom attribute writer method with validation
95
+ # @param [Object] redirect_url Value to be assigned
96
+ def redirect_url=(redirect_url)
97
+ if redirect_url.nil?
98
+ fail ArgumentError, 'redirect_url cannot be nil'
99
+ end
100
+
101
+ @redirect_url = redirect_url
102
+ end
103
+
87
104
  # Checks equality by comparing each attribute.
88
105
  # @param [Object] Object to be compared
89
106
  def ==(o)
@@ -15,7 +15,7 @@ require 'time'
15
15
 
16
16
  module Zyphr
17
17
  class SendEmailVerificationRequest
18
- # URL to redirect to after verification. Must be snake_case `redirect_url`: a camelCase `redirectUrl` is rejected with 400, since Zyphr hosts no fallback page. Must match one of the application's configured redirect URIs.
18
+ # Required. URL to redirect to after verification. Must be snake_case `redirect_url`: a camelCase `redirectUrl` is rejected with 400, since Zyphr hosts no fallback page. Must match one of the application's configured redirect URIs.
19
19
  attr_accessor :redirect_url
20
20
 
21
21
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -66,6 +66,8 @@ module Zyphr
66
66
 
67
67
  if attributes.key?(:'redirect_url')
68
68
  self.redirect_url = attributes[:'redirect_url']
69
+ else
70
+ self.redirect_url = nil
69
71
  end
70
72
  end
71
73
 
@@ -74,6 +76,10 @@ module Zyphr
74
76
  def list_invalid_properties
75
77
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
76
78
  invalid_properties = Array.new
79
+ if @redirect_url.nil?
80
+ invalid_properties.push('invalid value for "redirect_url", redirect_url cannot be nil.')
81
+ end
82
+
77
83
  invalid_properties
78
84
  end
79
85
 
@@ -81,9 +87,20 @@ module Zyphr
81
87
  # @return true if the model is valid
82
88
  def valid?
83
89
  warn '[DEPRECATED] the `valid?` method is obsolete'
90
+ return false if @redirect_url.nil?
84
91
  true
85
92
  end
86
93
 
94
+ # Custom attribute writer method with validation
95
+ # @param [Object] redirect_url Value to be assigned
96
+ def redirect_url=(redirect_url)
97
+ if redirect_url.nil?
98
+ fail ArgumentError, 'redirect_url cannot be nil'
99
+ end
100
+
101
+ @redirect_url = redirect_url
102
+ end
103
+
87
104
  # Checks equality by comparing each attribute.
88
105
  # @param [Object] Object to be compared
89
106
  def ==(o)
@@ -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