Class: LinkedIn::Client
Constant Summary
collapse
- HTTP_METHODS =
[:get, :post, :put, :patch, :delete, :headers].freeze
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.
14
15
16
17
|
# File 'lib/linkedin/client.rb', line 14
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
47
48
49
50
|
# File 'lib/linkedin/client.rb', line 47
def method_missing(method, *args, &body)
return simple_request(method, args[0], (args[1] || {}), &body) if HTTP_METHODS.include? method
super
end
|
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
10
11
12
|
# File 'lib/linkedin/client.rb', line 10
def access_token
@access_token
end
|
Class Method Details
.default_config ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/linkedin/client.rb', line 52
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
42
43
44
45
|
# File 'lib/linkedin/client.rb', line 42
def access_token_request(method, path, opts={}, &block)
response = access_token.send method, path, opts, &block
response.body
end
|
#connection ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/linkedin/client.rb', line 19
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
|