@delopay/sdk 0.64.0 → 0.65.0

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/index.cjs CHANGED
@@ -1745,13 +1745,26 @@ var Projects = class {
1745
1745
  /**
1746
1746
  * Get aggregate payment statistics across all projects for a merchant.
1747
1747
  *
1748
+ * The response's flat `shops[]` array holds every shop, including shops that
1749
+ * belong to no project — those are absent from `projects[].shops[]`, so look
1750
+ * a single shop up in `shops[]`. Requires `MerchantAccountRead`; a
1751
+ * shop-scoped user should call {@link Shops.stats} instead.
1752
+ *
1748
1753
  * @param merchantId - The merchant account ID.
1754
+ * @param period - Window in days, or `'all'` for an all-time total.
1755
+ * Omitted means the server default of 30 days.
1749
1756
  * @returns Project statistics.
1757
+ *
1758
+ * @example
1759
+ * ```typescript
1760
+ * const stats = await delopay.projects.stats('merch_123', 'all');
1761
+ * const shop = stats.shops.find((s) => s.shop_id === 'pro_1');
1762
+ * ```
1750
1763
  */
1751
- async stats(merchantId) {
1752
- return this.request("GET", "/projects/stats", {
1753
- query: { merchant_id: merchantId }
1754
- });
1764
+ async stats(merchantId, period) {
1765
+ const query = { merchant_id: merchantId };
1766
+ if (period !== void 0) query["period"] = String(period);
1767
+ return this.request("GET", "/projects/stats", { query });
1755
1768
  }
1756
1769
  /**
1757
1770
  * Get a high-level overview (volume, counts, top connectors) for a merchant.
@@ -2235,6 +2248,34 @@ var Shops = class {
2235
2248
  async list(merchantId) {
2236
2249
  return this.request("GET", `/shops/${encodeURIComponent(merchantId)}`);
2237
2250
  }
2251
+ /**
2252
+ * Successful-order count and revenue for one shop.
2253
+ *
2254
+ * Unlike `projects.stats()` this needs only `ProfileAccountRead`, so a
2255
+ * shop-scoped user can load it for their own shop; merchant-level users can
2256
+ * load any shop of their merchant.
2257
+ *
2258
+ * Revenue comes back FX-converted as `revenue_usd` (USD major units) plus a
2259
+ * `revenue_by_currency` breakdown. The legacy `revenue` field is a raw
2260
+ * cross-currency minor-unit sum and should not be displayed.
2261
+ *
2262
+ * @param merchantId - The merchant account ID.
2263
+ * @param shopId - The shop (business profile) ID.
2264
+ * @param period - Window in days, or `'all'` for an all-time total.
2265
+ * Omitted means the server default of 30 days.
2266
+ * @returns The shop's stats over the requested window.
2267
+ *
2268
+ * @example
2269
+ * ```typescript
2270
+ * const stats = await delopay.shops.stats('merch_123', 'pro_1', 'all');
2271
+ * console.log(stats.orders, stats.revenue_usd);
2272
+ * ```
2273
+ */
2274
+ async stats(merchantId, shopId, period) {
2275
+ const path = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
2276
+ if (period === void 0) return this.request("GET", path);
2277
+ return this.request("GET", path, { query: { period: String(period) } });
2278
+ }
2238
2279
  /**
2239
2280
  * Upload a logo file for a shop. The file is stored in Delopay's configured
2240
2281
  * object store and a public HTTPS URL is returned. This method does NOT write