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.
24 25 26 27 28 |
# File 'lib/gdata/client/calendar.rb', line 24 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
22 23 24 |
# File 'lib/gdata/client/calendar.rb', line 22 def @session_cookie end |
Instance Method Details
#auth_handler=(handler) ⇒ Object
Overrides auth_handler= so if the authentication changes, the session cookie is cleared.
32 33 34 35 |
# File 'lib/gdata/client/calendar.rb', line 32 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.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gdata/client/calendar.rb', line 38 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
50 51 52 53 54 55 |
# File 'lib/gdata/client/calendar.rb', line 50 def prepare_headers if @session_cookie @headers['cookie'] = @session_cookie end super end |