@proveanything/smartlinks 1.3.18 → 1.3.19
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.
- package/dist/api/order.d.ts +130 -1
- package/dist/api/order.js +149 -0
- package/dist/docs/API_SUMMARY.md +194 -1
- package/dist/types/order.d.ts +162 -0
- package/docs/API_SUMMARY.md +194 -1
- package/package.json +1 -1
package/dist/api/order.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateOrderRequest, CreateOrderResponse, GetOrderParams, GetOrderResponse, UpdateOrderRequest, UpdateOrderResponse, DeleteOrderResponse, ListOrdersRequest, ListOrdersResponse, GetOrderItemsParams, GetOrderItemsResponse, AddItemsRequest, AddItemsResponse, RemoveItemsRequest, RemoveItemsResponse, QueryOrdersRequest, QueryOrdersResponse, ReportsParams, ReportsResponse, LookupOrdersRequest, LookupOrdersResponse, LookupByProductParams, LookupByProductResponse } from "../types/order";
|
|
1
|
+
import { CreateOrderRequest, CreateOrderResponse, GetOrderParams, GetOrderResponse, UpdateOrderRequest, UpdateOrderResponse, DeleteOrderResponse, ListOrdersRequest, ListOrdersResponse, GetOrderItemsParams, GetOrderItemsResponse, AddItemsRequest, AddItemsResponse, RemoveItemsRequest, RemoveItemsResponse, QueryOrdersRequest, QueryOrdersResponse, ReportsParams, ReportsResponse, LookupOrdersRequest, LookupOrdersResponse, LookupByProductParams, LookupByProductResponse, OrderAnalyticsResponse, TimelineRequest, TimelineResponse, LocationRequest, LocationResponse, BulkAnalyticsRequest, BulkAnalyticsResponse, SummaryRequest, CollectionSummaryResponse } from "../types/order";
|
|
2
2
|
/**
|
|
3
3
|
* Order Management API
|
|
4
4
|
*
|
|
@@ -314,4 +314,133 @@ export declare namespace order {
|
|
|
314
314
|
* ```
|
|
315
315
|
*/
|
|
316
316
|
function findByProduct(collectionId: string, productId: string, params?: LookupByProductParams): Promise<LookupByProductResponse>;
|
|
317
|
+
/**
|
|
318
|
+
* Get comprehensive scan analytics for all tags in an order.
|
|
319
|
+
* Returns scan counts, timestamps, locations, devices, and per-tag summaries.
|
|
320
|
+
*
|
|
321
|
+
* @param collectionId - Identifier of the parent collection
|
|
322
|
+
* @param orderId - Order ID
|
|
323
|
+
* @returns Promise resolving to an OrderAnalyticsResponse with scan analytics
|
|
324
|
+
* @throws ErrorResponse if the request fails
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```typescript
|
|
328
|
+
* const analytics = await order.getAnalytics('coll_123', 'order_abc123')
|
|
329
|
+
*
|
|
330
|
+
* if (analytics.analytics) {
|
|
331
|
+
* console.log(`Total scans: ${analytics.analytics.totalScans}`)
|
|
332
|
+
* console.log(`Admin scans: ${analytics.analytics.adminScans}`)
|
|
333
|
+
* console.log(`Created at: ${analytics.analytics.estimatedCreatedAt}`)
|
|
334
|
+
* console.log(`Unique locations: ${analytics.analytics.uniqueLocations}`)
|
|
335
|
+
*
|
|
336
|
+
* analytics.analytics.tagSummaries.forEach(tag => {
|
|
337
|
+
* console.log(`Tag ${tag.tagId}: ${tag.totalScans} scans`)
|
|
338
|
+
* })
|
|
339
|
+
* }
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
function getAnalytics(collectionId: string, orderId: string): Promise<OrderAnalyticsResponse>;
|
|
343
|
+
/**
|
|
344
|
+
* Get chronological timeline of all scan events for an order's tags.
|
|
345
|
+
* Supports filtering by date range and admin/customer scans.
|
|
346
|
+
*
|
|
347
|
+
* @param collectionId - Identifier of the parent collection
|
|
348
|
+
* @param orderId - Order ID
|
|
349
|
+
* @param params - Optional filters (limit, date range, isAdmin)
|
|
350
|
+
* @returns Promise resolving to a TimelineResponse with scan events
|
|
351
|
+
* @throws ErrorResponse if the request fails
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* // Get all scan events
|
|
356
|
+
* const timeline = await order.getTimeline('coll_123', 'order_abc123')
|
|
357
|
+
*
|
|
358
|
+
* timeline.timeline.forEach(event => {
|
|
359
|
+
* console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`)
|
|
360
|
+
* })
|
|
361
|
+
*
|
|
362
|
+
* // Get admin scans only from last week
|
|
363
|
+
* const adminScans = await order.getTimeline('coll_123', 'order_abc123', {
|
|
364
|
+
* isAdmin: true,
|
|
365
|
+
* from: '2026-02-01T00:00:00Z',
|
|
366
|
+
* limit: 500
|
|
367
|
+
* })
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
function getTimeline(collectionId: string, orderId: string, params?: TimelineRequest): Promise<TimelineResponse>;
|
|
371
|
+
/**
|
|
372
|
+
* Get location-based scan history for an order's tags.
|
|
373
|
+
* Shows where the order's tags have been scanned.
|
|
374
|
+
*
|
|
375
|
+
* @param collectionId - Identifier of the parent collection
|
|
376
|
+
* @param orderId - Order ID
|
|
377
|
+
* @param params - Optional limit parameter
|
|
378
|
+
* @returns Promise resolving to a LocationResponse with location scans
|
|
379
|
+
* @throws ErrorResponse if the request fails
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```typescript
|
|
383
|
+
* const locations = await order.getLocationHistory('coll_123', 'order_abc123', {
|
|
384
|
+
* limit: 100
|
|
385
|
+
* })
|
|
386
|
+
*
|
|
387
|
+
* console.log(`Order scanned in ${locations.count} locations`)
|
|
388
|
+
* locations.locations.forEach(scan => {
|
|
389
|
+
* console.log(`${scan.location} at ${scan.timestamp}`)
|
|
390
|
+
* })
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
function getLocationHistory(collectionId: string, orderId: string, params?: LocationRequest): Promise<LocationResponse>;
|
|
394
|
+
/**
|
|
395
|
+
* Get analytics summary for multiple orders at once.
|
|
396
|
+
* Efficient way to retrieve scan data for many orders.
|
|
397
|
+
*
|
|
398
|
+
* @param collectionId - Identifier of the parent collection
|
|
399
|
+
* @param data - Request with array of order IDs and optional date filters
|
|
400
|
+
* @returns Promise resolving to a BulkAnalyticsResponse with summaries
|
|
401
|
+
* @throws ErrorResponse if the request fails
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```typescript
|
|
405
|
+
* const bulk = await order.getBulkAnalytics('coll_123', {
|
|
406
|
+
* orderIds: ['order_1', 'order_2', 'order_3'],
|
|
407
|
+
* from: '2026-01-01T00:00:00Z'
|
|
408
|
+
* })
|
|
409
|
+
*
|
|
410
|
+
* bulk.results.forEach(result => {
|
|
411
|
+
* if (result.analytics) {
|
|
412
|
+
* console.log(`${result.orderRef}: ${result.analytics.totalScans} scans`)
|
|
413
|
+
* }
|
|
414
|
+
* })
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
function getBulkAnalytics(collectionId: string, data: BulkAnalyticsRequest): Promise<BulkAnalyticsResponse>;
|
|
418
|
+
/**
|
|
419
|
+
* Get collection-wide analytics summary across all orders.
|
|
420
|
+
* Returns daily scan counts and admin activity overview.
|
|
421
|
+
*
|
|
422
|
+
* @param collectionId - Identifier of the parent collection
|
|
423
|
+
* @param params - Optional date range filters
|
|
424
|
+
* @returns Promise resolving to a CollectionSummaryResponse
|
|
425
|
+
* @throws ErrorResponse if the request fails
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```typescript
|
|
429
|
+
* // Get all-time collection summary
|
|
430
|
+
* const summary = await order.getCollectionSummary('coll_123')
|
|
431
|
+
*
|
|
432
|
+
* console.log(`Admin activity count: ${summary.adminActivity.count}`)
|
|
433
|
+
* console.log('Scans by day:')
|
|
434
|
+
* summary.scansByDay.forEach(day => {
|
|
435
|
+
* console.log(` ${day.date}: ${day.scanCount} scans`)
|
|
436
|
+
* })
|
|
437
|
+
*
|
|
438
|
+
* // Get summary for last 30 days
|
|
439
|
+
* const recentSummary = await order.getCollectionSummary('coll_123', {
|
|
440
|
+
* from: '2026-01-08T00:00:00Z',
|
|
441
|
+
* to: '2026-02-08T00:00:00Z'
|
|
442
|
+
* })
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
function getCollectionSummary(collectionId: string, params?: SummaryRequest): Promise<CollectionSummaryResponse>;
|
|
317
446
|
}
|
package/dist/api/order.js
CHANGED
|
@@ -427,4 +427,153 @@ export var order;
|
|
|
427
427
|
return request(path);
|
|
428
428
|
}
|
|
429
429
|
order.findByProduct = findByProduct;
|
|
430
|
+
/**
|
|
431
|
+
* Get comprehensive scan analytics for all tags in an order.
|
|
432
|
+
* Returns scan counts, timestamps, locations, devices, and per-tag summaries.
|
|
433
|
+
*
|
|
434
|
+
* @param collectionId - Identifier of the parent collection
|
|
435
|
+
* @param orderId - Order ID
|
|
436
|
+
* @returns Promise resolving to an OrderAnalyticsResponse with scan analytics
|
|
437
|
+
* @throws ErrorResponse if the request fails
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```typescript
|
|
441
|
+
* const analytics = await order.getAnalytics('coll_123', 'order_abc123')
|
|
442
|
+
*
|
|
443
|
+
* if (analytics.analytics) {
|
|
444
|
+
* console.log(`Total scans: ${analytics.analytics.totalScans}`)
|
|
445
|
+
* console.log(`Admin scans: ${analytics.analytics.adminScans}`)
|
|
446
|
+
* console.log(`Created at: ${analytics.analytics.estimatedCreatedAt}`)
|
|
447
|
+
* console.log(`Unique locations: ${analytics.analytics.uniqueLocations}`)
|
|
448
|
+
*
|
|
449
|
+
* analytics.analytics.tagSummaries.forEach(tag => {
|
|
450
|
+
* console.log(`Tag ${tag.tagId}: ${tag.totalScans} scans`)
|
|
451
|
+
* })
|
|
452
|
+
* }
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
async function getAnalytics(collectionId, orderId) {
|
|
456
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/analytics/${encodeURIComponent(orderId)}`;
|
|
457
|
+
return post(path, {});
|
|
458
|
+
}
|
|
459
|
+
order.getAnalytics = getAnalytics;
|
|
460
|
+
/**
|
|
461
|
+
* Get chronological timeline of all scan events for an order's tags.
|
|
462
|
+
* Supports filtering by date range and admin/customer scans.
|
|
463
|
+
*
|
|
464
|
+
* @param collectionId - Identifier of the parent collection
|
|
465
|
+
* @param orderId - Order ID
|
|
466
|
+
* @param params - Optional filters (limit, date range, isAdmin)
|
|
467
|
+
* @returns Promise resolving to a TimelineResponse with scan events
|
|
468
|
+
* @throws ErrorResponse if the request fails
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```typescript
|
|
472
|
+
* // Get all scan events
|
|
473
|
+
* const timeline = await order.getTimeline('coll_123', 'order_abc123')
|
|
474
|
+
*
|
|
475
|
+
* timeline.timeline.forEach(event => {
|
|
476
|
+
* console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`)
|
|
477
|
+
* })
|
|
478
|
+
*
|
|
479
|
+
* // Get admin scans only from last week
|
|
480
|
+
* const adminScans = await order.getTimeline('coll_123', 'order_abc123', {
|
|
481
|
+
* isAdmin: true,
|
|
482
|
+
* from: '2026-02-01T00:00:00Z',
|
|
483
|
+
* limit: 500
|
|
484
|
+
* })
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
async function getTimeline(collectionId, orderId, params) {
|
|
488
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/analytics/${encodeURIComponent(orderId)}/timeline`;
|
|
489
|
+
return post(path, params || {});
|
|
490
|
+
}
|
|
491
|
+
order.getTimeline = getTimeline;
|
|
492
|
+
/**
|
|
493
|
+
* Get location-based scan history for an order's tags.
|
|
494
|
+
* Shows where the order's tags have been scanned.
|
|
495
|
+
*
|
|
496
|
+
* @param collectionId - Identifier of the parent collection
|
|
497
|
+
* @param orderId - Order ID
|
|
498
|
+
* @param params - Optional limit parameter
|
|
499
|
+
* @returns Promise resolving to a LocationResponse with location scans
|
|
500
|
+
* @throws ErrorResponse if the request fails
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```typescript
|
|
504
|
+
* const locations = await order.getLocationHistory('coll_123', 'order_abc123', {
|
|
505
|
+
* limit: 100
|
|
506
|
+
* })
|
|
507
|
+
*
|
|
508
|
+
* console.log(`Order scanned in ${locations.count} locations`)
|
|
509
|
+
* locations.locations.forEach(scan => {
|
|
510
|
+
* console.log(`${scan.location} at ${scan.timestamp}`)
|
|
511
|
+
* })
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
async function getLocationHistory(collectionId, orderId, params) {
|
|
515
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/analytics/${encodeURIComponent(orderId)}/locations`;
|
|
516
|
+
return post(path, params || {});
|
|
517
|
+
}
|
|
518
|
+
order.getLocationHistory = getLocationHistory;
|
|
519
|
+
/**
|
|
520
|
+
* Get analytics summary for multiple orders at once.
|
|
521
|
+
* Efficient way to retrieve scan data for many orders.
|
|
522
|
+
*
|
|
523
|
+
* @param collectionId - Identifier of the parent collection
|
|
524
|
+
* @param data - Request with array of order IDs and optional date filters
|
|
525
|
+
* @returns Promise resolving to a BulkAnalyticsResponse with summaries
|
|
526
|
+
* @throws ErrorResponse if the request fails
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```typescript
|
|
530
|
+
* const bulk = await order.getBulkAnalytics('coll_123', {
|
|
531
|
+
* orderIds: ['order_1', 'order_2', 'order_3'],
|
|
532
|
+
* from: '2026-01-01T00:00:00Z'
|
|
533
|
+
* })
|
|
534
|
+
*
|
|
535
|
+
* bulk.results.forEach(result => {
|
|
536
|
+
* if (result.analytics) {
|
|
537
|
+
* console.log(`${result.orderRef}: ${result.analytics.totalScans} scans`)
|
|
538
|
+
* }
|
|
539
|
+
* })
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
async function getBulkAnalytics(collectionId, data) {
|
|
543
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/analytics/bulk`;
|
|
544
|
+
return post(path, data);
|
|
545
|
+
}
|
|
546
|
+
order.getBulkAnalytics = getBulkAnalytics;
|
|
547
|
+
/**
|
|
548
|
+
* Get collection-wide analytics summary across all orders.
|
|
549
|
+
* Returns daily scan counts and admin activity overview.
|
|
550
|
+
*
|
|
551
|
+
* @param collectionId - Identifier of the parent collection
|
|
552
|
+
* @param params - Optional date range filters
|
|
553
|
+
* @returns Promise resolving to a CollectionSummaryResponse
|
|
554
|
+
* @throws ErrorResponse if the request fails
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* // Get all-time collection summary
|
|
559
|
+
* const summary = await order.getCollectionSummary('coll_123')
|
|
560
|
+
*
|
|
561
|
+
* console.log(`Admin activity count: ${summary.adminActivity.count}`)
|
|
562
|
+
* console.log('Scans by day:')
|
|
563
|
+
* summary.scansByDay.forEach(day => {
|
|
564
|
+
* console.log(` ${day.date}: ${day.scanCount} scans`)
|
|
565
|
+
* })
|
|
566
|
+
*
|
|
567
|
+
* // Get summary for last 30 days
|
|
568
|
+
* const recentSummary = await order.getCollectionSummary('coll_123', {
|
|
569
|
+
* from: '2026-01-08T00:00:00Z',
|
|
570
|
+
* to: '2026-02-08T00:00:00Z'
|
|
571
|
+
* })
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
async function getCollectionSummary(collectionId, params) {
|
|
575
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/orders/analytics/summary`;
|
|
576
|
+
return post(path, params || {});
|
|
577
|
+
}
|
|
578
|
+
order.getCollectionSummary = getCollectionSummary;
|
|
430
579
|
})(order || (order = {}));
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.19 | Generated: 2026-02-08T09:16:59.107Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -2395,6 +2395,177 @@ interface LookupByProductResponse {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
```
|
|
2397
2397
|
|
|
2398
|
+
**TagScanSummary** (interface)
|
|
2399
|
+
```typescript
|
|
2400
|
+
interface TagScanSummary {
|
|
2401
|
+
tagId: string
|
|
2402
|
+
totalScans: number
|
|
2403
|
+
adminScans: number
|
|
2404
|
+
customerScans: number
|
|
2405
|
+
earliestScanAt: string | null
|
|
2406
|
+
earliestAdminScanAt: string | null
|
|
2407
|
+
}
|
|
2408
|
+
```
|
|
2409
|
+
|
|
2410
|
+
**OrderAnalyticsResponse** (interface)
|
|
2411
|
+
```typescript
|
|
2412
|
+
interface OrderAnalyticsResponse {
|
|
2413
|
+
orderRef: string
|
|
2414
|
+
orderId: string
|
|
2415
|
+
itemCount: number
|
|
2416
|
+
tagCount: number
|
|
2417
|
+
analytics: {
|
|
2418
|
+
totalScans: number
|
|
2419
|
+
adminScans: number
|
|
2420
|
+
customerScans: number
|
|
2421
|
+
earliestScanAt: string // ISO 8601
|
|
2422
|
+
latestScanAt: string // ISO 8601
|
|
2423
|
+
earliestAdminScanAt: string | null // ISO 8601
|
|
2424
|
+
earliestCustomerScanAt: string | null // ISO 8601
|
|
2425
|
+
estimatedCreatedAt: string // ISO 8601 - earliest admin scan or earliest scan
|
|
2426
|
+
uniqueLocations: number
|
|
2427
|
+
locations: string[] // Array of location strings
|
|
2428
|
+
uniqueDevices: number
|
|
2429
|
+
devices: string[] // Array of device types
|
|
2430
|
+
eventTypes: string[] // e.g., ["scan_tag", "verify_tag"]
|
|
2431
|
+
tagSummaries: TagScanSummary[]
|
|
2432
|
+
} | null // null if no tags found
|
|
2433
|
+
message?: string // Only present if no tags found
|
|
2434
|
+
}
|
|
2435
|
+
```
|
|
2436
|
+
|
|
2437
|
+
**TagScanEvent** (interface)
|
|
2438
|
+
```typescript
|
|
2439
|
+
interface TagScanEvent {
|
|
2440
|
+
codeId: string
|
|
2441
|
+
claimId: string
|
|
2442
|
+
proofId: string | null
|
|
2443
|
+
productId: string | null
|
|
2444
|
+
variantId: string | null
|
|
2445
|
+
batchId: string | null
|
|
2446
|
+
collectionId: string
|
|
2447
|
+
timestamp: string // ISO 8601
|
|
2448
|
+
isAdmin: boolean
|
|
2449
|
+
eventType: string | null // e.g., "scan_tag"
|
|
2450
|
+
location: string | null // GPS coordinates or location string
|
|
2451
|
+
location_accuracy: number | null
|
|
2452
|
+
deviceType: string | null
|
|
2453
|
+
ip: string | null
|
|
2454
|
+
country: string | null
|
|
2455
|
+
sessionId: string | null
|
|
2456
|
+
metadata: Record<string, any> | null
|
|
2457
|
+
}
|
|
2458
|
+
```
|
|
2459
|
+
|
|
2460
|
+
**TimelineRequest** (interface)
|
|
2461
|
+
```typescript
|
|
2462
|
+
interface TimelineRequest {
|
|
2463
|
+
limit?: number // Max results (default: 1000)
|
|
2464
|
+
from?: string // ISO 8601 start date filter
|
|
2465
|
+
to?: string // ISO 8601 end date filter
|
|
2466
|
+
isAdmin?: boolean // Filter by admin scans only
|
|
2467
|
+
}
|
|
2468
|
+
```
|
|
2469
|
+
|
|
2470
|
+
**TimelineResponse** (interface)
|
|
2471
|
+
```typescript
|
|
2472
|
+
interface TimelineResponse {
|
|
2473
|
+
orderRef: string
|
|
2474
|
+
orderId: string
|
|
2475
|
+
timeline: TagScanEvent[]
|
|
2476
|
+
count: number
|
|
2477
|
+
}
|
|
2478
|
+
```
|
|
2479
|
+
|
|
2480
|
+
**LocationRequest** (interface)
|
|
2481
|
+
```typescript
|
|
2482
|
+
interface LocationRequest {
|
|
2483
|
+
limit?: number // Max results (default: 1000)
|
|
2484
|
+
}
|
|
2485
|
+
```
|
|
2486
|
+
|
|
2487
|
+
**LocationResponse** (interface)
|
|
2488
|
+
```typescript
|
|
2489
|
+
interface LocationResponse {
|
|
2490
|
+
orderRef: string
|
|
2491
|
+
orderId: string
|
|
2492
|
+
locations: LocationScan[]
|
|
2493
|
+
count: number
|
|
2494
|
+
}
|
|
2495
|
+
```
|
|
2496
|
+
|
|
2497
|
+
**BulkAnalyticsRequest** (interface)
|
|
2498
|
+
```typescript
|
|
2499
|
+
interface BulkAnalyticsRequest {
|
|
2500
|
+
orderIds: string[] // Array of order IDs
|
|
2501
|
+
from?: string // ISO 8601 start date filter
|
|
2502
|
+
to?: string // ISO 8601 end date filter
|
|
2503
|
+
}
|
|
2504
|
+
```
|
|
2505
|
+
|
|
2506
|
+
**OrderAnalyticsSummary** (interface)
|
|
2507
|
+
```typescript
|
|
2508
|
+
interface OrderAnalyticsSummary {
|
|
2509
|
+
orderId: string
|
|
2510
|
+
orderRef: string
|
|
2511
|
+
analytics: {
|
|
2512
|
+
totalScans: number
|
|
2513
|
+
adminScans: number
|
|
2514
|
+
customerScans: number
|
|
2515
|
+
earliestScanAt: string | null
|
|
2516
|
+
earliestAdminScanAt: string | null
|
|
2517
|
+
estimatedCreatedAt: string | null
|
|
2518
|
+
tagCount: number
|
|
2519
|
+
tagSummaries: TagScanSummary[]
|
|
2520
|
+
} | null
|
|
2521
|
+
}
|
|
2522
|
+
```
|
|
2523
|
+
|
|
2524
|
+
**BulkAnalyticsResponse** (interface)
|
|
2525
|
+
```typescript
|
|
2526
|
+
interface BulkAnalyticsResponse {
|
|
2527
|
+
results: OrderAnalyticsSummary[]
|
|
2528
|
+
}
|
|
2529
|
+
```
|
|
2530
|
+
|
|
2531
|
+
**DailyScanCount** (interface)
|
|
2532
|
+
```typescript
|
|
2533
|
+
interface DailyScanCount {
|
|
2534
|
+
date: string // YYYY-MM-DD
|
|
2535
|
+
scanCount: number
|
|
2536
|
+
}
|
|
2537
|
+
```
|
|
2538
|
+
|
|
2539
|
+
**AdminActivityEvent** (interface)
|
|
2540
|
+
```typescript
|
|
2541
|
+
interface AdminActivityEvent {
|
|
2542
|
+
timestamp: string // ISO 8601
|
|
2543
|
+
eventType: string
|
|
2544
|
+
codeId: string
|
|
2545
|
+
}
|
|
2546
|
+
```
|
|
2547
|
+
|
|
2548
|
+
**SummaryRequest** (interface)
|
|
2549
|
+
```typescript
|
|
2550
|
+
interface SummaryRequest {
|
|
2551
|
+
from?: string // ISO 8601 start date filter
|
|
2552
|
+
to?: string // ISO 8601 end date filter
|
|
2553
|
+
}
|
|
2554
|
+
```
|
|
2555
|
+
|
|
2556
|
+
**CollectionSummaryResponse** (interface)
|
|
2557
|
+
```typescript
|
|
2558
|
+
interface CollectionSummaryResponse {
|
|
2559
|
+
adminActivity: {
|
|
2560
|
+
count: number
|
|
2561
|
+
recent: AdminActivityEvent[] // Last 100 events
|
|
2562
|
+
}
|
|
2563
|
+
scansByDay: DailyScanCount[]
|
|
2564
|
+
adminScansByDay: DailyScanCount[]
|
|
2565
|
+
customerScansByDay: DailyScanCount[]
|
|
2566
|
+
}
|
|
2567
|
+
```
|
|
2568
|
+
|
|
2398
2569
|
### product
|
|
2399
2570
|
|
|
2400
2571
|
**Product** (interface)
|
|
@@ -4177,6 +4348,28 @@ Get reports and aggregations for orders. Provides analytics grouped by status, c
|
|
|
4177
4348
|
params?: LookupByProductParams) → `Promise<LookupByProductResponse>`
|
|
4178
4349
|
Find all orders containing items with a specific product ID. Uses the automatic productSummary tracking in order metadata. ```typescript // Find all orders with a specific product const result = await order.findByProduct('coll_123', 'product_abc123', { limit: 50, includeItems: false }) result.orders.forEach(ord => { const count = ord.metadata.productSummary?.['product_abc123'] ?? 0 console.log(`Order ${ord.orderRef} has ${count} items of this product`) }) ```
|
|
4179
4350
|
|
|
4351
|
+
**getAnalytics**(collectionId: string,
|
|
4352
|
+
orderId: string) → `Promise<OrderAnalyticsResponse>`
|
|
4353
|
+
Get comprehensive scan analytics for all tags in an order. Returns scan counts, timestamps, locations, devices, and per-tag summaries. ```typescript const analytics = await order.getAnalytics('coll_123', 'order_abc123') if (analytics.analytics) { console.log(`Total scans: ${analytics.analytics.totalScans}`) console.log(`Admin scans: ${analytics.analytics.adminScans}`) console.log(`Created at: ${analytics.analytics.estimatedCreatedAt}`) console.log(`Unique locations: ${analytics.analytics.uniqueLocations}`) analytics.analytics.tagSummaries.forEach(tag => { console.log(`Tag ${tag.tagId}: ${tag.totalScans} scans`) }) } ```
|
|
4354
|
+
|
|
4355
|
+
**getTimeline**(collectionId: string,
|
|
4356
|
+
orderId: string,
|
|
4357
|
+
params?: TimelineRequest) → `Promise<TimelineResponse>`
|
|
4358
|
+
Get chronological timeline of all scan events for an order's tags. Supports filtering by date range and admin/customer scans. ```typescript // Get all scan events const timeline = await order.getTimeline('coll_123', 'order_abc123') timeline.timeline.forEach(event => { console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`) }) // Get admin scans only from last week const adminScans = await order.getTimeline('coll_123', 'order_abc123', { isAdmin: true, from: '2026-02-01T00:00:00Z', limit: 500 }) ```
|
|
4359
|
+
|
|
4360
|
+
**getLocationHistory**(collectionId: string,
|
|
4361
|
+
orderId: string,
|
|
4362
|
+
params?: LocationRequest) → `Promise<LocationResponse>`
|
|
4363
|
+
Get location-based scan history for an order's tags. Shows where the order's tags have been scanned. ```typescript const locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100 }) console.log(`Order scanned in ${locations.count} locations`) locations.locations.forEach(scan => { console.log(`${scan.location} at ${scan.timestamp}`) }) ```
|
|
4364
|
+
|
|
4365
|
+
**getBulkAnalytics**(collectionId: string,
|
|
4366
|
+
data: BulkAnalyticsRequest) → `Promise<BulkAnalyticsResponse>`
|
|
4367
|
+
Get analytics summary for multiple orders at once. Efficient way to retrieve scan data for many orders. ```typescript const bulk = await order.getBulkAnalytics('coll_123', { orderIds: ['order_1', 'order_2', 'order_3'], from: '2026-01-01T00:00:00Z' }) bulk.results.forEach(result => { if (result.analytics) { console.log(`${result.orderRef}: ${result.analytics.totalScans} scans`) } }) ```
|
|
4368
|
+
|
|
4369
|
+
**getCollectionSummary**(collectionId: string,
|
|
4370
|
+
params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
|
|
4371
|
+
Get collection-wide analytics summary across all orders. Returns daily scan counts and admin activity overview. ```typescript // Get all-time collection summary const summary = await order.getCollectionSummary('coll_123') console.log(`Admin activity count: ${summary.adminActivity.count}`) console.log('Scans by day:') summary.scansByDay.forEach(day => { console.log(` ${day.date}: ${day.scanCount} scans`) }) // Get summary for last 30 days const recentSummary = await order.getCollectionSummary('coll_123', { from: '2026-01-08T00:00:00Z', to: '2026-02-08T00:00:00Z' }) ```
|
|
4372
|
+
|
|
4180
4373
|
### product
|
|
4181
4374
|
|
|
4182
4375
|
**get**(collectionId: string,
|
package/dist/types/order.d.ts
CHANGED
|
@@ -241,3 +241,165 @@ export interface LookupByProductResponse {
|
|
|
241
241
|
limit: number;
|
|
242
242
|
offset: number;
|
|
243
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Summary of scans for a single tag.
|
|
246
|
+
*/
|
|
247
|
+
export interface TagScanSummary {
|
|
248
|
+
tagId: string;
|
|
249
|
+
totalScans: number;
|
|
250
|
+
adminScans: number;
|
|
251
|
+
customerScans: number;
|
|
252
|
+
earliestScanAt: string | null;
|
|
253
|
+
earliestAdminScanAt: string | null;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Complete analytics for an order.
|
|
257
|
+
*/
|
|
258
|
+
export interface OrderAnalyticsResponse {
|
|
259
|
+
orderRef: string;
|
|
260
|
+
orderId: string;
|
|
261
|
+
itemCount: number;
|
|
262
|
+
tagCount: number;
|
|
263
|
+
analytics: {
|
|
264
|
+
totalScans: number;
|
|
265
|
+
adminScans: number;
|
|
266
|
+
customerScans: number;
|
|
267
|
+
earliestScanAt: string;
|
|
268
|
+
latestScanAt: string;
|
|
269
|
+
earliestAdminScanAt: string | null;
|
|
270
|
+
earliestCustomerScanAt: string | null;
|
|
271
|
+
estimatedCreatedAt: string;
|
|
272
|
+
uniqueLocations: number;
|
|
273
|
+
locations: string[];
|
|
274
|
+
uniqueDevices: number;
|
|
275
|
+
devices: string[];
|
|
276
|
+
eventTypes: string[];
|
|
277
|
+
tagSummaries: TagScanSummary[];
|
|
278
|
+
} | null;
|
|
279
|
+
message?: string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Individual scan event from timeline.
|
|
283
|
+
*/
|
|
284
|
+
export interface TagScanEvent {
|
|
285
|
+
codeId: string;
|
|
286
|
+
claimId: string;
|
|
287
|
+
proofId: string | null;
|
|
288
|
+
productId: string | null;
|
|
289
|
+
variantId: string | null;
|
|
290
|
+
batchId: string | null;
|
|
291
|
+
collectionId: string;
|
|
292
|
+
timestamp: string;
|
|
293
|
+
isAdmin: boolean;
|
|
294
|
+
eventType: string | null;
|
|
295
|
+
location: string | null;
|
|
296
|
+
location_accuracy: number | null;
|
|
297
|
+
deviceType: string | null;
|
|
298
|
+
ip: string | null;
|
|
299
|
+
country: string | null;
|
|
300
|
+
sessionId: string | null;
|
|
301
|
+
metadata: Record<string, any> | null;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Request for timeline analytics.
|
|
305
|
+
*/
|
|
306
|
+
export interface TimelineRequest {
|
|
307
|
+
limit?: number;
|
|
308
|
+
from?: string;
|
|
309
|
+
to?: string;
|
|
310
|
+
isAdmin?: boolean;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Response with scan timeline.
|
|
314
|
+
*/
|
|
315
|
+
export interface TimelineResponse {
|
|
316
|
+
orderRef: string;
|
|
317
|
+
orderId: string;
|
|
318
|
+
timeline: TagScanEvent[];
|
|
319
|
+
count: number;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Location-based scan event.
|
|
323
|
+
*/
|
|
324
|
+
export interface LocationScan extends TagScanEvent {
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Request for location history.
|
|
328
|
+
*/
|
|
329
|
+
export interface LocationRequest {
|
|
330
|
+
limit?: number;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Response with location history.
|
|
334
|
+
*/
|
|
335
|
+
export interface LocationResponse {
|
|
336
|
+
orderRef: string;
|
|
337
|
+
orderId: string;
|
|
338
|
+
locations: LocationScan[];
|
|
339
|
+
count: number;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Request for bulk analytics.
|
|
343
|
+
*/
|
|
344
|
+
export interface BulkAnalyticsRequest {
|
|
345
|
+
orderIds: string[];
|
|
346
|
+
from?: string;
|
|
347
|
+
to?: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Summary analytics for a single order in bulk request.
|
|
351
|
+
*/
|
|
352
|
+
export interface OrderAnalyticsSummary {
|
|
353
|
+
orderId: string;
|
|
354
|
+
orderRef: string;
|
|
355
|
+
analytics: {
|
|
356
|
+
totalScans: number;
|
|
357
|
+
adminScans: number;
|
|
358
|
+
customerScans: number;
|
|
359
|
+
earliestScanAt: string | null;
|
|
360
|
+
earliestAdminScanAt: string | null;
|
|
361
|
+
estimatedCreatedAt: string | null;
|
|
362
|
+
tagCount: number;
|
|
363
|
+
tagSummaries: TagScanSummary[];
|
|
364
|
+
} | null;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Response from bulk analytics request.
|
|
368
|
+
*/
|
|
369
|
+
export interface BulkAnalyticsResponse {
|
|
370
|
+
results: OrderAnalyticsSummary[];
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Daily scan count for summary analytics.
|
|
374
|
+
*/
|
|
375
|
+
export interface DailyScanCount {
|
|
376
|
+
date: string;
|
|
377
|
+
scanCount: number;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Admin activity event.
|
|
381
|
+
*/
|
|
382
|
+
export interface AdminActivityEvent {
|
|
383
|
+
timestamp: string;
|
|
384
|
+
eventType: string;
|
|
385
|
+
codeId: string;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Request for collection summary.
|
|
389
|
+
*/
|
|
390
|
+
export interface SummaryRequest {
|
|
391
|
+
from?: string;
|
|
392
|
+
to?: string;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Response with collection-wide analytics summary.
|
|
396
|
+
*/
|
|
397
|
+
export interface CollectionSummaryResponse {
|
|
398
|
+
adminActivity: {
|
|
399
|
+
count: number;
|
|
400
|
+
recent: AdminActivityEvent[];
|
|
401
|
+
};
|
|
402
|
+
scansByDay: DailyScanCount[];
|
|
403
|
+
adminScansByDay: DailyScanCount[];
|
|
404
|
+
customerScansByDay: DailyScanCount[];
|
|
405
|
+
}
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.19 | Generated: 2026-02-08T09:16:59.107Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -2395,6 +2395,177 @@ interface LookupByProductResponse {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
```
|
|
2397
2397
|
|
|
2398
|
+
**TagScanSummary** (interface)
|
|
2399
|
+
```typescript
|
|
2400
|
+
interface TagScanSummary {
|
|
2401
|
+
tagId: string
|
|
2402
|
+
totalScans: number
|
|
2403
|
+
adminScans: number
|
|
2404
|
+
customerScans: number
|
|
2405
|
+
earliestScanAt: string | null
|
|
2406
|
+
earliestAdminScanAt: string | null
|
|
2407
|
+
}
|
|
2408
|
+
```
|
|
2409
|
+
|
|
2410
|
+
**OrderAnalyticsResponse** (interface)
|
|
2411
|
+
```typescript
|
|
2412
|
+
interface OrderAnalyticsResponse {
|
|
2413
|
+
orderRef: string
|
|
2414
|
+
orderId: string
|
|
2415
|
+
itemCount: number
|
|
2416
|
+
tagCount: number
|
|
2417
|
+
analytics: {
|
|
2418
|
+
totalScans: number
|
|
2419
|
+
adminScans: number
|
|
2420
|
+
customerScans: number
|
|
2421
|
+
earliestScanAt: string // ISO 8601
|
|
2422
|
+
latestScanAt: string // ISO 8601
|
|
2423
|
+
earliestAdminScanAt: string | null // ISO 8601
|
|
2424
|
+
earliestCustomerScanAt: string | null // ISO 8601
|
|
2425
|
+
estimatedCreatedAt: string // ISO 8601 - earliest admin scan or earliest scan
|
|
2426
|
+
uniqueLocations: number
|
|
2427
|
+
locations: string[] // Array of location strings
|
|
2428
|
+
uniqueDevices: number
|
|
2429
|
+
devices: string[] // Array of device types
|
|
2430
|
+
eventTypes: string[] // e.g., ["scan_tag", "verify_tag"]
|
|
2431
|
+
tagSummaries: TagScanSummary[]
|
|
2432
|
+
} | null // null if no tags found
|
|
2433
|
+
message?: string // Only present if no tags found
|
|
2434
|
+
}
|
|
2435
|
+
```
|
|
2436
|
+
|
|
2437
|
+
**TagScanEvent** (interface)
|
|
2438
|
+
```typescript
|
|
2439
|
+
interface TagScanEvent {
|
|
2440
|
+
codeId: string
|
|
2441
|
+
claimId: string
|
|
2442
|
+
proofId: string | null
|
|
2443
|
+
productId: string | null
|
|
2444
|
+
variantId: string | null
|
|
2445
|
+
batchId: string | null
|
|
2446
|
+
collectionId: string
|
|
2447
|
+
timestamp: string // ISO 8601
|
|
2448
|
+
isAdmin: boolean
|
|
2449
|
+
eventType: string | null // e.g., "scan_tag"
|
|
2450
|
+
location: string | null // GPS coordinates or location string
|
|
2451
|
+
location_accuracy: number | null
|
|
2452
|
+
deviceType: string | null
|
|
2453
|
+
ip: string | null
|
|
2454
|
+
country: string | null
|
|
2455
|
+
sessionId: string | null
|
|
2456
|
+
metadata: Record<string, any> | null
|
|
2457
|
+
}
|
|
2458
|
+
```
|
|
2459
|
+
|
|
2460
|
+
**TimelineRequest** (interface)
|
|
2461
|
+
```typescript
|
|
2462
|
+
interface TimelineRequest {
|
|
2463
|
+
limit?: number // Max results (default: 1000)
|
|
2464
|
+
from?: string // ISO 8601 start date filter
|
|
2465
|
+
to?: string // ISO 8601 end date filter
|
|
2466
|
+
isAdmin?: boolean // Filter by admin scans only
|
|
2467
|
+
}
|
|
2468
|
+
```
|
|
2469
|
+
|
|
2470
|
+
**TimelineResponse** (interface)
|
|
2471
|
+
```typescript
|
|
2472
|
+
interface TimelineResponse {
|
|
2473
|
+
orderRef: string
|
|
2474
|
+
orderId: string
|
|
2475
|
+
timeline: TagScanEvent[]
|
|
2476
|
+
count: number
|
|
2477
|
+
}
|
|
2478
|
+
```
|
|
2479
|
+
|
|
2480
|
+
**LocationRequest** (interface)
|
|
2481
|
+
```typescript
|
|
2482
|
+
interface LocationRequest {
|
|
2483
|
+
limit?: number // Max results (default: 1000)
|
|
2484
|
+
}
|
|
2485
|
+
```
|
|
2486
|
+
|
|
2487
|
+
**LocationResponse** (interface)
|
|
2488
|
+
```typescript
|
|
2489
|
+
interface LocationResponse {
|
|
2490
|
+
orderRef: string
|
|
2491
|
+
orderId: string
|
|
2492
|
+
locations: LocationScan[]
|
|
2493
|
+
count: number
|
|
2494
|
+
}
|
|
2495
|
+
```
|
|
2496
|
+
|
|
2497
|
+
**BulkAnalyticsRequest** (interface)
|
|
2498
|
+
```typescript
|
|
2499
|
+
interface BulkAnalyticsRequest {
|
|
2500
|
+
orderIds: string[] // Array of order IDs
|
|
2501
|
+
from?: string // ISO 8601 start date filter
|
|
2502
|
+
to?: string // ISO 8601 end date filter
|
|
2503
|
+
}
|
|
2504
|
+
```
|
|
2505
|
+
|
|
2506
|
+
**OrderAnalyticsSummary** (interface)
|
|
2507
|
+
```typescript
|
|
2508
|
+
interface OrderAnalyticsSummary {
|
|
2509
|
+
orderId: string
|
|
2510
|
+
orderRef: string
|
|
2511
|
+
analytics: {
|
|
2512
|
+
totalScans: number
|
|
2513
|
+
adminScans: number
|
|
2514
|
+
customerScans: number
|
|
2515
|
+
earliestScanAt: string | null
|
|
2516
|
+
earliestAdminScanAt: string | null
|
|
2517
|
+
estimatedCreatedAt: string | null
|
|
2518
|
+
tagCount: number
|
|
2519
|
+
tagSummaries: TagScanSummary[]
|
|
2520
|
+
} | null
|
|
2521
|
+
}
|
|
2522
|
+
```
|
|
2523
|
+
|
|
2524
|
+
**BulkAnalyticsResponse** (interface)
|
|
2525
|
+
```typescript
|
|
2526
|
+
interface BulkAnalyticsResponse {
|
|
2527
|
+
results: OrderAnalyticsSummary[]
|
|
2528
|
+
}
|
|
2529
|
+
```
|
|
2530
|
+
|
|
2531
|
+
**DailyScanCount** (interface)
|
|
2532
|
+
```typescript
|
|
2533
|
+
interface DailyScanCount {
|
|
2534
|
+
date: string // YYYY-MM-DD
|
|
2535
|
+
scanCount: number
|
|
2536
|
+
}
|
|
2537
|
+
```
|
|
2538
|
+
|
|
2539
|
+
**AdminActivityEvent** (interface)
|
|
2540
|
+
```typescript
|
|
2541
|
+
interface AdminActivityEvent {
|
|
2542
|
+
timestamp: string // ISO 8601
|
|
2543
|
+
eventType: string
|
|
2544
|
+
codeId: string
|
|
2545
|
+
}
|
|
2546
|
+
```
|
|
2547
|
+
|
|
2548
|
+
**SummaryRequest** (interface)
|
|
2549
|
+
```typescript
|
|
2550
|
+
interface SummaryRequest {
|
|
2551
|
+
from?: string // ISO 8601 start date filter
|
|
2552
|
+
to?: string // ISO 8601 end date filter
|
|
2553
|
+
}
|
|
2554
|
+
```
|
|
2555
|
+
|
|
2556
|
+
**CollectionSummaryResponse** (interface)
|
|
2557
|
+
```typescript
|
|
2558
|
+
interface CollectionSummaryResponse {
|
|
2559
|
+
adminActivity: {
|
|
2560
|
+
count: number
|
|
2561
|
+
recent: AdminActivityEvent[] // Last 100 events
|
|
2562
|
+
}
|
|
2563
|
+
scansByDay: DailyScanCount[]
|
|
2564
|
+
adminScansByDay: DailyScanCount[]
|
|
2565
|
+
customerScansByDay: DailyScanCount[]
|
|
2566
|
+
}
|
|
2567
|
+
```
|
|
2568
|
+
|
|
2398
2569
|
### product
|
|
2399
2570
|
|
|
2400
2571
|
**Product** (interface)
|
|
@@ -4177,6 +4348,28 @@ Get reports and aggregations for orders. Provides analytics grouped by status, c
|
|
|
4177
4348
|
params?: LookupByProductParams) → `Promise<LookupByProductResponse>`
|
|
4178
4349
|
Find all orders containing items with a specific product ID. Uses the automatic productSummary tracking in order metadata. ```typescript // Find all orders with a specific product const result = await order.findByProduct('coll_123', 'product_abc123', { limit: 50, includeItems: false }) result.orders.forEach(ord => { const count = ord.metadata.productSummary?.['product_abc123'] ?? 0 console.log(`Order ${ord.orderRef} has ${count} items of this product`) }) ```
|
|
4179
4350
|
|
|
4351
|
+
**getAnalytics**(collectionId: string,
|
|
4352
|
+
orderId: string) → `Promise<OrderAnalyticsResponse>`
|
|
4353
|
+
Get comprehensive scan analytics for all tags in an order. Returns scan counts, timestamps, locations, devices, and per-tag summaries. ```typescript const analytics = await order.getAnalytics('coll_123', 'order_abc123') if (analytics.analytics) { console.log(`Total scans: ${analytics.analytics.totalScans}`) console.log(`Admin scans: ${analytics.analytics.adminScans}`) console.log(`Created at: ${analytics.analytics.estimatedCreatedAt}`) console.log(`Unique locations: ${analytics.analytics.uniqueLocations}`) analytics.analytics.tagSummaries.forEach(tag => { console.log(`Tag ${tag.tagId}: ${tag.totalScans} scans`) }) } ```
|
|
4354
|
+
|
|
4355
|
+
**getTimeline**(collectionId: string,
|
|
4356
|
+
orderId: string,
|
|
4357
|
+
params?: TimelineRequest) → `Promise<TimelineResponse>`
|
|
4358
|
+
Get chronological timeline of all scan events for an order's tags. Supports filtering by date range and admin/customer scans. ```typescript // Get all scan events const timeline = await order.getTimeline('coll_123', 'order_abc123') timeline.timeline.forEach(event => { console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`) }) // Get admin scans only from last week const adminScans = await order.getTimeline('coll_123', 'order_abc123', { isAdmin: true, from: '2026-02-01T00:00:00Z', limit: 500 }) ```
|
|
4359
|
+
|
|
4360
|
+
**getLocationHistory**(collectionId: string,
|
|
4361
|
+
orderId: string,
|
|
4362
|
+
params?: LocationRequest) → `Promise<LocationResponse>`
|
|
4363
|
+
Get location-based scan history for an order's tags. Shows where the order's tags have been scanned. ```typescript const locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100 }) console.log(`Order scanned in ${locations.count} locations`) locations.locations.forEach(scan => { console.log(`${scan.location} at ${scan.timestamp}`) }) ```
|
|
4364
|
+
|
|
4365
|
+
**getBulkAnalytics**(collectionId: string,
|
|
4366
|
+
data: BulkAnalyticsRequest) → `Promise<BulkAnalyticsResponse>`
|
|
4367
|
+
Get analytics summary for multiple orders at once. Efficient way to retrieve scan data for many orders. ```typescript const bulk = await order.getBulkAnalytics('coll_123', { orderIds: ['order_1', 'order_2', 'order_3'], from: '2026-01-01T00:00:00Z' }) bulk.results.forEach(result => { if (result.analytics) { console.log(`${result.orderRef}: ${result.analytics.totalScans} scans`) } }) ```
|
|
4368
|
+
|
|
4369
|
+
**getCollectionSummary**(collectionId: string,
|
|
4370
|
+
params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
|
|
4371
|
+
Get collection-wide analytics summary across all orders. Returns daily scan counts and admin activity overview. ```typescript // Get all-time collection summary const summary = await order.getCollectionSummary('coll_123') console.log(`Admin activity count: ${summary.adminActivity.count}`) console.log('Scans by day:') summary.scansByDay.forEach(day => { console.log(` ${day.date}: ${day.scanCount} scans`) }) // Get summary for last 30 days const recentSummary = await order.getCollectionSummary('coll_123', { from: '2026-01-08T00:00:00Z', to: '2026-02-08T00:00:00Z' }) ```
|
|
4372
|
+
|
|
4180
4373
|
### product
|
|
4181
4374
|
|
|
4182
4375
|
**get**(collectionId: string,
|