Class: SimpleSpark::Endpoints::Templates
- Inherits:
-
Object
- Object
- SimpleSpark::Endpoints::Templates
- Defined in:
- lib/simple_spark/endpoints/templates.rb
Overview
Sample Template { “id”=>“102293692714480130”, “name”=>“Summer Sale!”, “description”=>“”, “published”=>false, “options”=>{},
"last_update_time"=>"2016-03-02T22:49:23+00:00",
"content"=>{"from"=>"[email protected]", "subject"=>"Summer deals", "html"=>"<b>Check out these deals!</b>"} }
Provides access to the /templates endpoint
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(values) ⇒ boolean
Create a template by providing values for the template object.
-
#delete(id) ⇒ Object
Delete a Template by its ID.
-
#initialize(client) ⇒ Templates
constructor
A new instance of Templates.
-
#list ⇒ Array
Lists the most recent version of each template in your account.
-
#preview(id, substitutions, draft = nil) ⇒ Object
Preview a Template by its ID.
-
#retrieve(id, draft = nil) ⇒ Hash
Retrieve a Template by its ID.
-
#update(id, values, update_published = false) ⇒ Object
Update a Template by its ID.
Constructor Details
#initialize(client) ⇒ Templates
Returns a new instance of Templates.
12 13 14 |
# File 'lib/simple_spark/endpoints/templates.rb', line 12 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/simple_spark/endpoints/templates.rb', line 10 def client @client end |
Instance Method Details
#create(values) ⇒ boolean
Create a template by providing values for the template object.
29 30 31 |
# File 'lib/simple_spark/endpoints/templates.rb', line 29 def create(values) @client.call(method: :post, path: 'templates', body_values: values) end |
#delete(id) ⇒ Object
Delete a Template by its ID
75 76 77 |
# File 'lib/simple_spark/endpoints/templates.rb', line 75 def delete(id) @client.call(method: :delete, path: "templates/#{id}") end |
#list ⇒ Array
Lists the most recent version of each template in your account.
19 20 21 |
# File 'lib/simple_spark/endpoints/templates.rb', line 19 def list @client.call(method: :get, path: 'templates') end |
#preview(id, substitutions, draft = nil) ⇒ Object
Preview a Template by its ID
66 67 68 69 |
# File 'lib/simple_spark/endpoints/templates.rb', line 66 def preview(id, substitutions, draft = nil) query_params = draft.nil? ? {} : { draft: draft } @client.call(method: :post, path: "templates/#{id}/preview", body_values: substitutions, query_values: query_params) end |
#retrieve(id, draft = nil) ⇒ Hash
Retrieve a Template by its ID
40 41 42 43 44 |
# File 'lib/simple_spark/endpoints/templates.rb', line 40 def retrieve(id, draft = nil) path = "templates/#{id}" query_params = draft.nil? ? {} : { draft: draft } @client.call(method: :get, path: path, query_values: query_params) end |
#update(id, values, update_published = false) ⇒ Object
Update a Template by its ID
53 54 55 |
# File 'lib/simple_spark/endpoints/templates.rb', line 53 def update(id, values, update_published = false) @client.call(method: :put, path: "templates/#{id}", body_values: values, query_values: { update_published: update_published }) end |