Customer
An anonymous customer is created server-side when a visitor enters the site for the first time.
The customer can later be authenticated by registering or signing in.
Usage
import { mockServer, CustomerApi } from 'geta-checkout';
const customerApi = new CustomerApi(mockServer.customerServices);
customerApi.get()
.then(customer => console.log(`Hello ${customer.firstName}!`))
.catch(console.error);
Properties
| Name | Required | Type | Description |
|---|---|---|---|
| firstName | no | String | |
| lastName | no | String | |
| isAuthenticated | no | Boolean | |
| no | String | ||
| phone | no | String | |
| address | no | Address | |
| password | no | String | Only visible to the server, but can be updated from the frontend. |
Methods
get()
→ customer or Error
customerApi.get()
.then(console.log)
.catch(console.error);
update(properties)
→ customer or Error
customerApi.update({
firstName: 'Alan',
lastName: 'Turing',
email: 'alan@loremips.um'
})
.then(console.log)
.catch(console.error);
register(data)
→ customer or Error
customerApi.register(data)
.then(console.log)
.catch(console.error);
login(userId, password)
→ customer or Error
customerApi.login({
userId: 'alan@loremips.um',
password: 'secret'
})
.then(console.log)
.catch(console.error);
logout()
→ customer or Error
customerApi.logout()
.then(console.log)
.catch(console.error);
resetPassword(userId)
→ customer or Error
customerApi.resetPassword('alan@loremips.um')
.then(console.log)
.catch(console.error);
search(query)
→ customer or Error
customerApi.search({phone: 12345678})
.then(console.log)
.catch(console.error);