Class: GData::Client::Calendar
- Defined in:
- lib/gdata/client/calendar.rb
Overview
Client class to wrap working with the Calendar Data API.
Instance Attribute Summary collapse
-
#session_cookie ⇒ Object
Holds on to a session cookie.
Attributes inherited from Base
#auth_handler, #authsub_scope, #clientlogin_service, #clientlogin_url, #headers, #http_service, #source, #version
Instance Method Summary collapse
-
#auth_handler=(handler) ⇒ Object
Overrides auth_handler= so if the authentication changes, the session cookie is cleared.
-
#initialize(options = {}) ⇒ Calendar
constructor
A new instance of Calendar.
-
#make_request(method, url, body = '', retries = 4) ⇒ Object
Overrides make_request to handle 302 redirects with a session cookie.
-
#prepare_headers ⇒ Object
Custom prepare_headers to include the session cookie if it exists.
Methods inherited from Base
#authsub_private_key=, #authsub_token=, #authsub_url, #clientlogin, #delete, #get, #make_file_request, #post, #post_file, #put, #put_file
Constructor Details
#initialize(options = {}) ⇒ Calendar
Returns a new instance of Calendar.
25 26 27 28 29 |
# File 'lib/gdata/client/calendar.rb', line 25 def initialize( = {}) [:clientlogin_service] ||= 'cl' [:authsub_scope] ||= 'https://www.google.com/calendar/feeds/' super() end |
Instance Attribute Details
#session_cookie ⇒ Object
Holds on to a session cookie
23 24 25 |
# File 'lib/gdata/client/calendar.rb', line 23 def @session_cookie end |
Instance Method Details
#auth_handler=(handler) ⇒ Object
Overrides auth_handler= so if the authentication changes, the session cookie is cleared.
33 34 35 36 |
# File 'lib/gdata/client/calendar.rb', line 33 def auth_handler=(handler) @session_cookie = nil return super(handler) end |
#make_request(method, url, body = '', retries = 4) ⇒ Object
Overrides make_request to handle 302 redirects with a session cookie.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gdata/client/calendar.rb', line 39 def make_request(method, url, body = '', retries = 4) response = super(method, url, body) if response.status_code == 302 and retries > 0 @session_cookie = response.headers['set-cookie'] return self.make_request(method, url, body, retries - 1) else return response end end |
#prepare_headers ⇒ Object
Custom prepare_headers to include the session cookie if it exists
51 52 53 54 55 56 |
# File 'lib/gdata/client/calendar.rb', line 51 def prepare_headers if @session_cookie @headers['cookie'] = @session_cookie end super end |