Class: Invoance::Resources::Traces

Inherits:
Object
  • Object
show all
Defined in:
lib/invoance/resources/traces.rb

Overview

Traces resource — client.traces.*

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Traces

Returns a new instance of Traces.

Parameters:



8
9
10
# File 'lib/invoance/resources/traces.rb', line 8

def initialize(http)
  @http = http
end

Instance Method Details

#create(label:, metadata: nil) ⇒ Hash

POST /traces — Create a new trace.

Returns:

  • (Hash)

    CreateTraceResponse



14
15
16
17
18
# File 'lib/invoance/resources/traces.rb', line 14

def create(label:, metadata: nil)
  body = { "label" => label }
  body["metadata"] =  if 
  @http.post("/traces", body)
end

#delete(trace_id) ⇒ Hash

DELETE /traces/:trace_id — Delete an empty open trace.

Returns:

  • (Hash)

    DeleteTraceResponse



37
38
39
# File 'lib/invoance/resources/traces.rb', line 37

def delete(trace_id)
  @http.delete("/traces/#{trace_id}")
end

#get(trace_id, event_page: nil, event_limit: nil) ⇒ Hash

GET /traces/:trace_id — Trace detail with paginated events.

Returns:

  • (Hash)

    TraceDetail



28
29
30
31
32
33
# File 'lib/invoance/resources/traces.rb', line 28

def get(trace_id, event_page: nil, event_limit: nil)
  @http.get("/traces/#{trace_id}", {
              "event_page" => event_page,
              "event_limit" => event_limit
            })
end

#list(page: nil, limit: nil, status: nil) ⇒ Hash

GET /traces — Paginated trace listing. status in open|sealed.

Returns:

  • (Hash)

    ListTracesResponse



22
23
24
# File 'lib/invoance/resources/traces.rb', line 22

def list(page: nil, limit: nil, status: nil)
  @http.get("/traces", { "page" => page, "limit" => limit, "status" => status })
end

#proof(trace_id) ⇒ Hash

GET /traces/:trace_id/proof — Export proof bundle as JSON.

Returns:

  • (Hash)

    TraceProofBundle



49
50
51
# File 'lib/invoance/resources/traces.rb', line 49

def proof(trace_id)
  @http.get("/traces/#{trace_id}/proof")
end

#proof_pdf(trace_id) ⇒ String

GET /traces/:trace_id/proof/pdf — Download proof bundle as PDF.

Returns:

  • (String)

    raw binary PDF bytes



55
56
57
# File 'lib/invoance/resources/traces.rb', line 55

def proof_pdf(trace_id)
  @http.get_bytes("/traces/#{trace_id}/proof/pdf")
end

#seal(trace_id) ⇒ Hash

POST /traces/:trace_id/seal — Seal a trace (async, 202).

Returns:

  • (Hash)

    SealTraceResponse



43
44
45
# File 'lib/invoance/resources/traces.rb', line 43

def seal(trace_id)
  @http.post("/traces/#{trace_id}/seal", {})
end