Class: Courier::AsyncAuditEventsClient

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:) ⇒ AsyncAuditEventsClient

Parameters:



60
61
62
63
# File 'lib/trycourier/audit_events/client.rb', line 60

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

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



56
57
58
# File 'lib/trycourier/audit_events/client.rb', line 56

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:



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/trycourier/audit_events/client.rb', line 90

def get(audit_event_id:, request_options: nil)
  Async do
    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
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:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/trycourier/audit_events/client.rb', line 70

def list(cursor: nil, request_options: nil)
  Async do
    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
end