Class: Hatena::API::Auth
- Inherits:
-
Object
- Object
- Hatena::API::Auth
- Defined in:
- lib/hatena/api/auth.rb
Constant Summary collapse
- BASE_URI =
'http://auth.hatena.ne.jp/'
- PATH =
{ :auth => '/auth', :json => '/api/auth.json' }.freeze
- VERSION =
'0.1.0'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Auth
constructor
A new instance of Auth.
- #login(cert) ⇒ Object
- #uri_to_login ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Auth
Returns a new instance of Auth.
28 29 30 31 |
# File 'lib/hatena/api/auth.rb', line 28 def initialize( = {}) @api_key = [:api_key] @secret = [:secret] end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
27 28 29 |
# File 'lib/hatena/api/auth.rb', line 27 def api_key @api_key end |
#secret ⇒ Object
Returns the value of attribute secret.
27 28 29 |
# File 'lib/hatena/api/auth.rb', line 27 def secret @secret end |
Instance Method Details
#login(cert) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hatena/api/auth.rb', line 40 def login(cert) result = JSON.parse open( uri_to_authcheck(cert), 'User-Agent' => "#{self.class}/#{VERSION} - Ruby" ).read if result['has_error'] raise AuthError.new(result['error']['message']) else result['user'] end end |