Class: Deckle::Templates
- Inherits:
-
Object
- Object
- Deckle::Templates
- Defined in:
- lib/deckle/templates.rb
Instance Method Summary collapse
-
#create(name:, html_content:, schema: nil, is_public: false) ⇒ Hash
Create a new template.
-
#delete(id) ⇒ Hash
Delete a template.
-
#get(id) ⇒ Hash
Get a template by ID.
-
#initialize(client) ⇒ Templates
constructor
A new instance of Templates.
-
#list ⇒ Hash
List all templates.
-
#update(id, name: nil, html_content: nil, schema: nil, is_public: nil) ⇒ Hash
Update a template.
Constructor Details
#initialize(client) ⇒ Templates
Returns a new instance of Templates.
5 6 7 |
# File 'lib/deckle/templates.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#create(name:, html_content:, schema: nil, is_public: false) ⇒ Hash
Create a new template.
16 17 18 19 20 21 |
# File 'lib/deckle/templates.rb', line 16 def create(name:, html_content:, schema: nil, is_public: false) body = { "name" => name, "html_content" => html_content, "is_public" => is_public } body["schema"] = schema if schema @client.request(:post, "/v1/templates", body: body) end |
#delete(id) ⇒ Hash
Delete a template.
60 61 62 |
# File 'lib/deckle/templates.rb', line 60 def delete(id) @client.request(:delete, "/v1/templates/#{id}") end |
#get(id) ⇒ Hash
Get a template by ID.
34 35 36 |
# File 'lib/deckle/templates.rb', line 34 def get(id) @client.request(:get, "/v1/templates/#{id}") end |
#list ⇒ Hash
List all templates.
26 27 28 |
# File 'lib/deckle/templates.rb', line 26 def list @client.request(:get, "/v1/templates") end |
#update(id, name: nil, html_content: nil, schema: nil, is_public: nil) ⇒ Hash
Update a template.
46 47 48 49 50 51 52 53 54 |
# File 'lib/deckle/templates.rb', line 46 def update(id, name: nil, html_content: nil, schema: nil, is_public: nil) body = {} body["name"] = name unless name.nil? body["html_content"] = html_content unless html_content.nil? body["schema"] = schema unless schema.nil? body["is_public"] = is_public unless is_public.nil? @client.request(:put, "/v1/templates/#{id}", body: body) end |