Class: Kaltura::Service::CategoryService

Inherits:
BaseService show all
Defined in:
lib/kaltura/service/category_service.rb

Overview

CategoryService is responsible for adding and managing Categories. Categories are the main means to filter entries within the KMC.

Examples:

Add a new category to the KMC filter list.

new_category = Kaltura::Category.new
new_category.name = "waffles"
client.category_service.add(new_category)

Get an existing category by ID.

client.category_service.get(214)

Update an existing category.

category_update = Kaltura::Category.new
category_update.description = "waffles are pretty freaking good."
client.category_service.update(214,category_update)

Delete an existing category.

client.category_service.delete(214)

List all categories with a parent_id of 2

category_filter = Kaltura::Filter::CategoryFilter.new
category_filter.parent_id_equal = 2
client.category_service.list(category_filter)

Instance Attribute Summary

Attributes inherited from BaseService

#client

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #perform_request

Constructor Details

This class inherits a constructor from Kaltura::Service::BaseService

Instance Method Details

#add(category) ⇒ Kaltura::Category

Adds a new Category.

Parameters:

  • category (Kaltura::Category)

    The category that will be created. The crucial field to fill out is name.

Returns:

  • (Kaltura::Category)

    Returns the category as it now appears on the server. It would be beneficial to save the ID of the category for later reference.

Raises:



40
41
42
43
44
# File 'lib/kaltura/service/category_service.rb', line 40

def add(category)
	kparams = {}
	client.add_param(kparams, 'category', category)
	perform_request('category','add',kparams,false)
end

#delete(id) ⇒ nil

Deletes the requested Category. I am fairly confident that this will not actually clear the category from each entry, but it is no longer a filter on the KMC.

Parameters:

  • id (Integer)

    The category ID to remove.

Returns:

  • (nil)

    Returns nothing.

Raises:



90
91
92
93
94
# File 'lib/kaltura/service/category_service.rb', line 90

def delete(id)
	kparams = {}
	client.add_param(kparams, 'id', id)
	perform_request('category','delete',kparams,false)
end

#get(id) ⇒ Kaltura::Category

Retrieves a category by it’s ID.

Parameters:

  • id (Integer)

    The Kaltura::Category object’s id.

Returns:

Raises:



55
56
57
58
59
# File 'lib/kaltura/service/category_service.rb', line 55

def get(id)
	kparams = {}
	client.add_param(kparams, 'id', id)
	perform_request('category','get',kparams,false)
end

#list(filter = nil) ⇒ Kaltura::Response::CategoryListResponse

Lists all Categories given the specified filter.

Parameters:

Returns:

Raises:



105
106
107
108
109
# File 'lib/kaltura/service/category_service.rb', line 105

def list(filter=nil)
	kparams = {}
	client.add_param(kparams, 'filter', filter)
	perform_request('category','list',kparams,false)
end

#update(id, category) ⇒ Kaltura::Category

Updates a category. The best practice as with all updates would be to insantiate a new Kaltura::Category and update specific fields.

Parameters:

  • id (Integer)

    The Kaltura::Category id of the category to be updated.

  • A (Kaltura::Category)

    newly insantiated Category object with the fields updated that you’d like to update.

Returns:

Raises:



72
73
74
75
76
77
# File 'lib/kaltura/service/category_service.rb', line 72

def update(id, category)
	kparams = {}
	client.add_param(kparams, 'id', id)
	client.add_param(kparams, 'category', category)
	perform_request('category','update',kparams,false)
end