Class: ExpressPigeon::Templates

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/express_pigeon/templates.rb

Overview

Templates

Instance Method Summary collapse

Constructor Details

#initialize(auth_key) ⇒ Templates

Returns a new instance of Templates.



8
9
10
# File 'lib/express_pigeon/templates.rb', line 8

def initialize(auth_key)
  self.class.headers('X-auth-key' => auth_key)
end

Instance Method Details

#copy(template_id, name:, merge_fields: {}) ⇒ Object

Copy template

POST api.expresspigeon.com/templates/template_id/copy

NOTE: It is important to use only single quotes in injected HTML



17
18
19
20
21
22
23
24
25
26
# File 'lib/express_pigeon/templates.rb', line 17

def copy(template_id, name:, merge_fields: {})
  self.class.post(
    "/#{template_id}/copy",
    body: {
      name: name,
      merge_fields: merge_fields
    }.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end