summaryrefslogtreecommitdiff
path: root/src/lib/checkout/api/getVoucher.js
blob: 54c8cce56f72a4dcefc6258218d9995f454b129e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import odooApi from '@/core/api/odooApi';

export const getVoucher = async (id, query) => {
  const queryParam = new URLSearchParams(query);
  const url = `/api/v1/user/${id}/voucher?${queryParam.toString()}`;
  const dataVoucher = await odooApi('GET', url);
  return dataVoucher;
};

export const findVoucher = async (code, id, source) => {
  let dataVoucher = null;
  if (source) {
    dataVoucher = await odooApi(
      'GET',
      `/api/v1/user/${id}/voucher?code=${code}&source=${source}`
    );
  } else {
    dataVoucher = await odooApi(
      'GET',
      `/api/v1/user/${id}/voucher?code=${code}`
    );
  }
  return dataVoucher;
};