Class: Cb::Clients::Company

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

Class Method Summary collapse

Methods inherited from Base

cb_client, headers

Class Method Details

.find_by_did(did) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cb/clients/company.rb', line 16

def self.find_by_did(did)
  json_hash = cb_client.cb_get(Cb.configuration.uri_company_find,
                               query: { CompanyDID: did, hostsite: Cb.configuration.host_site })

  if json_hash.key?('Results')
    if json_hash['Results'].key?('CompanyProfileDetail')
      company = Models::Company.new(json_hash['Results']['CompanyProfileDetail'])
    end
    cb_client.append_api_responses(company, json_hash['Results'])
  end

  cb_client.append_api_responses(company, json_hash)
end

.find_for(obj) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/cb/clients/company.rb', line 30

def self.find_for(obj)
  if obj.is_a?(String)
    did = obj
  elsif obj.is_a?(Cb::Models::Job)
    did = obj.company_did
  end
  did ||= ''

  find_by_did did unless did.empty?
end