Class: ConnectClient::Http::EventEndpoint
- Inherits:
-
Object
- Object
- ConnectClient::Http::EventEndpoint
- Defined in:
- lib/connect_client/http/event_endpoint.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ EventEndpoint
constructor
A new instance of EventEndpoint.
- #push(collection_name, event) ⇒ Object
- #push_batch(events_by_collection) ⇒ Object
Constructor Details
#initialize(config) ⇒ EventEndpoint
Returns a new instance of EventEndpoint.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# 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 |
Instance Method Details
#push(collection_name, event) ⇒ Object
25 26 27 28 29 |
# 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) ⇒ Object
31 32 33 34 35 |
# 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 |