Class: Evernote::UserStore
- Inherits:
-
Object
- Object
- Evernote::UserStore
show all
- Defined in:
- lib/evernote/user_store.rb
Constant Summary
collapse
- AuthenticationFailure =
Class.new(StandardError)
Instance Method Summary
collapse
Constructor Details
#initialize(uri, credentials, thrift_client_options = {}) ⇒ UserStore
Returns a new instance of UserStore.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/evernote/user_store.rb', line 8
def initialize(uri, credentials, thrift_client_options = {})
raise ArgumentError, "credentials must be passed in as a hash" unless credentials.is_a? Hash
credentials=credentials.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
@consumer_key = credentials[:consumer_key]
@consumer_secret = credentials[:consumer_secret]
@username = credentials[:username]
@password = credentials[:password]
unless @consumer_key && @consumer_secret && @username && @password
raise ArgumentError, "'consumer_key', 'consumer_secret', 'username' and 'password' are required"
end
@client = Evernote::Client.new(Evernote::EDAM::UserStore::UserStore::Client, uri, thrift_client_options)
validate_version
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
34
35
36
|
# File 'lib/evernote/user_store.rb', line 34
def method_missing(name, *args, &block)
@client.send(name, *args, &block)
end
|
Instance Method Details
#authenticate ⇒ Object
28
29
30
31
32
|
# File 'lib/evernote/user_store.rb', line 28
def authenticate
@client.authenticate(@username, @password, @consumer_key, @consumer_secret)
rescue Evernote::EDAM::Error::EDAMUserException
raise AuthenticationFailure
end
|
#validate_version ⇒ Object
38
39
40
|
# File 'lib/evernote/user_store.rb', line 38
def validate_version
raise VersionOutOfDate, "The vendored Evernote client code is out of date and needs to be regenerated" unless version_valid?
end
|
#version_valid? ⇒ Boolean
42
43
44
|
# File 'lib/evernote/user_store.rb', line 42
def version_valid?
checkVersion("Ruby EDAMTest", Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR, Evernote::EDAM::UserStore::EDAM_VERSION_MINOR)
end
|