Class: Cryptopay::Customers

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/api/customers.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Customers

Returns a new instance of Customers.



8
9
10
# File 'lib/cryptopay/api/customers.rb', line 8

def initialize(connection)
  @connection = connection
end

Instance Method Details

#create(customer_params, _opts = {}) ⇒ CustomerResult

Create a customer

Parameters:

  • customer_params (CustomerParams)
  • opts (Hash)

    the optional parameters

Returns:



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cryptopay/api/customers.rb', line 16

def create(customer_params, _opts = {})
  path = '/api/customers'

  req = Request.new(
    method: :post,
    path: path,
    body_params: customer_params
  )

  connection.call(req, return_type: CustomerResult)
end

#list(opts = {}) ⇒ CustomerListResult

List customers

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :starting_after (String)

    Pagination parameter. ID to start after

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cryptopay/api/customers.rb', line 32

def list(opts = {})
  path = '/api/customers'

  query_params = {}
  query_params[:starting_after] = opts[:starting_after] unless opts[:starting_after].nil?

  req = Request.new(
    method: :get,
    path: path,
    query_params: query_params
  )

  connection.call(req, return_type: CustomerListResult)
end

#retrieve(customer_id, _opts = {}) ⇒ CustomerResult

Retrieve a customer

Parameters:

  • customer_id (String)

    The customer's reference ID in your system

  • opts (Hash)

    the optional parameters

Returns:



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cryptopay/api/customers.rb', line 51

def retrieve(customer_id, _opts = {})
  path = '/api/customers/{customer_id}'
  path = path.sub('{customer_id}', CGI.escape(customer_id.to_s))

  req = Request.new(
    method: :get,
    path: path
  )

  connection.call(req, return_type: CustomerResult)
end

#update(customer_id, customer_update_params, _opts = {}) ⇒ CustomerResult

Update a customer

Parameters:

  • customer_id (String)

    The customer's reference ID in your system

  • customer_update_params (CustomerUpdateParams)
  • opts (Hash)

    the optional parameters

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cryptopay/api/customers.rb', line 68

def update(customer_id, customer_update_params, _opts = {})
  path = '/api/customers/{customer_id}'
  path = path.sub('{customer_id}', CGI.escape(customer_id.to_s))

  req = Request.new(
    method: :patch,
    path: path,
    body_params: customer_update_params
  )

  connection.call(req, return_type: CustomerResult)
end