class Cryptopay::Customers

Attributes

connection[R]

Public Class Methods

new(connection) click to toggle source
# File lib/cryptopay/api/customers.rb, line 8
def initialize(connection)
  @connection = connection
end

Public Instance Methods

create(customer_params, _opts = {}) click to toggle source

Create a customer @param customer_params [CustomerParams] @param [Hash] opts the optional parameters @return [CustomerResult]

# 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 = {}) click to toggle source

List customers @param [Hash] opts the optional parameters @option opts [String] :starting_after Pagination parameter. ID to start after @return [CustomerListResult]

# 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 = {}) click to toggle source

Retrieve a customer @param customer_id [String] The customer's reference ID in your system @param [Hash] opts the optional parameters @return [CustomerResult]

# 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 = {}) click to toggle source

Update a customer @param customer_id [String] The customer's reference ID in your system @param customer_update_params [CustomerUpdateParams] @param [Hash] opts the optional parameters @return [CustomerResult]

# 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