Class: LinkedIn::Client
- Inherits:
-
Object
- Object
- LinkedIn::Client
- Extended by:
- Forwardable
- Defined in:
- lib/linkedin/client.rb
Constant Summary collapse
- HTTP_METHODS =
[:get, :post, :put, :patch, :delete, :headers].freeze
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Attributes included from API::Authentication
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(options = {}, &block) ⇒ Client
constructor
A new instance of Client.
- #method_missing(method, *args, &body) ⇒ Object
- #profile_fields ⇒ Object
Methods included from API::Companies
Methods included from API::NetworkUpdates
#network_update_comments, #network_update_likes, #network_updates
Methods included from API::Profiles
#connect_with, #connections, #message, #profile, #profile_api, #search, #shared_connections
Methods included from API::Authentication
#authorize_url, #request_access_token
Methods included from Configuration
Methods included from LinkedIn::Configuration::InstanceConfiguration
Methods included from LinkedIn::Configuration::BaseConfiguration
Constructor Details
#initialize(options = {}, &block) ⇒ Client
Returns a new instance of Client.
17 18 19 20 |
# File 'lib/linkedin/client.rb', line 17 def initialize(={}, &block) configure , &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
57 58 59 60 |
# File 'lib/linkedin/client.rb', line 57 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.
13 14 15 |
# File 'lib/linkedin/client.rb', line 13 def access_token @access_token end |
Class Method Details
.default_config ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/linkedin/client.rb', line 62 def self.default_config { 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
#connection ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/linkedin/client.rb', line 26 def connection @connection ||= OAuth2::Client.new config.key, config.secret, do |faraday| faraday.request :url_encoded faraday.request :json faraday.request :linkedin_format, config.request_format faraday.response :mashify faraday.response :linkedin_errors faraday.response :logger, config.logger faraday.response :json, content_type: /\bjson$/ faraday.adapter :net_http end end |
#profile_fields ⇒ Object
50 51 52 53 54 55 |
# File 'lib/linkedin/client.rb', line 50 def profile_fields scopes = config.scope unless config.scope.respond_to?(:values) scopes ||= config.scope scopes.reduce([]) { |fields, scope| fields + LinkedIn.send(scope) } end |