Class: Paubox::DynamicTemplates
- Inherits:
-
Object
- Object
- Paubox::DynamicTemplates
- Defined in:
- lib/paubox/dynamic_templates.rb
Instance Attribute Summary collapse
-
#api_customer_id ⇒ Object
Returns the value of attribute api_customer_id.
-
#body ⇒ Object
Returns the value of attribute body.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(args = {}) ⇒ DynamicTemplates
constructor
A new instance of DynamicTemplates.
- #update(template_file_path, template_name = nil) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ DynamicTemplates
Returns a new instance of DynamicTemplates.
8 9 10 11 12 13 |
# File 'lib/paubox/dynamic_templates.rb', line 8 def initialize(args = {}) @id = args['id'] @name = args['name'] @api_customer_id = args['api_customer_id'] @body = args['body'] end |
Instance Attribute Details
#api_customer_id ⇒ Object
Returns the value of attribute api_customer_id.
6 7 8 |
# File 'lib/paubox/dynamic_templates.rb', line 6 def api_customer_id @api_customer_id end |
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/paubox/dynamic_templates.rb', line 6 def body @body end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/paubox/dynamic_templates.rb', line 6 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/paubox/dynamic_templates.rb', line 6 def name @name end |
Class Method Details
.create(template_name, template_file_path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/paubox/dynamic_templates.rb', line 33 def create(template_name, template_file_path) path = "dynamic_templates" payload = { data: { name: template_name, body: File.new(template_file_path) } } Paubox::Client.new.send_request(method: :post, payload: payload, path: path) end |
.find(template_id) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/paubox/dynamic_templates.rb', line 44 def find(template_id) path = "dynamic_templates/#{template_id.to_s}" response = Paubox::Client.new.send_request(method: :get, path: path) data = JSON.parse(response.body) Paubox::DynamicTemplates.new(data) end |
.list ⇒ Object
51 52 53 54 55 |
# File 'lib/paubox/dynamic_templates.rb', line 51 def list path = "dynamic_templates" response = Paubox::Client.new.send_request(method: :get, path: path) JSON.parse(response.body) end |
Instance Method Details
#delete ⇒ Object
27 28 29 30 |
# File 'lib/paubox/dynamic_templates.rb', line 27 def delete path = "dynamic_templates/#{id}" Paubox::Client.new.send_request(method: :delete, path: path) end |
#update(template_file_path, template_name = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/paubox/dynamic_templates.rb', line 15 def update(template_file_path, template_name = nil) path = "dynamic_templates/#{id}" payload = { data: { name: template_name, body: File.new(template_file_path) } } Paubox::Client.new.send_request(method: :patch, payload: payload, path: path) end |