Method: Courier::ListsClient#list

Defined in:
lib/trycourier/lists/client.rb

#list(cursor: nil, pattern: nil, request_options: nil) ⇒ Lists::ListGetAllResponse

Returns all of the lists, with the ability to filter based on a pattern.

Parameters:

  • cursor (String) (defaults to: nil)

    A unique identifier that allows for fetching the next page of lists.

  • pattern (String) (defaults to: nil)

    “A pattern used to filter the list items returned. Pattern types supported: exact match on ‘list_id` or a pattern of one or more pattern parts. you may replace a part with either: `*` to match all parts in that position, or `**` to signify a wildcard `endsWith` pattern match.”

  • request_options (RequestOptions) (defaults to: nil)

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/trycourier/lists/client.rb', line 29

def list(cursor: nil, pattern: nil, request_options: nil)
  response = @request_client.conn.get("/lists") 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,
      "pattern": pattern
    }.compact
  end
  Lists::ListGetAllResponse.from_json(json_object: response.body)
end