Module: Bundles

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

Instance Method Summary collapse

Instance Method Details

#create_bundle(data, options = nil) ⇒ Object

Create bundle.

Create a bundle with data.

Parameters

data

(Hash) – Data to be submitted.

Example

data = {
  user_id: 1,
  slug: "new-bundle",
  bundle_template_id: 1
}

options = { fields: 'id,slug' }

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


64
65
66
# File 'lib/user/content/bundles.rb', line 64

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

#delete_bundle(id) ⇒ Object

Delete bundle.

Delete a bundle.

Parameters

id

(Integer) – bundle id.

Example

@data = @cxf_user.delete_bundle(6)


93
94
95
# File 'lib/user/content/bundles.rb', line 93

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

#get_bundle(id, options = nil) ⇒ Object

Get bundle.

Get a bundle info.

Parameters

id

(Integer) – bundle id.

options

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

First Example

@data = @cxf_user.get_bundle(1)

Second Example

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


44
45
46
# File 'lib/user/content/bundles.rb', line 44

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

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

Get bundles.

Get a collection of bundles.

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_bundles

Second Example

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

Third Example

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


25
26
27
# File 'lib/user/content/bundles.rb', line 25

def get_bundles(options = nil, use_post = true)
  get_query_results('/content/bundles', options, use_post)
end

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

Update bundle.

Update a bundle info.

Parameters

id

(Integer) – bundle id.

data

(Hash) – Data to be submitted.

Example

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


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

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