2020-07-02 15:17:07 +00:00
|
|
|
export default class CustomerService {
|
2022-12-27 20:54:26 +00:00
|
|
|
constructor() {
|
|
|
|
const runtimeConfig = useRuntimeConfig();
|
2022-12-28 08:48:05 +00:00
|
|
|
|
2022-12-27 20:54:26 +00:00
|
|
|
this.contextPath = runtimeConfig.public.contextPath;
|
|
|
|
}
|
|
|
|
|
2021-10-05 07:41:07 +00:00
|
|
|
getCustomersSmall() {
|
2022-12-27 20:54:26 +00:00
|
|
|
return fetch(this.contextPath + 'demo/data/customers-small.json')
|
2022-09-14 14:26:41 +00:00
|
|
|
.then((res) => res.json())
|
|
|
|
.then((d) => d.data);
|
2021-10-05 07:41:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getCustomersMedium() {
|
2022-12-27 20:54:26 +00:00
|
|
|
return fetch(this.contextPath + 'demo/data/customers-medium.json')
|
2022-09-14 14:26:41 +00:00
|
|
|
.then((res) => res.json())
|
|
|
|
.then((d) => d.data);
|
2021-10-05 07:41:07 +00:00
|
|
|
}
|
2020-03-04 12:10:34 +00:00
|
|
|
|
2021-10-05 07:41:07 +00:00
|
|
|
getCustomersLarge() {
|
2022-12-27 20:54:26 +00:00
|
|
|
return fetch(this.contextPath + 'demo/data/customers-large.json')
|
2022-09-14 14:26:41 +00:00
|
|
|
.then((res) => res.json())
|
|
|
|
.then((d) => d.data);
|
2021-10-05 07:41:07 +00:00
|
|
|
}
|
2020-03-04 12:10:34 +00:00
|
|
|
|
2021-10-05 07:41:07 +00:00
|
|
|
getCustomersXLarge() {
|
2022-12-27 20:54:26 +00:00
|
|
|
return fetch(this.contextPath + 'demo/data/customers-xlarge.json')
|
2022-09-14 14:26:41 +00:00
|
|
|
.then((res) => res.json())
|
|
|
|
.then((d) => d.data);
|
2021-10-05 07:41:07 +00:00
|
|
|
}
|
2020-03-04 12:10:34 +00:00
|
|
|
|
2021-10-05 07:41:07 +00:00
|
|
|
getCustomers(params) {
|
2022-09-14 14:26:41 +00:00
|
|
|
const queryParams = params
|
|
|
|
? Object.keys(params)
|
|
|
|
.map((k) => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
|
|
|
|
.join('&')
|
|
|
|
: '';
|
2022-12-20 12:32:32 +00:00
|
|
|
|
2022-09-14 14:26:41 +00:00
|
|
|
return fetch('https://www.primefaces.org/data/customers?' + queryParams).then((res) => res.json());
|
2021-10-05 07:41:07 +00:00
|
|
|
}
|
|
|
|
}
|