@malga-checkout/core
Version:
Core components for Malga Checkout
23 lines (22 loc) • 578 B
JavaScript
import settings from '../../stores/settings';
import { Api } from '../api';
export class CustomerCards {
constructor() {
this.api = new Api();
this.endpoint = settings.sessionId ? '/sessions/customers' : '/customers';
}
async create(cardId, customerId) {
return this.api.create({
endpoint: `${this.endpoint}/${customerId}/cards`,
data: { cardId },
});
}
async list(customerId) {
const response = await this.api.fetch({
endpoint: `${this.endpoint}/${customerId}/cards`,
});
return {
data: response.data,
};
}
}