Module: Blocks

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

Instance Method Summary collapse

Instance Method Details

#create_block(data, options = nil) ⇒ Object

Create block.

Create a block with data.

Parameters

data

(Hash) – Data to be submitted.

Example

data = {
  user_id: 1,
  slug: "new-block",
  block_template_id: 1
}

options = { fields: 'id,slug' }

@data = @cxf_user.create_block(data, options)


77
78
79
# File 'lib/user/content/blocks.rb', line 77

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

#delete_block(id) ⇒ Object

Delete block.

Delete a block.

Parameters

id

(Integer) – block id.

Example

@data = @cxf_user.delete_block(6)


106
107
108
# File 'lib/user/content/blocks.rb', line 106

def delete_block(id)
  @client.raw('delete', "/content/blocks/#{id}")
end

#duplicate_block(id, data) ⇒ Object

Duplicate block.

Duplicate a block.

Parameters

id

(Integer) – block id.

data

(Hash) – Data to be submitted.

Example

data = { options: [] }
@data = @cxf_user.duplicate_block(1, data.to_json)


13
14
15
# File 'lib/user/content/blocks.rb', line 13

def duplicate_block(id, data)
  @client.raw('post', "/content/blocks/#{id}/duplicate", nil, data)
end

#get_block(id, options = nil) ⇒ Object

Get block.

Get a block info.

Parameters

id

(Integer) – block id.

options

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

First Example

@data = @cxf_user.get_block(1)

Second Example

options = {
  fields: 'id, slug'
}
@data = @cxf_user.get_block(1, options)


57
58
59
# File 'lib/user/content/blocks.rb', line 57

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

#get_blocks(options = nil, use_post = true) ⇒ Object

Get blocks.

Get a collection of blocks.

Parameters

options

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

use_post

(Boolean) – Variable to determine if the request is by ‘post’ or ‘get’ functions.

First Example

@data = @cxf_user.get_blocks

Second Example

options = {
  fields: 'id, slug'
}
@data = @cxf_user.get_blocks(options)

Third Example

options = {
  fields: 'id, slug'
}
@data = @cxf_user.get_blocks(options, true)


38
39
40
# File 'lib/user/content/blocks.rb', line 38

def get_blocks(options = nil, use_post = true)
  get_query_results('/content/blocks', options, use_post)
end

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

Update block.

Update a block info.

Parameters

id

(Integer) – block id.

data

(Hash) – Data to be submitted.

Example

data = {
  user_id: 1,
  slug: 'new-block'
}
@data = @cxf_user.update_block(5, data)


94
95
96
# File 'lib/user/content/blocks.rb', line 94

def update_block(id, data, options = nil)
  @client.raw('put', "/content/blocks/#{id}", options, data_transform(data))
end