Class: Cb::Clients::Recommendation

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/clients/recommendation.rb

Class Method Summary collapse

Class Method Details

.for_company(company_did) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cb/clients/recommendation.rb', line 55

def self.for_company(company_did)
  my_api = Cb::Utils::Api.new
  json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_company, :query => {:CompanyDID => company_did})

  jobs = []
  if json_hash.has_key?('Results')
    if json_hash['Results'].has_key?('JobRecommendation')
      json_hash['Results']['JobRecommendation']['Jobs'].each do |cur_job|
        jobs << Models::Job.new(cur_job)
      end
      my_api.append_api_responses(jobs, json_hash['Results']['JobRecommendation'])
    end

    my_api.append_api_responses(jobs, json_hash['Results'])
  end

  my_api.append_api_responses(jobs, json_hash)
end

.for_job(did, countlimit = '25', site_id = '', co_brand = '') ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cb/clients/recommendation.rb', line 7

def self.for_job(did, countlimit = '25', site_id = '', co_brand = '')
  my_api = Cb::Utils::Api.new
  json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_job,
                              :query => {:JobDID => did, :CountLimit => countlimit, :SiteID => site_id,
                                         :CoBrand => co_brand, :HostSite => Cb.configuration.host_site})

  jobs = []
  if json_hash.has_key?('ResponseRecommendJob')
    if json_hash['ResponseRecommendJob'].has_key?('RecommendJobResults') &&
       !json_hash['ResponseRecommendJob']['RecommendJobResults'].nil?

      json_hash['ResponseRecommendJob']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
        jobs << Models::Job.new(cur_job)
      end

      my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob']['Request'])
    end

    my_api.append_api_responses(jobs, json_hash['ResponseRecommendJob'])
  end

  my_api.append_api_responses(jobs, json_hash)
end

.for_user(external_id, countlimit = '25', site_id = '', co_brand = '') ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cb/clients/recommendation.rb', line 31

def self.for_user(external_id, countlimit = '25', site_id = '', co_brand = '')
  my_api = Cb::Utils::Api.new
  json_hash = my_api.cb_get(Cb.configuration.uri_recommendation_for_user,
                              :query => {:ExternalID => external_id, :CountLimit => countlimit, :SiteID => site_id, :CoBrand => co_brand,
                                         :HostSite => Cb.configuration.host_site})

  jobs = []
  if json_hash.has_key?('ResponseRecommendUser')

    if json_hash['ResponseRecommendUser'].has_key?('RecommendJobResults') &&
      !json_hash['ResponseRecommendUser']['RecommendJobResults'].nil?

      json_hash['ResponseRecommendUser']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
        jobs << Models::Job.new(cur_job)
      end
      my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser']['Request'])
    end

    my_api.append_api_responses(jobs, json_hash['ResponseRecommendUser'])
  end

  my_api.append_api_responses(jobs, json_hash)
end