class ConnectClient::Http::EventEndpoint

Public Class Methods

new(config) click to toggle source
# File lib/connect_client/http/event_endpoint.rb, line 8
def initialize(config)
  headers = {
    "Content-Type" => "application/json", 
    "Accept" => "application/json",
    "Accept-Encoding" => "identity",
    "X-Api-Key" => config.api_key,
    "X-Project-Id" => config.project_id
  }

  if config.async
    @http = EmHttp.new config.base_url, headers
  else
    @http = NetHttp.new config.base_url, headers
  end

end

Public Instance Methods

push(collection_name, event) click to toggle source
# File lib/connect_client/http/event_endpoint.rb, line 25
def push(collection_name, event)
  path_uri_part = "/events/#{CGI.escape(collection_name.to_s)}"

  @http.push_events path_uri_part, event.data.to_json, event
end
push_batch(events_by_collection) click to toggle source
# File lib/connect_client/http/event_endpoint.rb, line 31
def push_batch(events_by_collection)
  path_uri_part = "/events"

  @http.push_events path_uri_part, events_by_collection.to_json, events_by_collection
end