Class: LinkedIn::Client
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included
#config, #reset
#configure, #defaults, #load
Constructor Details
#initialize(options = {}, &block) ⇒ Client
Returns a new instance of Client.
12
13
14
15
|
# File 'lib/linkedin/client.rb', line 12
def initialize(options={}, &block)
configure options, &block
self.access_token ||= self.config[:access_token].to_s
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &body) ⇒ Object
45
46
47
48
|
# File 'lib/linkedin/client.rb', line 45
def method_missing(method, *args, &body)
return simple_request(method, args[0], (args[1] || {}), &body) if %i(get post put patch delete headers).include? method
super
end
|
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
8
9
10
|
# File 'lib/linkedin/client.rb', line 8
def access_token
@access_token
end
|
Class Method Details
.default_config ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/linkedin/client.rb', line 50
def self.default_config
{
authorize_path: '/uas/oauth2/authorization',
access_token_path: '/uas/oauth2/accessToken',
api_host: 'https://api.linkedin.com',
auth_host: 'https://www.linkedin.com',
request_format: :json,
key: nil,
secret: nil,
access_token: nil,
scope: 'r_basicprofile',
state: Utils.generate_random_state,
redirect_uri: 'http://localhost',
logger: Logger.new('/dev/null')
}
end
|
Instance Method Details
#access_token_request(method, path, opts = {}, &block) ⇒ Object
40
41
42
43
|
# File 'lib/linkedin/client.rb', line 40
def access_token_request(method, path, opts={}, &block)
response = access_token.send method, path, opts, &block
response.body
end
|
#connection ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/linkedin/client.rb', line 17
def connection
@connection ||= OAuth2::Client.new(config.key, config.secret, oauth2_options) do |faraday|
faraday.request :url_encoded
faraday.request :json
faraday.request :linkedin_format, defaults(:request_format)
faraday.response :linkedin_errors
faraday.response :logger, config.logger
faraday.response :json, content_type: /\bjson$/
faraday.adapter :net_http
end
end
|