Class: Cryptopay::Customers
- Inherits:
-
Object
- Object
- Cryptopay::Customers
- Defined in:
- lib/cryptopay/api/customers.rb
Instance Method Summary collapse
-
#create(customer_params, _opts = {}) ⇒ CustomerResult
Create a customer.
-
#initialize(connection) ⇒ Customers
constructor
A new instance of Customers.
-
#list(opts = {}) ⇒ CustomerListResult
List customers.
-
#retrieve(customer_id, _opts = {}) ⇒ CustomerResult
Retrieve a customer.
-
#update(customer_id, customer_update_params, _opts = {}) ⇒ CustomerResult
Update a customer.
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
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
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
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
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 |