Class: Invoance::Resources::Audit::Events
- Inherits:
-
Object
- Object
- Invoance::Resources::Audit::Events
- Defined in:
- lib/invoance/resources/audit.rb
Overview
audit.events.*
Instance Method Summary collapse
-
#get(event_id) ⇒ Hash
GET /audit/events/:id.
-
#ingest(organization_id:, action:, actor:, occurred_at: nil, targets: nil, context: nil, metadata: nil, idempotency_key: nil) ⇒ Hash
POST /audit/events — append one signed event.
-
#initialize(http) ⇒ Events
constructor
A new instance of Events.
-
#list(organization_id: nil, actions: nil, actor_id: nil, target_id: nil, range_start: nil, range_end: nil, limit: nil, cursor: nil) ⇒ Hash
GET /audit/events — keyset-paginated listing.
-
#verify(event_id) ⇒ Hash
GET /audit/events/:id/verify — server-side verify (pinned key).
Constructor Details
#initialize(http) ⇒ Events
Returns a new instance of Events.
45 46 47 |
# File 'lib/invoance/resources/audit.rb', line 45 def initialize(http) @http = http end |
Instance Method Details
#get(event_id) ⇒ Hash
GET /audit/events/:id
86 87 88 |
# File 'lib/invoance/resources/audit.rb', line 86 def get(event_id) @http.get("/audit/events/#{event_id}") end |
#ingest(organization_id:, action:, actor:, occurred_at: nil, targets: nil, context: nil, metadata: nil, idempotency_key: nil) ⇒ Hash
POST /audit/events — append one signed event. The ledger REQUIRES an Idempotency-Key; derive a content-stable one when none is provided.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/invoance/resources/audit.rb', line 53 def ingest(organization_id:, action:, actor:, occurred_at: nil, targets: nil, context: nil, metadata: nil, idempotency_key: nil) body = { "organization_id" => organization_id, "action" => action, "occurred_at" => occurred_at || Time.now.utc.iso8601, "actor" => actor, "targets" => targets.nil? ? [] : targets } body["context"] = context if context body["metadata"] = if idem = idempotency_key || Resources.content_idempotency_key(body) @http.post("/audit/events", body, idem) end |
#list(organization_id: nil, actions: nil, actor_id: nil, target_id: nil, range_start: nil, range_end: nil, limit: nil, cursor: nil) ⇒ Hash
GET /audit/events — keyset-paginated listing.
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/invoance/resources/audit.rb', line 70 def list(organization_id: nil, actions: nil, actor_id: nil, target_id: nil, range_start: nil, range_end: nil, limit: nil, cursor: nil) @http.get("/audit/events", { "organization_id" => organization_id, "actions" => actions, "actor_id" => actor_id, "target_id" => target_id, "range_start" => range_start, "range_end" => range_end, "limit" => limit, "cursor" => cursor }) end |
#verify(event_id) ⇒ Hash
GET /audit/events/:id/verify — server-side verify (pinned key).
92 93 94 |
# File 'lib/invoance/resources/audit.rb', line 92 def verify(event_id) @http.get("/audit/events/#{event_id}/verify") end |