summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/evernote/client.rb12
-rw-r--r--lib/evernote/user_store.rb17
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/evernote/client.rb b/lib/evernote/client.rb
index 1141087..e6962dc 100644
--- a/lib/evernote/client.rb
+++ b/lib/evernote/client.rb
@@ -1,13 +1,19 @@
+require 'forwardable'
+
module Evernote
class Client
-
+
THRIFT_DEFAULTS = {
:transport => Thrift::HTTPClientTransport
}.freeze
def initialize(klass, url, thrift_client_options = {})
thrift_opts = THRIFT_DEFAULTS.merge(thrift_client_options)
- ThriftClient.new(klass, url, thrift_opts)
+ @client = ThriftClient.new(klass, url, thrift_opts)
+ end
+
+ def method_missing(name, *args, &block)
+ @client.send(name, *args, &block)
end
end
-end \ No newline at end of file
+end
diff --git a/lib/evernote/user_store.rb b/lib/evernote/user_store.rb
index 1be8cb6..2b60756 100644
--- a/lib/evernote/user_store.rb
+++ b/lib/evernote/user_store.rb
@@ -1,5 +1,10 @@
module Evernote
+
+ VersionOutOfDate = Class.new(StandardError)
+
class UserStore
+ attr_reader :client
+
def initialize(uri, opts = {}, thrift_client_options = {})
@consumer_key = opts[:consumer_key]
@consumer_secret = opts[:consumer_secret]
@@ -10,7 +15,17 @@ module Evernote
raise ArgumentError, ":consumer_key, :consumer_secret, :username and :password are required"
end
- Evernote::Client.new(Evernote::EDAM::UserStore::UserStore::Client, uri, thrift_client_options)
+ @client = Evernote::Client.new(Evernote::EDAM::UserStore::UserStore::Client, uri, thrift_client_options)
+
+ validate_version
+ end
+
+ def validate_version
+ raise VersionOutOfDate, "The vendored Evernote client code is out of date and needs to be regenerated" unless version_valid?
+ end
+
+ def version_valid?
+ @client.checkVersion("Ruby EDAMTest", Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR, Evernote::EDAM::UserStore::EDAM_VERSION_MINOR)
end
end
end