Method: Orchestrate::Client#put_event

Defined in:
lib/orchestrate/client.rb

#put_event(collection, key, event_type, timestamp, ordinal, body, ref = nil) ⇒ Object

Parameters:

  • collection (#to_s)

    The name of the collection.

  • key (#to_s)

    The name of the key.

  • event_type (#to_s)

    The category for the event.

  • timestamp (Time, Date, Integer, String, nil)

    The timestamp for the event. If a String, must match the Timestamp specification and include the milliseconds portion.

  • ordinal (Integer, #to_s)

    The ordinal for the event in the given timestamp.

  • body (#to_json)

    The value for the event.

  • ref (nil, #to_s) (defaults to: nil)

    If provided, used as If-Match, and event will only update if its current value has the provided ref. If omitted, updates the event regardless.

Returns:

  • Orchestrate::API::ItemResponse

Raises:

  • Orchestrate::API::NotFound The specified event doesn't exist.

  • Orchestrate::API::BadRequest If the body is not valid JSON.

  • Orchestrate::API::VersionMismatch The event's current value has a ref that does not match the provided ref.

  • Orchestrate::API::MalformedRef If the ref provided is not a valid ref.

[View source]

306
307
308
309
310
311
312
# File 'lib/orchestrate/client.rb', line 306

def put_event(collection, key, event_type, timestamp, ordinal, body, ref=nil)
  timestamp = API::Helpers.timestamp(timestamp)
  path = [collection, key, 'events', event_type, timestamp, ordinal]
  headers = {}
  headers['If-Match'] = API::Helpers.format_ref(ref) if ref
  send_request :put, path, { body: body, headers: headers, response: API::ItemResponse }
end