Class: Cronofy::Client::BatchBuilder

Inherits:
Object
  • Object
show all
Includes:
TimeEncoding
Defined in:
lib/cronofy/client.rb

Instance Method Summary collapse

Methods included from TimeEncoding

#encode_event_time, #to_iso8601

Constructor Details

#initializeBatchBuilder

Returns a new instance of BatchBuilder.



336
337
338
# File 'lib/cronofy/client.rb', line 336

def initialize
  @entries = []
end

Instance Method Details

#add_entry(args) ⇒ Object



359
360
361
362
# File 'lib/cronofy/client.rb', line 359

def add_entry(args)
  @entries << BatchEntryRequest.new(args)
  nil
end

#buildObject



364
365
366
# File 'lib/cronofy/client.rb', line 364

def build
  @entries.dup
end

#delete_event(calendar_id, event_id) ⇒ Object



351
352
353
# File 'lib/cronofy/client.rb', line 351

def delete_event(calendar_id, event_id)
  delete "/v1/calendars/#{calendar_id}/events", event_id: event_id
end

#delete_external_event(calendar_id, event_uid) ⇒ Object



355
356
357
# File 'lib/cronofy/client.rb', line 355

def delete_external_event(calendar_id, event_uid)
  delete "/v1/calendars/#{calendar_id}/events", event_uid: event_uid
end

#upsert_event(calendar_id, event) ⇒ Object Also known as: create_or_update_event



340
341
342
343
344
345
346
347
# File 'lib/cronofy/client.rb', line 340

def upsert_event(calendar_id, event)
  data = event.dup

  data[:start] = encode_event_time(data[:start])
  data[:end] = encode_event_time(data[:end])

  post "/v1/calendars/#{calendar_id}/events", data
end