import { normalizeEntities } from '../../../../admin/schema';
import apiFetch from '../../functions/fetch';
import { addQueryArgs } from '@wordpress/url';
const path = 'surecart/v1/products/';
export const getPricesAndProducts = async ({ ids, archived = false }) => {
  const prices = (await apiFetch({
    path: addQueryArgs('surecart/v1/prices/', {
      ids,
      archived,
      expand: ['product'],
    }),
  }));
  return normalizePrices(prices);
};
export const normalizePrices = (prices) => {
  const { entities } = normalizeEntities(prices);
  return {
    prices: entities === null || entities === void 0 ? void 0 : entities.price,
    products: entities === null || entities === void 0 ? void 0 : entities.product,
  };
};
/**
 * Get prices
 */
export const getProducts = async ({ query }) => {
  return (await apiFetch({
    path: addQueryArgs(path, query),
  }));
};
