Class: Courier::AuditEventsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/audit_events/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ AuditEventsClient

Parameters:



14
15
16
17
# File 'lib/trycourier/audit_events/client.rb', line 14

def initialize(request_client:)
  # @type [RequestClient]
  @request_client = request_client
end

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



10
11
12
# File 'lib/trycourier/audit_events/client.rb', line 10

def request_client
  @request_client
end

Instance Method Details

#get(audit_event_id:, request_options: nil) ⇒ AuditEvents::AuditEvent

Fetch a specific audit event by ID.

Parameters:

  • audit_event_id (String)

    A unique identifier associated with the audit event you wish to retrieve

  • request_options (RequestOptions) (defaults to: nil)

Returns:



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/trycourier/audit_events/client.rb', line 42

def get(audit_event_id:, request_options: nil)
  response = @request_client.conn.get("/audit-events/#{audit_event_id}") do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    unless request_options&.authorization_token.nil?
      req.headers["Authorization"] =
        request_options.authorization_token
    end
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
  end
  AuditEvents::AuditEvent.from_json(json_object: response.body)
end

#list(cursor: nil, request_options: nil) ⇒ AuditEvents::ListAuditEventsResponse

Fetch the list of audit events

Parameters:

  • cursor (String) (defaults to: nil)

    A unique identifier that allows for fetching the next set of audit events.

  • request_options (RequestOptions) (defaults to: nil)

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/trycourier/audit_events/client.rb', line 24

def list(cursor: nil, request_options: nil)
  response = @request_client.conn.get("/audit-events") do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    unless request_options&.authorization_token.nil?
      req.headers["Authorization"] =
        request_options.authorization_token
    end
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.params = { **(request_options&.additional_query_parameters || {}), "cursor": cursor }.compact
  end
  AuditEvents::ListAuditEventsResponse.from_json(json_object: response.body)
end