Class: OmniContacts::Importer::Linkedin

Inherits:
Middleware::OAuth2 show all
Includes:
ParseUtils
Defined in:
lib/omnicontacts/importer/linkedin.rb

Constant Summary

Constants included from HTTPUtils

HTTPUtils::SSL_PORT

Instance Attribute Summary collapse

Attributes inherited from Middleware::OAuth2

#client_id, #client_secret, #redirect_path

Attributes inherited from Middleware::BaseOAuth

#ssl_ca_file

Instance Method Summary collapse

Methods included from ParseUtils

#birthday_format, #email_to_name, #full_name, #image_url_from_email, #normalize_name

Methods inherited from Middleware::OAuth2

#fetch_contacts, #redirect_uri, #refresh_token_prop_name, #request_authorization_from_user

Methods included from Authorization::OAuth2

#authorization_url, #fetch_access_token, #refresh_access_token

Methods included from HTTPUtils

encode, host_url_from_rack_env, query_string_to_map, scheme, to_query_string

Methods inherited from Middleware::BaseOAuth

#call, #class_name

Constructor Details

#initialize(*args) ⇒ Linkedin

Returns a new instance of Linkedin.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/omnicontacts/importer/linkedin.rb', line 11

def initialize *args
  super *args
  @auth_host = "www.linkedin.com"
  @authorize_path = "/uas/oauth2/authorization"
  @auth_token_path = "/uas/oauth2/accessToken"
  @scope = (args[3] && args[3][:scope]) || "r_network"
  @contacts_host = "api.linkedin.com"
  @contacts_path = "/v1/people/~/connections:(id,first-name,last-name,picture-url)"
  @self_host = "www.linkedin.com"
  @profile_path = "/oauth2/v1/userinfo"
  @state = (args[3] && args[3][:state])
end

Instance Attribute Details

#auth_hostObject (readonly)

Returns the value of attribute auth_host.



9
10
11
# File 'lib/omnicontacts/importer/linkedin.rb', line 9

def auth_host
  @auth_host
end

#auth_token_pathObject (readonly)

Returns the value of attribute auth_token_path.



9
10
11
# File 'lib/omnicontacts/importer/linkedin.rb', line 9

def auth_token_path
  @auth_token_path
end

#authorize_pathObject (readonly)

Returns the value of attribute authorize_path.



9
10
11
# File 'lib/omnicontacts/importer/linkedin.rb', line 9

def authorize_path
  @authorize_path
end

#scopeObject (readonly)

Returns the value of attribute scope.



9
10
11
# File 'lib/omnicontacts/importer/linkedin.rb', line 9

def scope
  @scope
end

#stateObject (readonly)

Returns the value of attribute state.



9
10
11
# File 'lib/omnicontacts/importer/linkedin.rb', line 9

def state
  @state
end

Instance Method Details

#fetch_contacts_using_access_token(access_token, token_type) ⇒ Object



24
25
26
27
28
# File 'lib/omnicontacts/importer/linkedin.rb', line 24

def fetch_contacts_using_access_token access_token, token_type
  token_type = "Bearer" if token_type.nil?
  contacts_response = https_get(@contacts_host, @contacts_path, contacts_req_params, contacts_req_headers(access_token, token_type))
  contacts_from_response contacts_response
end