lib/sredder/wrike_auth.rb in sredder-0.0.4 vs lib/sredder/wrike_auth.rb in sredder-0.0.5
- old
+ new
@@ -1,7 +1,8 @@
require 'oauth'
require 'forwardable'
+require 'debugger'
module Sredder
WRIKE_OAUTH_OPTIONS = {
:site => 'https://www.wrike.com',
@@ -15,11 +16,11 @@
extend Forwardable
attr_accessor :sredderc
attr_writer :consumer
- def_delegators :sredderc, :token, :token=, :secret, :secret=
+ def_delegators :sredderc, :credentials, :credentials=
def initialize(sredderc = Sredderc.new)
@sredderc = sredderc
@sredderc.load
end
@@ -37,16 +38,16 @@
store_tokens(@request_token.get_access_token)
end
def authorized?
- !!token && !!secret
+ !!credentials[:wrike_token] && !!credentials[:wrike_secret]
end
def oauth_access_token
if @access_token || authorized?
- @access_token ||= OAuth::AccessToken.new(consumer, secret, token)
+ @access_token ||= OAuth::AccessToken.new(consumer, credentials[:wrike_token], credentials[:wrike_secret])
end
end
private
@@ -62,11 +63,11 @@
'4216face9995a5d6'
end
def store_tokens(access_token)
@access_token = access_token
- self.secret = access_token.token
- self.token = access_token.secret
+ self.credentials[:wrike_secret] = access_token.secret
+ self.credentials[:wrike_token] = access_token.token
sredderc.save
end
end