class Iterable::EmailTemplates

Interact with /templates/email API endpoints

@example Creating email templates endpoint object

# With default config
templates = Iterable::EmailTemplates.new
templates.get

# With custom config
conf = Iterable::Config.new(token: 'new-token')
templates = Iterable::EmailTemplates.new(config)

Public Instance Methods

get(template_id, params = {}) click to toggle source

Get an email template

@param template_id [String|Integer] An email template ID @param params [Hash] Additional params to use such as locale

@return [Iterable::Response] A response object

# File lib/iterable/email_templates.rb, line 23
def get(template_id, params = {})
  params['templateId'] = template_id
  Iterable.request(conf, '/templates/email/get', params).get
end
update(template_id, attrs = {}) click to toggle source

Update an email template

@param template_id [String|Integer] An email template ID @param attrs [Hash] Update attributes

@return [Iterable::Response] A response object

# File lib/iterable/email_templates.rb, line 36
def update(template_id, attrs = {})
  attrs['templateId'] = template_id
  Iterable.request(conf, '/templates/email/update').post(attrs)
end
upsert(client_template_id, attrs = {}) click to toggle source

Upsert an email template by client template ID

@param client_template_id [String] A client template id to use or create @param attrs [Hash] Update attributes

@return [Iterable::Response] A response object

# File lib/iterable/email_templates.rb, line 49
def upsert(client_template_id, attrs = {})
  attrs['clientTemplateId'] = client_template_id
  Iterable.request(conf, '/templates/email/upsert').post(attrs)
end