module SendGrid4r::REST::TransactionalTemplates

SendGrid Web API v3 Template Engine - Templates

SendGrid Web API v3 Template Engine - Templates

Constants

Template
Templates

Public Class Methods

create_template(resp) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 26
def self.create_template(resp)
  return resp if resp.nil?
  vers = resp['versions'].map do |ver|
    TransactionalTemplates::Versions.create_version(ver)
  end
  Template.new(resp['id'], resp['name'], vers)
end
create_templates(resp) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 18
def self.create_templates(resp)
  return resp if resp.nil?
  tmps = resp['templates'].map do |template|
    TransactionalTemplates.create_template(template)
  end
  Templates.new(tmps)
end
url(temp_id = nil) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 12
def self.url(temp_id = nil)
  url = "#{BASE_URL}/templates"
  url = "#{url}/#{temp_id}" unless temp_id.nil?
  url
end

Public Instance Methods

delete_template(template_id:, &block) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 65
def delete_template(template_id:, &block)
  endpoint = TransactionalTemplates.url(template_id)
  delete(@auth, endpoint, &block)
end
get_template(template_id:, &block) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 49
def get_template(template_id:, &block)
  endpoint = TransactionalTemplates.url(template_id)
  resp = get(@auth, endpoint, &block)
  finish(resp, @raw_resp) do |r|
    TransactionalTemplates.create_template(r)
  end
end
get_templates(&block) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 42
def get_templates(&block)
  resp = get(@auth, TransactionalTemplates.url, &block)
  finish(resp, @raw_resp) do |r|
    TransactionalTemplates.create_templates(r)
  end
end
patch_template(template_id:, name:, &block) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 57
def patch_template(template_id:, name:, &block)
  endpoint = TransactionalTemplates.url(template_id)
  resp = patch(@auth, endpoint, name: name, &block)
  finish(resp, @raw_resp) do |r|
    TransactionalTemplates.create_template(r)
  end
end
post_template(name:, &block) click to toggle source
# File lib/sendgrid4r/rest/transactional_templates/templates.rb, line 34
def post_template(name:, &block)
  endpoint = TransactionalTemplates.url
  resp = post(@auth, endpoint, name: name, &block)
  finish(resp, @raw_resp) do |r|
    TransactionalTemplates.create_template(r)
  end
end