25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/cb/clients/category.rb', line 25
def self.search_by_host_site(host_site)
my_api = Cb::Utils::Api.instance
json_hash = my_api.cb_get(Cb.configuration.uri_job_category_search, :query => {:CountryCode => host_site})
categoryList = []
if json_hash.has_key?('ResponseCategories')
if json_hash['ResponseCategories'].has_key?('Categories')
if json_hash['ResponseCategories']['Categories']['Category'].is_a?(Array)
json_hash['ResponseCategories']['Categories']['Category'].each do |cat|
categoryList << Models::Category.new(cat)
end
elsif json_hash['ResponseCategories']['Categories']['Category'].is_a?(Hash) && json_hash.length < 2
categoryList << Models::Category.new(json_hash['ResponseCategories']['Categories']['Category'])
end
end
my_api.append_api_responses(categoryList, json_hash['ResponseCategories'])
end
my_api.append_api_responses(categoryList, json_hash)
end
|