Class: Evernotable::Client::User
- Inherits:
-
Base
- Object
- Base
- Evernotable::Client::User
show all
- Defined in:
- lib/evernotable/client/user.rb
Instance Attribute Summary
Attributes inherited from Base
#client_token, #current_user
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ User
Returns a new instance of User.
5
6
7
8
9
|
# File 'lib/evernotable/client/user.rb', line 5
def initialize(params={})
super
api = @config["user_api"][@env]
@instance = Evernote::UserStore.new(api, {:username => params[:user], :password => params[:password], :consumer_key => @config["api_credentials"]["consumer_key"], :consumer_secret => @config["api_credentials"]["consumer_secret"]})
end
|
Instance Method Details
#authenticate ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/evernotable/client/user.rb', line 11
def authenticate
self.wrap_method('attempt to authenticate the user') do
auth_result = @instance.authenticate
self.current_user = auth_result.user
self.client_token = auth_result.authenticationToken
end
end
|
#refresh_authentication ⇒ Object
19
20
21
|
# File 'lib/evernotable/client/user.rb', line 19
def refresh_authentication
self.wrap_method('attempt to refresh auth token') {|client_token| self.client_token = @instance.refreshAuthentication(client_token).authenticationToken}
end
|
#valid_version? ⇒ Boolean
23
24
25
|
# File 'lib/evernotable/client/user.rb', line 23
def valid_version?
self.wrap_method('attempt to check API version') { @instance.version_valid? }
end
|