Class: Gaah::Calendar::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/gaah/calendar/api.rb

Class Method Summary collapse

Class Method Details

.create_event(xoauth_requestor_id, options) ⇒ Object

API: Events#insert



19
20
21
22
23
24
25
# File 'lib/gaah/calendar/api.rb', line 19

def create_event(xoauth_requestor_id, options)
  url    = build_api_url(options.delete(:email))
  params = { xoauth_requestor_id: xoauth_requestor_id }
  body   = build_create_api_body(options)
  json   = ApiClient.instance.post(url, params, body)
  event  = JSON.load(json)
end

.event(xoauth_requestor_id, options) ⇒ Object

API: Events#get



28
29
30
31
32
33
34
35
# File 'lib/gaah/calendar/api.rb', line 28

def event(xoauth_requestor_id, options)
  base   = build_api_url(options.delete(:email))
  id     = options.delete(:event_id)
  url    = "#{base}/#{id}"
  params = { xoauth_requestor_id: xoauth_requestor_id }
  json   = ApiClient.instance.get(url, params)
  event  = JSON.load(json)
end

.events(xoauth_requestor_id, options) ⇒ Object

API: Events#list



10
11
12
13
14
15
16
# File 'lib/gaah/calendar/api.rb', line 10

def events(xoauth_requestor_id, options)
  url    = build_api_url(options[:email])
  params = build_events_api_params(xoauth_requestor_id, options)
  json   = ApiClient.instance.get(url, params)
  events = JSON.load(json)
  Event.batch_create(events['items'])
end