Permalink
Browse files

Move #errors to the base consumer, and add abstract methods.

  • Loading branch information...
1 parent 7b3316c commit e20a0c1b7160fd4247a05f1e2b8511859468ebab @oggy oggy committed Jun 27, 2010
Showing with 26 additions and 1 deletion.
  1. +26 −0 lib/contacts/consumer.rb
  2. +0 −1 lib/contacts/oauth_consumer.rb
View
@@ -61,6 +61,32 @@ def self.deserialize(string)
consumer
end
+ #
+ # Authorize the consumer's token from the given
+ # parameters. +params+ is the request parameters the user is
+ # redirected to your site with.
+ #
+ # Return true if authorization is successful, false otherwise. If
+ # unsuccessful, an error message is set in #error. Authorization
+ # may fail, for example, if the user denied access, or the
+ # authorization is forged.
+ #
+ def authorize(params)
+ raise NotImplementedError, 'abstract'
+ end
+
+ #
+ # An error message for the last call to #authorize.
+ #
+ attr_accessor :error
+
+ #
+ # Return the list of contacts, or nil if none could be retrieved.
+ #
+ def contacts
+ raise NotImplementedError, 'abstract'
+ end
+
protected
def initialize_serialized(data)
@@ -26,7 +26,6 @@ def serializable_data
attr_accessor :request_token
attr_accessor :access_token
- attr_accessor :error
def authentication_url(target, options={})
@request_token = consumer.get_request_token({:oauth_callback => target}, @request_token_params)

0 comments on commit e20a0c1

Please sign in to comment.