Module: Shushu::BEvent

Extended by:
BEvent
Included in:
BEvent
Defined in:
lib/models/b_event.rb

Constant Summary collapse

OPEN =
"open"
CLOSE =
"close"

Instance Method Summary collapse

Instance Method Details

#allObject



8
9
10
# File 'lib/models/b_event.rb', line 8

def all
  Shushu.handle_req {RestClient.get([Shushu.url, "/billable_events"].join, Shushu.headers)}
end

#close(args) ⇒ Object



19
20
21
22
23
24
# File 'lib/models/b_event.rb', line 19

def close(args)
  hid = args.delete(:hid) || args.delete("hid")
  entity_id = args.delete(:entity_id) || args.delete("entity_id")
  args[:state] = CLOSE
  Shushu.handle_req {RestClient.put(events_url(hid, entity_id), args, Shushu.headers)}
end

#events_url(hid, entity_id) ⇒ Object



26
27
28
# File 'lib/models/b_event.rb', line 26

def events_url(hid, entity_id)
  [Shushu.url, "/resources/#{hid}/billable_events/#{entity_id}"].join
end

#open(args) ⇒ Object



12
13
14
15
16
17
# File 'lib/models/b_event.rb', line 12

def open(args)
  hid = args.delete(:hid) || args.delete("hid")
  entity_id = args.delete(:entity_id) || args.delete("entity_id")
  args[:state] = OPEN
  Shushu.handle_req {RestClient.put(events_url(hid, entity_id), args, Shushu.headers)}
end