Class: LinkedinClient
- Inherits:
-
BaseApiClient
- Object
- Base
- BaseApiClient
- LinkedinClient
- Defined in:
- lib/whos_using_what/api_clients/linkedin_client.rb
Constant Summary collapse
- @@json_indicator =
"format=json"
- @@base_url =
"http://api.linkedin.com/v1/"
- @@linkedin_tech_industry_codes =
"80"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(api_key, api_secret, user_token, user_secret, url) ⇒ LinkedinClient
constructor
A new instance of LinkedinClient.
- #json_api_call_helper(base_url, params, skip_params = false) ⇒ Object
- #query_companies(location_code, company_size, params) ⇒ Object
- #query_people_from_company(company_name, location) ⇒ Object
- #query_people_from_company_ids(company_ids, title, location) ⇒ Object
Methods inherited from BaseApiClient
arraySearch, arry_to_str_delim, cleanup_url, #determineIfUsesTechnology, prepare_params_from_map_helper, starts_with?
Methods inherited from Base
Constructor Details
#initialize(api_key, api_secret, user_token, user_secret, url) ⇒ LinkedinClient
Returns a new instance of LinkedinClient.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/whos_using_what/api_clients/linkedin_client.rb', line 16 def initialize(api_key, api_secret, user_token, user_secret, url) super() @consumer = OAuth::Consumer.new(api_key, api_secret, { :site => url, # :scope => "r_basicprofile+r_emailaddress+r_network" }) @consumer.[:request_token_path] = @consumer.[:request_token_path] << "?scope=r_fullprofile+r_emailaddress+r_network" @access_token = OAuth::AccessToken.new(@consumer, user_token, user_secret) end |
Instance Method Details
#json_api_call_helper(base_url, params, skip_params = false) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/whos_using_what/api_clients/linkedin_client.rb', line 101 def json_api_call_helper (base_url, params, skip_params = false) url = base_url.clone if !skip_params url = BaseApiClient.prepare_params_from_map_helper(base_url, params) end #remove white spaces, for ease in reading queries, they may have white spaces / line breaks url = url.gsub(/\s+/, "") puts url json = @access_token.get(url << "&" << @@json_indicator) puts json.body JSON.parse(json.body) end |
#query_companies(location_code, company_size, params) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/whos_using_what/api_clients/linkedin_client.rb', line 31 def query_companies location_code, company_size, params base_url = @@base_url << "company-search:( companies:( id, name, universal-name, website-url, industries, logo-url, employee-count-range, locations ) )?facets=industry,location,company-size" << "&facet=industry," << @@linkedin_tech_industry_codes << "&facet=location," << location_code << "&facet=company-size,C,D,E,F,G,H,I" json_api_call_helper(base_url, params) end |
#query_people_from_company(company_name, location) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/whos_using_what/api_clients/linkedin_client.rb', line 55 def query_people_from_company company_name, location company_name = company_name.gsub(/\s+/, "+") location = location.gsub(/\s+/, "+") base_url_tmp = @@base_url.clone url = base_url_tmp << "people-search:(people:(id,first-name,last-name,public-profile-url,picture-url,headline),num-results)" << "?company-name=" << company_name << "," << "&location=" << location << "¤t-company=true" json_api_call_helper url, {} end |
#query_people_from_company_ids(company_ids, title, location) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/whos_using_what/api_clients/linkedin_client.rb', line 72 def query_people_from_company_ids company_ids, title, location location = location.gsub(/\s+/, "+") base_url_tmp = @@base_url.clone company_id_str = "" i = 1 company_ids.each do |company_id| delim = "" if i != 1 delim = "," end company_id_str = company_id_str << delim << company_id i += i end url = base_url_tmp << "people-search:(people:(id,first-name,last-name,public-profile-url,picture-url,headline),num-results)" << "?facets=location,current-company" << "&facet=location," << location << "&facet=current-company," << company_id_str "¤t-title=" << title json_api_call_helper url, {}, true end |