@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.
@@ -1,5 +1,5 @@
1
- import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-B09FKPkT.mjs';
2
- export { k as CartAPI, C as CartHeadersAdapter, o as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, w as ProductsAPI } from '../types-B09FKPkT.mjs';
1
+ import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-B7CKE1bj.mjs';
2
+ export { k as CartAPI, C as CartHeadersAdapter, o as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, w as ProductsAPI } from '../types-B7CKE1bj.mjs';
3
3
  import 'axios';
4
4
  import 'zod';
5
5
 
@@ -1,5 +1,5 @@
1
- import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-B09FKPkT.js';
2
- export { k as CartAPI, C as CartHeadersAdapter, o as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, w as ProductsAPI } from '../types-B09FKPkT.js';
1
+ import { W as WooCommerceConfig, a as WooCommerceClient } from '../types-B7CKE1bj.js';
2
+ export { k as CartAPI, C as CartHeadersAdapter, o as CheckoutAPI, J as JwtTokenAdapter, O as OrdersAPI, w as ProductsAPI } from '../types-B7CKE1bj.js';
3
3
  import 'axios';
4
4
  import 'zod';
5
5
 
@@ -1318,6 +1318,15 @@ var productSchema = zod.z.object({
1318
1318
  review_count: zod.z.number(),
1319
1319
  extensions: zod.z.record(zod.z.string(), zod.z.unknown())
1320
1320
  });
1321
+ zod.z.object({
1322
+ /** Attribution source type (e.g., 'mobile_app', 'organic', 'referral') */
1323
+ source_type: zod.z.string(),
1324
+ /** UTM source identifier (e.g., 'moja-apoteka-app', 'google') */
1325
+ utm_source: zod.z.string(),
1326
+ /** Device type (e.g., 'mobile', 'desktop', 'tablet') */
1327
+ device_type: zod.z.string()
1328
+ });
1329
+ var ORDER_ATTRIBUTION_NAMESPACE = "woocommerce/order-attribution";
1321
1330
 
1322
1331
  // src/api/cart.ts
1323
1332
  var createCartAPI = (client, endpoints, options) => ({
@@ -1356,13 +1365,20 @@ var createCartAPI = (client, endpoints, options) => ({
1356
1365
  });
1357
1366
 
1358
1367
  // src/api/checkout.ts
1359
- var createCheckoutAPI = (client, endpoints, options) => ({
1368
+ var createCheckoutAPI = (client, endpoints, options, orderAttribution) => ({
1360
1369
  get: async () => {
1361
1370
  const response = await client.get(endpoints.checkout);
1362
1371
  return handleApiResponse(response, checkoutSchema, options);
1363
1372
  },
1364
1373
  process: async (input) => {
1365
- const response = await client.post(endpoints.checkout, input);
1374
+ const body = orderAttribution ? {
1375
+ ...input,
1376
+ extensions: {
1377
+ [ORDER_ATTRIBUTION_NAMESPACE]: orderAttribution,
1378
+ ...input.extensions
1379
+ }
1380
+ } : input;
1381
+ const response = await client.post(endpoints.checkout, body);
1366
1382
  return handleApiResponse(response, checkoutSchema, options);
1367
1383
  }
1368
1384
  });
@@ -1448,7 +1464,12 @@ var createClient = (config) => {
1448
1464
  axios: axiosInstance,
1449
1465
  products: createProductsAPI(axiosInstance, endpoints, responseOptions),
1450
1466
  cart: createCartAPI(axiosInstance, endpoints, responseOptions),
1451
- checkout: createCheckoutAPI(axiosInstance, endpoints, responseOptions),
1467
+ checkout: createCheckoutAPI(
1468
+ axiosInstance,
1469
+ endpoints,
1470
+ responseOptions,
1471
+ fullConfig.orderAttribution
1472
+ ),
1452
1473
  orders: createOrdersAPI(axiosInstance, endpoints, responseOptions)
1453
1474
  };
1454
1475
  setupRequestInterceptor(axiosInstance, fullConfig, client);