Please forgive me

This commit is contained in:
Chris Blanchard 2016-02-05 16:58:10 +00:00
parent c19e0a056c
commit a496589d14

View file

@ -39,7 +39,7 @@ end
class GoogleCalendar
class Request
BASE_URL = "https://www.googleapis.com/calendar/v3/calendars"
BASE_URL = "https://www.googleapis.com/"
EVENTS_ENDPOINT = "events"
def self.events_list(id, timezone_offset)
@ -61,7 +61,12 @@ class GoogleCalendar
def get_data
Rails.cache.fetch(cache_key, expires_in: 5.minutes) do
Faraday.get(request_url)
if Rails.env.development?
conn = Faraday.new(BASE_URL, ssl: {verify: false})
else
conn = Faraday.new(BASE_URL)
end
conn.get(request_url)
end
end
@ -76,7 +81,7 @@ class GoogleCalendar
#that is longer ago then 7 days.
#Alternative: maxResults=2500
time_min = (Time.now - 7.days).utc.iso8601
"#{BASE_URL}/#{@id}/#{@endpoint}/?key=#{ENV['GOOGLE_API_KEY']}&timeMin=#{time_min}"
"calendar/v3/calendars/#{@id}/#{@endpoint}/?key=#{ENV['GOOGLE_API_KEY']}&timeMin=#{time_min}"
end
end