Module: Yourub::REST::Categories

Included in:
API
Defined in:
lib/yourub/rest/categories.rb

Class Method Summary collapse

Class Method Details

.for_country(client, country) ⇒ Object

it returns an Array containing the categories for the given country, or the DEFAULT_COUNTRY if no countries was given.

Examples:

client = Yourub::Client.new
categories = Yourub::REST::Categories.for_country(client, ["US"])

Parameters:



17
18
19
20
21
22
23
24
25
26
# File 'lib/yourub/rest/categories.rb', line 17

def for_country(client, country)
  categories = []
  param = {"part" => "snippet","regionCode" => country }
  categories_list = video_categories_list_request(client, param)
  categories_list.data.items.each do |cat_result|
    category_name = parse_name(cat_result["snippet"]["title"])
    categories.push(cat_result["id"] => category_name)
  end
  return categories
end