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.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/connect_client/http/event_endpoint.rb', line 7 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 = Async.new config.base_url, headers else @http = Sync.new config.base_url, headers end end |
Instance Method Details
#push(collection_name, event) ⇒ Object
24 25 26 27 28 |
# File 'lib/connect_client/http/event_endpoint.rb', line 24 def push(collection_name, event) path_uri_part = "/events/#{collection_name}" @http.send path_uri_part, event.data.to_json, event end |
#push_batch(events_by_collection) ⇒ Object
30 31 32 33 34 |
# File 'lib/connect_client/http/event_endpoint.rb', line 30 def push_batch(events_by_collection) path_uri_part = "/events" @http.send path_uri_part, events_by_collection.to_json, events_by_collection end |