class Evernote::UserStore

Constants

AuthenticationFailure

Public Class Methods

new(uri, credentials, thrift_client_options = {}) click to toggle source
# 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 } # convert any stringifyed hash keys into symbols
  
  @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

Public Instance Methods

authenticate() click to toggle source
# 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
method_missing(name, *args, &block) click to toggle source
# File lib/evernote/user_store.rb, line 34
def method_missing(name, *args, &block)
  @client.send(name, *args, &block)
end
validate_version() click to toggle source
# 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?() click to toggle source
# 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