import apiFetch from '../../functions/fetch';
import { addQueryArgs } from '@wordpress/url';
const path = 'surecart/v1/price/';
/**
 * Get prices
 */
export const getPrices = async ({ query, currencyCode = 'usd' }) => {
  const res = (await apiFetch({
    path: addQueryArgs(path, query),
  }));
  // this does not allow prices with a different currency than provided.
  return res.filter(price => {
    return price.currency && price.currency === currencyCode;
  });
};
