Class: Gosns::Linkedin

Inherits:
Sns
  • Object
show all
Defined in:
lib/provider/linkedin.rb

Class Attribute Summary collapse

Attributes inherited from Sns

#account

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sns

#initialize

Constructor Details

This class inherits a constructor from Gosns::Sns

Class Attribute Details

.keyObject

Returns the value of attribute key.



5
6
7
# File 'lib/provider/linkedin.rb', line 5

def key
  @key
end

.redirect_uriObject

Returns the value of attribute redirect_uri.



5
6
7
# File 'lib/provider/linkedin.rb', line 5

def redirect_uri
  @redirect_uri
end

.secretObject

Returns the value of attribute secret.



5
6
7
# File 'lib/provider/linkedin.rb', line 5

def secret
  @secret
end

Class Method Details

.get_token(code) ⇒ Object



22
23
24
# File 'lib/provider/linkedin.rb', line 22

def get_token(code)
  oauth_client.auth_code.get_token(code, redirect_uri: redirect_uri).token
end

.oauth_authorize_urlObject



6
7
8
9
10
11
12
# File 'lib/provider/linkedin.rb', line 6

def oauth_authorize_url
  state = 'DCEeFWf45A53sdfKef424'
  oauth_client.auth_code.authorize_url(
    redirect_uri: redirect_uri,
    state: state,
  )
end

.oauth_clientObject



13
14
15
16
17
18
19
20
# File 'lib/provider/linkedin.rb', line 13

def oauth_client
  option = {
    site: 'https://www.linkedin.com',
    authorize_url: "/uas/oauth2/authorization",
    token_url: "/uas/oauth2/accessToken"
  }
  OAuth2::Client.new(key, secret, option)
end

Instance Method Details

#followersObject



27
28
29
30
# File 'lib/provider/linkedin.rb', line 27

def followers
  JSON.parse(r.body)['followStatistics']['count']
  Helper::parse_int Helper::at_css("https://www.linkedin.com/company/#{}", '.followers-count')
end