Sha256: 4306a33f1d275ff8d4bec79af365f935eab421411c8ba5d0131494f0718f641f

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'rest-core'

# http://developer.linkedin.com/documents/linkedin-api-resource-map
module RestCore
  Linkedin = Builder.client do
    use Timeout       , 10

    use DefaultSite   , 'https://api.linkedin.com/'
    use DefaultHeaders, {'Accept' => 'application/json'}
    use DefaultQuery  , {'format' => 'json'}

    use Oauth1Header  ,
      'uas/oauth/requestToken', 'uas/oauth/accessToken',
      'https://www.linkedin.com/uas/oauth/authorize'

    use CommonLogger  , nil
    use Cache         , nil, 600 do
      use ErrorHandler, lambda{ |env|
        RuntimeError.new(env[RESPONSE_BODY]['message'])}
      use ErrorDetectorHttp
      use JsonResponse, true
    end
  end
end

module RestCore::Linkedin::Client
  include RestCore

  def me query={}, opts={}
    get('v1/people/~', query, opts)
  end

  def authorize_url
    url(authorize_path, :oauth_token => oauth_token, :format => false)
  end
end

RestCore::Linkedin.send(:include, RestCore::ClientOauth1)
RestCore::Linkedin.send(:include, RestCore::Linkedin::Client)
require 'rest-core/client/linkedin/rails_util' if
  Object.const_defined?(:Rails)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-more-2.0.2 lib/rest-core/client/linkedin.rb
rest-more-2.0.0 lib/rest-core/client/linkedin.rb