Class: Textmagic::REST::Templates
- Inherits:
-
ListResource
- Object
- ListResource
- Textmagic::REST::Templates
- Defined in:
- lib/textmagic-ruby/rest/templates.rb
Instance Method Summary collapse
-
#create(params = {}) ⇒ Object
Create new Template.
-
#delete(uid) ⇒ Object
Delete template by ID.
-
#get(uid) ⇒ Object
Get template by ID.
-
#list(params = {}) ⇒ Object
Get all user templates.
-
#update(uid, params = {}) ⇒ Object
Updates the existing Template for the given unique id.
Methods inherited from ListResource
Methods included from Utils
#key_map, #resource, #to_camel_case, #to_underscore_case
Constructor Details
This class inherits a constructor from Textmagic::REST::ListResource
Instance Method Details
#create(params = {}) ⇒ Object
Create new Template. Returns Template object contains id and link to new Template.
The following params keys are supported:
- name
-
Template name. Required.
- content
-
Template text. May contain tags inside braces. Required.
Example:
@template = client.templates.create {:name => 'MyTemplate'}
32 33 34 |
# File 'lib/textmagic-ruby/rest/templates.rb', line 32 def create(params={}) super params end |
#delete(uid) ⇒ Object
Delete template by ID. Returns true if success.
- uid
-
Template ID. Required.
Example:
r = client.templates.delete 987
89 90 91 |
# File 'lib/textmagic-ruby/rest/templates.rb', line 89 def delete(uid) super uid end |
#get(uid) ⇒ Object
Get template by ID. Returns Template object.
- uid
-
Template ID. Required.
Example:
@template = client.templates.get 987
14 15 16 |
# File 'lib/textmagic-ruby/rest/templates.rb', line 14 def get(uid) super uid end |
#list(params = {}) ⇒ Object
Get all user templates. Returns PaginateResource object, contains array of Template objects.
The following params keys are supported:
- search
-
If true then search templates using ‘name` and/or `content`. Defaults false.
- page
-
Fetch specified results page. Defaults 1
- limit
-
How many results on page. Defaults 10
- name
-
Find template by name. Using with ‘search`=true.
- content
-
Find template by content. Using with ‘search`=true..
Example:
@templates = client.templates.list
56 57 58 |
# File 'lib/textmagic-ruby/rest/templates.rb', line 56 def list(params={}) super params end |
#update(uid, params = {}) ⇒ Object
Updates the existing Template for the given unique id. Returns Template object contains id and link to updated Template.
- uid
-
Template ID. Required.
The following params keys are supported:
- name
-
Template name. Required.
- content
-
Template text. May contain tags inside braces. Required.
Example:
@template = client.templates.update 123, {:name => 'Updated Template'}
76 77 78 |
# File 'lib/textmagic-ruby/rest/templates.rb', line 76 def update(uid, params={}) super uid, params end |