Class: HolidayList::GoogleCalendarRequestString

Inherits:
Object
  • Object
show all
Includes:
RequestException
Defined in:
lib/holiday_list/google_calendar_request_string.rb

Overview

GoogleCalendarRequestString: Generates the google calendar api request string

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ GoogleCalendarRequestString

Returns a new instance of GoogleCalendarRequestString.



26
27
28
29
30
31
32
33
# File 'lib/holiday_list/google_calendar_request_string.rb', line 26

def initialize(configuration)
  argument_error! unless configuration.configured?

  key = configuration.key
  @id = configuration.id

  @params = Params.new(key)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



24
25
26
# File 'lib/holiday_list/google_calendar_request_string.rb', line 24

def id
  @id
end

#paramsObject (readonly)

Returns the value of attribute params.



24
25
26
# File 'lib/holiday_list/google_calendar_request_string.rb', line 24

def params
  @params
end

Class Method Details

.url_baseObject

TODO: address these items:

  • make class more extensible

  • rename class, redundat String, and is it really a ‘Request’?

  • don’t think ‘to_str’ is working. should work like:

    gcrs = GoogleCalendarRequestString.new(configuration)
    conn.get gcrs # '/calendar/v3/calendars/12345/events?time_min=yesterday'
    


16
17
18
# File 'lib/holiday_list/google_calendar_request_string.rb', line 16

def self.url_base
  'https://www.googleapis.com'
end

Instance Method Details

#to_sObject



35
36
37
# File 'lib/holiday_list/google_calendar_request_string.rb', line 35

def to_s
  "#{url_path}/#{id}/events?#{params}"
end

#url_pathObject



20
21
22
# File 'lib/holiday_list/google_calendar_request_string.rb', line 20

def url_path
  '/calendar/v3/calendars'
end