Class: GoogleReaderApi::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/google-reader-api-uniq/api.rb

Constant Summary collapse

BASE_URL =
"http://www.google.com/reader/"

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Api

specify either the :email and :password or the :auth token you got in the past

:email

the user’s email address for login purposes

:password

the user’s password for login purposes

:auth

the auth token you got from a previous authentication request if you provide this you do not need to provide the email and password



19
20
21
22
23
24
25
26
# File 'lib/google-reader-api-uniq/api.rb', line 19

def initialize(options)
  if options[:auth]
    @auth = options[:auth]
  else
    request_auth(options[:email],options[:password])
  end
  @cache = GoogleReaderApi::Cache.new(2)
end

Instance Method Details

#cached_unread_countObject



40
41
42
# File 'lib/google-reader-api-uniq/api.rb', line 40

def cached_unread_count
  @cache['unread-count'] ||= get_link 'api/0/unread-count', :output => :json
end

do a get request to the link args is a hash of values that should be used in the request



30
31
32
33
# File 'lib/google-reader-api-uniq/api.rb', line 30

def get_link(link,args={})
  link = BASE_URL + link
  get_request(link,args)
end

#post_link(link, args = {}) ⇒ Object



35
36
37
38
# File 'lib/google-reader-api-uniq/api.rb', line 35

def post_link(link,args={})
  link = BASE_URL + link
  post_request(link,args)
end