@atomic-solutions/woocommerce-api-client 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1312,6 +1312,15 @@ var productSchema = z.object({
1312
1312
  review_count: z.number(),
1313
1313
  extensions: z.record(z.string(), z.unknown())
1314
1314
  });
1315
+ z.object({
1316
+ /** Attribution source type (e.g., 'mobile_app', 'organic', 'referral') */
1317
+ source_type: z.string(),
1318
+ /** UTM source identifier (e.g., 'moja-apoteka-app', 'google') */
1319
+ utm_source: z.string(),
1320
+ /** Device type (e.g., 'mobile', 'desktop', 'tablet') */
1321
+ device_type: z.string()
1322
+ });
1323
+ var ORDER_ATTRIBUTION_NAMESPACE = "woocommerce/order-attribution";
1315
1324
 
1316
1325
  // src/api/cart.ts
1317
1326
  var createCartAPI = (client, endpoints, options) => ({
@@ -1350,13 +1359,20 @@ var createCartAPI = (client, endpoints, options) => ({
1350
1359
  });
1351
1360
 
1352
1361
  // src/api/checkout.ts
1353
- var createCheckoutAPI = (client, endpoints, options) => ({
1362
+ var createCheckoutAPI = (client, endpoints, options, orderAttribution) => ({
1354
1363
  get: async () => {
1355
1364
  const response = await client.get(endpoints.checkout);
1356
1365
  return handleApiResponse(response, checkoutSchema, options);
1357
1366
  },
1358
1367
  process: async (input) => {
1359
- const response = await client.post(endpoints.checkout, input);
1368
+ const body = orderAttribution ? {
1369
+ ...input,
1370
+ extensions: {
1371
+ [ORDER_ATTRIBUTION_NAMESPACE]: orderAttribution,
1372
+ ...input.extensions
1373
+ }
1374
+ } : input;
1375
+ const response = await client.post(endpoints.checkout, body);
1360
1376
  return handleApiResponse(response, checkoutSchema, options);
1361
1377
  }
1362
1378
  });
@@ -1442,7 +1458,12 @@ var createClient = (config) => {
1442
1458
  axios: axiosInstance,
1443
1459
  products: createProductsAPI(axiosInstance, endpoints, responseOptions),
1444
1460
  cart: createCartAPI(axiosInstance, endpoints, responseOptions),
1445
- checkout: createCheckoutAPI(axiosInstance, endpoints, responseOptions),
1461
+ checkout: createCheckoutAPI(
1462
+ axiosInstance,
1463
+ endpoints,
1464
+ responseOptions,
1465
+ fullConfig.orderAttribution
1466
+ ),
1446
1467
  orders: createOrdersAPI(axiosInstance, endpoints, responseOptions)
1447
1468
  };
1448
1469
  setupRequestInterceptor(axiosInstance, fullConfig, client);