Class: Transloadit::Template

Inherits:
ApiModel show all
Defined in:
lib/transloadit/template.rb

Overview

Represents a Template API ready to interact with its corresponding REST API.

See the Transloadit documentation for further information on Templates and their parameters.

Instance Attribute Summary

Attributes inherited from ApiModel

#options, #transloadit

Instance Method Summary collapse

Methods inherited from ApiModel

#initialize, #inspect, #to_hash, #to_json

Constructor Details

This class inherits a constructor from Transloadit::ApiModel

Instance Method Details

#create(params) ⇒ Object

Submits a template to be created.

Parameters:

  • params (Hash)

    POST data to submit with the request. must contain keys ‘name’ and ‘template’

Options Hash (params):

  • :name (String)

    name assigned to the newly created template

  • :template (Hash)

    key, value pair of template content see template



20
21
22
# File 'lib/transloadit/template.rb', line 20

def create(params)
  _do_request("/templates", params, "post")
end

#delete(id, params = {}) ⇒ Object

Deletes the template object specified by the template id

Parameters:

  • id (String)

    id of the desired template

  • additional (Hash)

    POST data to submit with the request



60
61
62
# File 'lib/transloadit/template.rb', line 60

def delete(id, params = {})
  _do_request("/templates/#{id}", params, "delete")
end

#get(id, params = {}) ⇒ Object

Returns a single template object specified by the template id

Parameters:

  • id (String)

    id of the desired template

  • additional (Hash)

    GET data to submit with the request



37
38
39
# File 'lib/transloadit/template.rb', line 37

def get(id, params = {})
  _do_request("/templates/#{id}", params)
end

#list(params = {}) ⇒ Object

Returns a list of all templates

Parameters:

  • additional (Hash)

    GET data to submit with the request



28
29
30
# File 'lib/transloadit/template.rb', line 28

def list(params = {})
  _do_request("/templates", params)
end

#update(id, params = {}) ⇒ Object

Updates the template object specified by the template id

Parameters:

  • id (String)

    id of the desired template

  • additional (Hash)

    POST data to submit with the request must contain keys ‘name’ and ‘template’

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

    a customizable set of options

Options Hash (params):

  • :name (String)

    name assigned to the newly created template

  • :template (Hash)

    key, value pair of template content see template



51
52
53
# File 'lib/transloadit/template.rb', line 51

def update(id, params = {})
  _do_request("/templates/#{id}", params, "put")
end