Class: Lescopr::Transport::HttpClient
- Inherits:
-
Object
- Object
- Lescopr::Transport::HttpClient
- Defined in:
- lib/lescopr/transport/http_client.rb
Overview
HTTPS batch transport to api.lescopr.com
Constant Summary collapse
- BASE_URL =
"https://api.lescopr.com/api/v1"- TIMEOUT_SEC =
10- MAX_RETRIES =
3
Instance Method Summary collapse
-
#ingest_logs(logs) ⇒ Boolean
Batch ingest via the new /logs/ingest endpoint (Direct / Embedded mode).
-
#initialize(api_key:, sdk_key:) ⇒ HttpClient
constructor
A new instance of HttpClient.
-
#send_heartbeat(sdk_id) ⇒ Object
Send a single heartbeat.
-
#send_logs(logs) ⇒ Boolean
Send a batch of log entries.
-
#verify_project(payload) ⇒ Hash?
Register / verify the project with the API.
Constructor Details
#initialize(api_key:, sdk_key:) ⇒ HttpClient
Returns a new instance of HttpClient.
15 16 17 18 |
# File 'lib/lescopr/transport/http_client.rb', line 15 def initialize(api_key:, sdk_key:) @api_key = api_key @sdk_key = sdk_key end |
Instance Method Details
#ingest_logs(logs) ⇒ Boolean
Batch ingest via the new /logs/ingest endpoint (Direct / Embedded mode). Authenticated by X-SDK-Key header — no user session required.
42 43 44 45 46 47 |
# File 'lib/lescopr/transport/http_client.rb', line 42 def ingest_logs(logs) return true if logs.empty? result = post("/logs/ingest", { logs: logs }) !result.nil? end |
#send_heartbeat(sdk_id) ⇒ Object
Send a single heartbeat.
50 51 52 |
# File 'lib/lescopr/transport/http_client.rb', line 50 def send_heartbeat(sdk_id) post("/sdk/heartbeat/", { sdk_id: sdk_id }) end |
#send_logs(logs) ⇒ Boolean
Send a batch of log entries.
30 31 32 33 34 35 |
# File 'lib/lescopr/transport/http_client.rb', line 30 def send_logs(logs) return true if logs.empty? result = post("/sdk/logs/", { logs: logs }) !result.nil? end |
#verify_project(payload) ⇒ Hash?
Register / verify the project with the API.
23 24 25 |
# File 'lib/lescopr/transport/http_client.rb', line 23 def verify_project(payload) post("/sdk/verify/", payload) end |