Class: Dodopayments::Resources::Customers

Inherits:
Object
  • Object
show all
Defined in:
lib/dodopayments/resources/customers.rb,
lib/dodopayments/resources/customers/wallets.rb,
lib/dodopayments/resources/customers/customer_portal.rb,
lib/dodopayments/resources/customers/wallets/ledger_entries.rb

Defined Under Namespace

Classes: CustomerPortal, Wallets

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Customers

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 Customers.

Parameters:



128
129
130
131
132
# File 'lib/dodopayments/resources/customers.rb', line 128

def initialize(client:)
  @client = client
  @customer_portal = Dodopayments::Resources::Customers::CustomerPortal.new(client: client)
  @wallets = Dodopayments::Resources::Customers::Wallets.new(client: client)
end

Instance Attribute Details

#customer_portalDodopayments::Resources::Customers::CustomerPortal (readonly)



7
8
9
# File 'lib/dodopayments/resources/customers.rb', line 7

def customer_portal
  @customer_portal
end

#walletsDodopayments::Resources::Customers::Wallets (readonly)



10
11
12
# File 'lib/dodopayments/resources/customers.rb', line 10

def wallets
  @wallets
end

Instance Method Details

#create(email: , name: , metadata: nil, phone_number: nil, request_options: {}) ⇒ Dodopayments::Models::Customer

Parameters:

  • email (String)
  • name (String)
  • metadata (Hash{Symbol=>String})

    Additional metadata for the customer

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

Returns:

See Also:



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

def create(params)
  parsed, options = Dodopayments::CustomerCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "customers",
    body: parsed,
    model: Dodopayments::Customer,
    options: options
  )
end

#list(email: nil, page_number: nil, page_size: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::Customer>

Parameters:

  • email (String)

    Filter by customer email

  • page_number (Integer)

    Page number default is 0

  • page_size (Integer)

    Page size default is 10 max is 100

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

Returns:

See Also:



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/dodopayments/resources/customers.rb', line 95

def list(params = {})
  parsed, options = Dodopayments::CustomerListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "customers",
    query: parsed,
    page: Dodopayments::Internal::DefaultPageNumberPagination,
    model: Dodopayments::Customer,
    options: options
  )
end

#retrieve(customer_id, request_options: {}) ⇒ Dodopayments::Models::Customer

Parameters:

Returns:

See Also:



47
48
49
50
51
52
53
54
# File 'lib/dodopayments/resources/customers.rb', line 47

def retrieve(customer_id, params = {})
  @client.request(
    method: :get,
    path: ["customers/%1$s", customer_id],
    model: Dodopayments::Customer,
    options: params[:request_options]
  )
end

#retrieve_payment_methods(customer_id, request_options: {}) ⇒ Dodopayments::Models::CustomerRetrievePaymentMethodsResponse

Parameters:

Returns:

See Also:



116
117
118
119
120
121
122
123
# File 'lib/dodopayments/resources/customers.rb', line 116

def retrieve_payment_methods(customer_id, params = {})
  @client.request(
    method: :get,
    path: ["customers/%1$s/payment-methods", customer_id],
    model: Dodopayments::Models::CustomerRetrievePaymentMethodsResponse,
    options: params[:request_options]
  )
end

#update(customer_id, metadata: nil, name: nil, phone_number: nil, request_options: {}) ⇒ Dodopayments::Models::Customer

Parameters:

  • customer_id (String)

    Customer Id

  • metadata (Hash{Symbol=>String}, nil)

    Additional metadata for the customer

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

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
# File 'lib/dodopayments/resources/customers.rb', line 71

def update(customer_id, params = {})
  parsed, options = Dodopayments::CustomerUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["customers/%1$s", customer_id],
    body: parsed,
    model: Dodopayments::Customer,
    options: options
  )
end