Class: Broadcast::Resources::Templates
- Defined in:
- lib/broadcast/resources/templates.rb
Instance Method Summary collapse
-
#create(**attrs) ⇒ Object
Create a template.
- #delete(id) ⇒ Object
- #get_template(id) ⇒ Object
- #list(**params) ⇒ Object
- #update(id, **attrs) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from Broadcast::Resources::Base
Instance Method Details
#create(**attrs) ⇒ Object
Create a template. Attrs are wrapped under template: on the wire.
Content:
label:, subject:, preheader:, body:, html_body:
Confirmation templates (double opt-in):
template_purpose: marks the template's role, e.g. 'confirmation'
confirmation_text: copy shown in the confirmation email
default_confirmation: make this the channel's default confirmation template
confirmation_page_settings: per-state page copy, keyed by state, each
taking { heading:, body: } — e.g.
{ 'confirmed' => { heading: 'You're in',
body: 'Thanks for confirming.' },
'expired' => { heading: 'Link expired', body: '...' } }
Anything the server doesn't recognize comes back as an
unrecognized_parameter warning on the response rather than an error.
31 32 33 |
# File 'lib/broadcast/resources/templates.rb', line 31 def create(**attrs) post('/api/v1/templates', { template: attrs }) end |
#delete(id) ⇒ Object
39 40 41 |
# File 'lib/broadcast/resources/templates.rb', line 39 def delete(id) @client.request(:delete, "/api/v1/templates/#{id}") end |
#get_template(id) ⇒ Object
10 11 12 |
# File 'lib/broadcast/resources/templates.rb', line 10 def get_template(id) get("/api/v1/templates/#{id}") end |
#list(**params) ⇒ Object
6 7 8 |
# File 'lib/broadcast/resources/templates.rb', line 6 def list(**params) get('/api/v1/templates', params) end |
#update(id, **attrs) ⇒ Object
35 36 37 |
# File 'lib/broadcast/resources/templates.rb', line 35 def update(id, **attrs) patch("/api/v1/templates/#{id}", { template: attrs }) end |