Class: Dodopayments::Resources::Customers::Emails

Inherits:
Object
  • Object
show all
Defined in:
lib/dodopayments/resources/customers/emails.rb,
sig/dodopayments/resources/customers/emails.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Emails

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Emails.

Parameters:



70
71
72
# File 'lib/dodopayments/resources/customers/emails.rb', line 70

def initialize(client:)
  @client = client
end

Instance Method Details

#list(customer_id, page_number: nil, page_size: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::Customers::EmailLogItem>

Returns every transactional email sent to this customer in the last 180 days, newest first, with its delivery outcome. Delivery status comes from the email provider and is as fresh as replication, typically seconds.

Parameters:

  • customer_id (String)

    The customer's id

  • page_number (Integer)

    Which page to return. The default is 0.

  • page_size (Integer)

    How many emails to return. The default is 10 and the maximum is 100.

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dodopayments/resources/customers/emails.rb', line 24

def list(customer_id, params = {})
  parsed, options = Dodopayments::Customers::EmailListParams.dump_request(params)
  query = Dodopayments::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["customers/%1$s/emails", customer_id],
    query: query,
    page: Dodopayments::Internal::DefaultPageNumberPagination,
    model: Dodopayments::Customers::EmailLogItem,
    options: options
  )
end

#retrieve_body(email_log_id, customer_id:, request_options: {}) ⇒ Dodopayments::Models::Customers::EmailBody

Returns the email exactly as it was sent, plus the reason it failed when it did. Some emails have no body to show: an authentication email carries a live login token, a blocked email never reached the provider, and the provider clears bodies at 180 days.

Parameters:

  • email_log_id (String)

    The email log entry's id

  • customer_id (String)

    The customer's id

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/dodopayments/resources/customers/emails.rb', line 53

def retrieve_body(email_log_id, params)
  parsed, options = Dodopayments::Customers::EmailRetrieveBodyParams.dump_request(params)
  customer_id =
    parsed.delete(:customer_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["customers/%1$s/emails/%2$s/body", customer_id, email_log_id],
    model: Dodopayments::Customers::EmailBody,
    options: options
  )
end