Class: Iterable::PushTemplates

Inherits:
ApiResource show all
Defined in:
lib/iterable/push_templates.rb

Overview

Interact with /templates/push API endpoints

Examples:

Creating push templates endpoint object

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

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

Instance Attribute Summary

Attributes inherited from ApiResource

#conf

Instance Method Summary collapse

Methods inherited from ApiResource

#default_config, default_config, #initialize

Constructor Details

This class inherits a constructor from Iterable::ApiResource

Instance Method Details

#get(template_id, params = {}) ⇒ Iterable::Response

Get a push template

Parameters:

  • template_id (String|Integer)

    A push template ID

  • params (Hash) (defaults to: {})

    Additional params to use such as locale

Returns:



23
24
25
26
# File 'lib/iterable/push_templates.rb', line 23

def get(template_id, params = {})
  params['templateId'] = template_id
  Iterable.request(conf, '/templates/push/get', params).get
end

#update(template_id, attrs = {}) ⇒ Iterable::Response

Update a push template

Parameters:

  • template_id (String|Integer)

    A push template ID

  • attrs (Hash) (defaults to: {})

    Update attributes

Returns:



36
37
38
39
# File 'lib/iterable/push_templates.rb', line 36

def update(template_id, attrs = {})
  attrs['templateId'] = template_id
  Iterable.request(conf, '/templates/push/update').post(attrs)
end

#upsert(client_template_id, attrs = {}) ⇒ Iterable::Response

Upsert a push template by client template ID

Parameters:

  • client_template_id (String)

    A client template id to use or create

  • attrs (Hash) (defaults to: {})

    Update attributes

Returns:



49
50
51
52
# File 'lib/iterable/push_templates.rb', line 49

def upsert(client_template_id, attrs = {})
  attrs['clientTemplateId'] = client_template_id
  Iterable.request(conf, '/templates/push/upsert').post(attrs)
end