Class: Courier::TemplatesClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ TemplatesClient

Parameters:



13
14
15
16
# File 'lib/trycourier/templates/client.rb', line 13

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

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



9
10
11
# File 'lib/trycourier/templates/client.rb', line 9

def request_client
  @request_client
end

Instance Method Details

#list(cursor: nil, request_options: nil) ⇒ Templates::ListTemplatesResponse

Returns a list of notification templates

Parameters:

  • cursor (String) (defaults to: nil)

    A unique identifier that allows for fetching the next set of templates

  • request_options (RequestOptions) (defaults to: nil)

Returns:



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

def list(cursor: nil, request_options: nil)
  response = @request_client.conn.get("/notifications") 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
  Templates::ListTemplatesResponse.from_json(json_object: response.body)
end