Module: Templates

Included in:
Content
Defined in:
lib/user/content/templates.rb

Instance Method Summary collapse

Instance Method Details

#create_template(data, options = nil) ⇒ Object

Create template.

Create a template with data.

Parameters

data

(Hash) – Data to be submitted.

Example

data = {
  title: 'New Template',
  slug: 'new/template-slug'
}
@data = @cxf_user.create_template(data)


53
54
55
# File 'lib/user/content/templates.rb', line 53

def create_template(data, options = nil)
  @client.raw('post', '/content/templates', options, data_transform(data))
end

#create_template_variant_option(id, data, options = nil) ⇒ Object

Create variant option for template.

Create a variant option for a template with data.

Parameters

id

(Integer) – template id.

data

(Hash) – Data to be submitted.

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

Example

data = {
  variant_option_id: 1
}
@data = @cxf_user.create_template_variant_option(1, data)


70
71
72
# File 'lib/user/content/templates.rb', line 70

def create_template_variant_option(id, data, options = nil)
  @client.raw('post', "/content/templates/#{id}/variant-option", options, data_transform(data))
end

#delete_template_variant_option(id, data, options = nil) ⇒ Object

Delete variant option from template.

Delete a variant option from a template.

Parameters

id

(Integer) – template id.

data

(Hash) – Data to be submitted.

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.



81
82
83
# File 'lib/user/content/templates.rb', line 81

def delete_template_variant_option(id, data, options = nil)
  @client.raw('delete', "/content/templates/#{id}/variant-option", options, data_transform(data))
end

#get_template(id, options = nil) ⇒ Object

Get template.

Get a template info.

Parameters

id

(Integer) – template id.

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

First Example

@data = @cxf_user.get_template(2)

Second Example

options = {
  fields: 'title'
}
@data = @cxf_user.get_template(1, options)


37
38
39
# File 'lib/user/content/templates.rb', line 37

def get_template(id, options = nil)
  @client.raw('get', "/content/templates/#{id}", options)
end

#get_templates(options = nil) ⇒ Object

Get templates.

Get a collection of templates.

Parameters

options

(Hash) – List of Resource Collection Options shown above can be used as parameter.

First Example

@data = @cxf_user.get_templates

Second Example

options = {
  fields: 'id, title'
}
@data = @cxf_user.get_templates(options)


18
19
20
# File 'lib/user/content/templates.rb', line 18

def get_templates(options = nil)
  @client.raw('get', '/content/templates', options)
end

#update_template(id, data) ⇒ Object

Update template.

Update a template info.

Parameters

id

(Integer) – template id.

data

(Hash) – Data to be submitted.

Example

data = {
  title: 'New Template Modified'
}
@data = @cxf_user.update_template(3, data)


97
98
99
# File 'lib/user/content/templates.rb', line 97

def update_template(id, data)
  @client.raw('put', "/content/templates/#{id}", nil, data_transform(data))
end