Module: LoyverseApi::Endpoints::Customers
- Included in:
- Client
- Defined in:
- lib/loyverse_api/endpoints/customers.rb
Instance Method Summary collapse
-
#create_customer(name:, email: nil, phone_number: nil, address: nil, city: nil, region: nil, postal_code: nil, country: nil, customer_code: nil, note: nil, first_visit: nil, total_visits: nil, total_spent: nil) ⇒ Hash
Create a new customer.
-
#delete_customer(customer_id) ⇒ Hash
Delete a customer.
-
#get_customer(customer_id) ⇒ Hash
Get a specific customer by ID.
-
#list_customers(limit: 250, cursor: nil, email: nil, phone_number: nil, updated_at_min: nil, updated_at_max: nil) ⇒ Hash
List customers.
-
#update_customer(customer_id, name: nil, email: nil, phone_number: nil, address: nil, city: nil, region: nil, postal_code: nil, country: nil, customer_code: nil, note: nil) ⇒ Hash
Update an existing customer.
Instance Method Details
#create_customer(name:, email: nil, phone_number: nil, address: nil, city: nil, region: nil, postal_code: nil, country: nil, customer_code: nil, note: nil, first_visit: nil, total_visits: nil, total_spent: nil) ⇒ Hash
Create a new customer
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/loyverse_api/endpoints/customers.rb', line 47 def create_customer( name:, email: nil, phone_number: nil, address: nil, city: nil, region: nil, postal_code: nil, country: nil, customer_code: nil, note: nil, first_visit: nil, total_visits: nil, total_spent: nil ) body = { name: name, email: email, phone_number: phone_number, address: address, city: city, region: region, postal_code: postal_code, country: country, customer_code: customer_code, note: note, first_visit: format_time(first_visit), total_visits: total_visits, total_spent: total_spent }.compact post("customers", body: body) end |
#delete_customer(customer_id) ⇒ Hash
Delete a customer
126 127 128 |
# File 'lib/loyverse_api/endpoints/customers.rb', line 126 def delete_customer(customer_id) delete("customers/#{customer_id}") end |
#get_customer(customer_id) ⇒ Hash
Get a specific customer by ID
7 8 9 |
# File 'lib/loyverse_api/endpoints/customers.rb', line 7 def get_customer(customer_id) get("customers/#{customer_id}") end |
#list_customers(limit: 250, cursor: nil, email: nil, phone_number: nil, updated_at_min: nil, updated_at_max: nil) ⇒ Hash
List customers
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/loyverse_api/endpoints/customers.rb', line 19 def list_customers(limit: 250, cursor: nil, email: nil, phone_number: nil, updated_at_min: nil, updated_at_max: nil) params = { limit: limit, cursor: cursor, email: email, phone_number: phone_number, updated_at_min: format_time(updated_at_min), updated_at_max: format_time(updated_at_max) }.compact get("customers", params: params) end |
#update_customer(customer_id, name: nil, email: nil, phone_number: nil, address: nil, city: nil, region: nil, postal_code: nil, country: nil, customer_code: nil, note: nil) ⇒ Hash
Update an existing customer
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/loyverse_api/endpoints/customers.rb', line 94 def update_customer( customer_id, name: nil, email: nil, phone_number: nil, address: nil, city: nil, region: nil, postal_code: nil, country: nil, customer_code: nil, note: nil ) body = { name: name, email: email, phone_number: phone_number, address: address, city: city, region: region, postal_code: postal_code, country: country, customer_code: customer_code, note: note }.compact put("customers/#{customer_id}", body: body) end |