@gymspace/sdk 1.2.12 → 1.2.14

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.js CHANGED
@@ -379,18 +379,10 @@ var GymsResource = class extends BaseResource {
379
379
  this.basePath = "gyms";
380
380
  }
381
381
  async createGym(data, options) {
382
- return this.client.post(
383
- this.basePath,
384
- data,
385
- options
386
- );
382
+ return this.client.post(this.basePath, data, options);
387
383
  }
388
384
  async getOrganizationGyms(options) {
389
- return this.client.get(
390
- this.basePath,
391
- void 0,
392
- options
393
- );
385
+ return this.client.get(this.basePath, void 0, options);
394
386
  }
395
387
  async getGym(id, options) {
396
388
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
@@ -413,6 +405,44 @@ var GymsResource = class extends BaseResource {
413
405
  async updateGymSocialMedia(id, data, options) {
414
406
  return this.client.put(`${this.basePath}/${id}/social-media`, data, options);
415
407
  }
408
+ /**
409
+ * Update current gym inventory settings (stock configuration)
410
+ * Uses gym from context (x-gym-id header)
411
+ * @param data Inventory settings data
412
+ * @param options Request options
413
+ * @returns Updated gym with new settings
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * const gym = await sdk.gyms.updateInventorySettings({
418
+ * defaultMinStock: 15,
419
+ * defaultMaxStock: 1000,
420
+ * enableLowStockAlerts: true
421
+ * });
422
+ * ```
423
+ */
424
+ async updateInventorySettings(data, options) {
425
+ return this.client.patch(`${this.basePath}/current/inventory-settings`, data, options);
426
+ }
427
+ /**
428
+ * Update current gym contract expiration settings
429
+ * Uses gym from context (x-gym-id header)
430
+ * @param data Contract settings data
431
+ * @param options Request options
432
+ * @returns Updated gym with new settings
433
+ *
434
+ * @example
435
+ * ```typescript
436
+ * const gym = await sdk.gyms.updateContractSettings({
437
+ * expiringSoonDays: 7,
438
+ * gracePeriodDays: 0,
439
+ * enableExpirationNotifications: true
440
+ * });
441
+ * ```
442
+ */
443
+ async updateContractSettings(data, options) {
444
+ return this.client.patch(`${this.basePath}/current/contract-settings`, data, options);
445
+ }
416
446
  };
417
447
 
418
448
  // src/resources/collaborators.ts
@@ -573,6 +603,29 @@ var ContractsResource = class extends BaseResource {
573
603
  async cancelContract(id, data, options) {
574
604
  return this.client.put(`${this.basePath}/${id}/cancel`, data, options);
575
605
  }
606
+ async suspendContract(id, data, options) {
607
+ return this.client.post(`${this.basePath}/${id}/suspend`, data, options);
608
+ }
609
+ async resumeContract(id, data, options) {
610
+ return this.client.post(`${this.basePath}/${id}/resume`, data, options);
611
+ }
612
+ async reactivateContract(id, data, options) {
613
+ return this.client.post(`${this.basePath}/${id}/reactivate`, data, options);
614
+ }
615
+ async getLifecycleHistory(id, options) {
616
+ return this.client.get(
617
+ `${this.basePath}/${id}/lifecycle-history`,
618
+ void 0,
619
+ options
620
+ );
621
+ }
622
+ async getCancellationAnalytics(params, options) {
623
+ return this.client.get(
624
+ `${this.basePath}/analytics/cancellation-reasons`,
625
+ params,
626
+ options
627
+ );
628
+ }
576
629
  async resendWhatsAppNotification(contractId, options) {
577
630
  return this.client.post(
578
631
  `${this.basePath}/${contractId}/resend-whatsapp`,
@@ -659,6 +712,19 @@ var CheckInsResource = class extends BaseResource {
659
712
  super(...arguments);
660
713
  this.basePath = "check-ins";
661
714
  }
715
+ /**
716
+ * Creates a new check-in for a client.
717
+ *
718
+ * **Permissions Required:**
719
+ * - Gym owners with full gym access
720
+ * - Active collaborators with CHECKINS_CREATE permission
721
+ *
722
+ * @param data - The check-in data including client ID and optional notes
723
+ * @param options - Optional request configuration
724
+ * @returns The created check-in record with client and user details
725
+ * @throws {ValidationError} When client is not found or already checked in
726
+ * @throws {AuthorizationError} When user lacks required permissions
727
+ */
662
728
  async createCheckIn(data, options) {
663
729
  return this.client.post(this.basePath, data, options);
664
730
  }
@@ -671,6 +737,25 @@ var CheckInsResource = class extends BaseResource {
671
737
  async getCheckIn(id, options) {
672
738
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
673
739
  }
740
+ /**
741
+ * Deletes a check-in record.
742
+ *
743
+ * **Permissions Required:**
744
+ * - Gym owners with full gym access
745
+ * - Active collaborators with CHECKINS_CREATE permission
746
+ *
747
+ * **Business Rules:**
748
+ * - Only check-ins from today can be deleted
749
+ * - The same permission level required for creation is required for deletion
750
+ * - Cannot delete check-ins from previous days
751
+ *
752
+ * @param id - The ID of the check-in to delete
753
+ * @param options - Optional request configuration
754
+ * @returns Promise that resolves when the check-in is successfully deleted
755
+ * @throws {NotFoundError} When the check-in is not found
756
+ * @throws {AuthorizationError} When user lacks required permissions
757
+ * @throws {ValidationError} When trying to delete a check-in from a previous day
758
+ */
674
759
  async deleteCheckIn(id, options) {
675
760
  return this.client.delete(`${this.basePath}/${id}`, options);
676
761
  }
@@ -1167,6 +1252,13 @@ var SubscriptionPlansResource = class extends BaseResource {
1167
1252
  constructor() {
1168
1253
  super(...arguments);
1169
1254
  this.basePath = "admin/subscription-plans";
1255
+ this.publicBasePath = "subscription-plans/public";
1256
+ }
1257
+ /**
1258
+ * List all active subscription plans (Public - no authentication required)
1259
+ */
1260
+ async listPublicPlans(options) {
1261
+ return this.client.get(`${this.publicBasePath}`, void 0, options);
1170
1262
  }
1171
1263
  /**
1172
1264
  * List all subscription plans (Super Admin only)
@@ -1400,6 +1492,220 @@ var WhatsAppTemplatesResource = class extends BaseResource {
1400
1492
  }
1401
1493
  };
1402
1494
 
1495
+ // src/resources/bulk-messaging.ts
1496
+ var BulkMessagingResource = class extends BaseResource {
1497
+ constructor() {
1498
+ super(...arguments);
1499
+ this.basePath = "whatsapp/bulk-messaging";
1500
+ this.templatesPath = "whatsapp/bulk-templates";
1501
+ }
1502
+ async createTemplate(data, options) {
1503
+ return this.client.post(this.templatesPath, data, options);
1504
+ }
1505
+ async getTemplates(options) {
1506
+ return this.client.get(this.templatesPath, void 0, options);
1507
+ }
1508
+ async getTemplate(id, options) {
1509
+ return this.client.get(`${this.templatesPath}/${id}`, void 0, options);
1510
+ }
1511
+ async updateTemplate(id, data, options) {
1512
+ return this.client.put(`${this.templatesPath}/${id}`, data, options);
1513
+ }
1514
+ async deleteTemplate(id, options) {
1515
+ return this.client.delete(`${this.templatesPath}/${id}`, options);
1516
+ }
1517
+ async getAvailableVariables(options) {
1518
+ return this.client.get(
1519
+ `${this.basePath}/available-variables`,
1520
+ void 0,
1521
+ options
1522
+ );
1523
+ }
1524
+ /**
1525
+ * Generate AI message with streaming support
1526
+ * Note: This proxies to the agent endpoint for streaming responses
1527
+ */
1528
+ async generateAIMessage(data, options) {
1529
+ return this.client.post(
1530
+ `${this.basePath}/generate-ai`,
1531
+ data,
1532
+ options
1533
+ );
1534
+ }
1535
+ /**
1536
+ * Send bulk messages to multiple clients
1537
+ * Note: SDK sends clientIds, API fetches full client and gym data before sending to agent
1538
+ */
1539
+ async send(data, options) {
1540
+ return this.client.post(`${this.basePath}/send`, data, options);
1541
+ }
1542
+ /**
1543
+ * Get logs for a bulk message send operation
1544
+ */
1545
+ async getLogs(sendId, options) {
1546
+ return this.client.get(`${this.basePath}/logs`, { sendId }, options);
1547
+ }
1548
+ };
1549
+
1550
+ // src/resources/activities.ts
1551
+ var ActivitiesResource = class extends BaseResource {
1552
+ constructor() {
1553
+ super(...arguments);
1554
+ this.basePath = "activities";
1555
+ }
1556
+ async createActivity(data, options) {
1557
+ return this.client.post(this.basePath, data, options);
1558
+ }
1559
+ async searchActivities(params, options) {
1560
+ return this.paginate(this.basePath, params, options);
1561
+ }
1562
+ async getActivity(id, options) {
1563
+ return this.client.get(`${this.basePath}/${id}`, void 0, options);
1564
+ }
1565
+ async updateActivity(id, data, options) {
1566
+ return this.client.patch(`${this.basePath}/${id}`, data, options);
1567
+ }
1568
+ async deleteActivity(id, params, options) {
1569
+ const queryString = params?.deleteRecurrence ? "?deleteRecurrence=true" : "";
1570
+ return this.client.delete(`${this.basePath}/${id}${queryString}`, options);
1571
+ }
1572
+ async createNotification(activityId, data, options) {
1573
+ return this.client.post(
1574
+ `${this.basePath}/${activityId}/notifications`,
1575
+ data,
1576
+ options
1577
+ );
1578
+ }
1579
+ async getNotifications(activityId, options) {
1580
+ return this.client.get(
1581
+ `${this.basePath}/${activityId}/notifications`,
1582
+ void 0,
1583
+ options
1584
+ );
1585
+ }
1586
+ async updateNotification(activityId, notificationId, data, options) {
1587
+ return this.client.patch(
1588
+ `${this.basePath}/${activityId}/notifications/${notificationId}`,
1589
+ data,
1590
+ options
1591
+ );
1592
+ }
1593
+ async deleteNotification(activityId, notificationId, options) {
1594
+ return this.client.delete(
1595
+ `${this.basePath}/${activityId}/notifications/${notificationId}`,
1596
+ options
1597
+ );
1598
+ }
1599
+ async getStats(params, options) {
1600
+ return this.client.get(`${this.basePath}/stats`, params, options);
1601
+ }
1602
+ async getEligibleClients(activityId, options) {
1603
+ return this.client.get(
1604
+ `${this.basePath}/${activityId}/eligible-clients`,
1605
+ void 0,
1606
+ options
1607
+ );
1608
+ }
1609
+ };
1610
+
1611
+ // src/resources/tags.ts
1612
+ var TagsResource = class extends BaseResource {
1613
+ constructor() {
1614
+ super(...arguments);
1615
+ this.basePath = "tags";
1616
+ }
1617
+ // ==================== Tag Management ====================
1618
+ /**
1619
+ * Create a new tag
1620
+ * POST /api/v1/tags
1621
+ */
1622
+ async createTag(data, options) {
1623
+ return this.client.post(this.basePath, data, options);
1624
+ }
1625
+ /**
1626
+ * List all tags with optional filters and pagination
1627
+ * GET /api/v1/tags
1628
+ */
1629
+ async searchTags(params, options) {
1630
+ return this.client.get(this.basePath, params, options);
1631
+ }
1632
+ /**
1633
+ * Get a specific tag by ID
1634
+ * GET /api/v1/tags/:id
1635
+ */
1636
+ async getTag(id, options) {
1637
+ return this.client.get(`${this.basePath}/${id}`, void 0, options);
1638
+ }
1639
+ /**
1640
+ * Update an existing tag
1641
+ * PUT /api/v1/tags/:id
1642
+ */
1643
+ async updateTag(id, data, options) {
1644
+ return this.client.put(`${this.basePath}/${id}`, data, options);
1645
+ }
1646
+ /**
1647
+ * Delete a tag (soft delete)
1648
+ * DELETE /api/v1/tags/:id
1649
+ * @param id - Tag ID
1650
+ * @param force - Force deletion even if tag has assigned clients
1651
+ */
1652
+ async deleteTag(id, force, options) {
1653
+ const path = force ? `${this.basePath}/${id}?force=true` : `${this.basePath}/${id}`;
1654
+ return this.client.delete(path, options);
1655
+ }
1656
+ /**
1657
+ * Get clients with a specific tag
1658
+ * GET /api/v1/tags/:id/clients
1659
+ */
1660
+ async getTagClients(id, params, options) {
1661
+ return this.client.get(`${this.basePath}/${id}/clients`, params, options);
1662
+ }
1663
+ /**
1664
+ * Get tag statistics
1665
+ * GET /api/v1/tags/stats
1666
+ */
1667
+ async getTagStats(options) {
1668
+ return this.client.get(`${this.basePath}/stats`, void 0, options);
1669
+ }
1670
+ // ==================== Client Tag Assignment ====================
1671
+ /**
1672
+ * Assign one or multiple tags to a client
1673
+ * POST /api/v1/clients/:clientId/tags
1674
+ */
1675
+ async assignTagsToClient(clientId, data, options) {
1676
+ return this.client.post(`clients/${clientId}/tags`, data, options);
1677
+ }
1678
+ /**
1679
+ * Remove a specific tag from a client
1680
+ * DELETE /api/v1/clients/:clientId/tags/:tagId
1681
+ */
1682
+ async removeTagFromClient(clientId, tagId, options) {
1683
+ return this.client.delete(`clients/${clientId}/tags/${tagId}`, options);
1684
+ }
1685
+ /**
1686
+ * Remove multiple tags from a client
1687
+ * DELETE /api/v1/clients/:clientId/tags
1688
+ * Note: This endpoint requires sending tagIds in the request body
1689
+ */
1690
+ async removeTagsFromClient(clientId, tagIds, options) {
1691
+ return this.request(`clients/${clientId}/tags`, {
1692
+ method: "DELETE",
1693
+ body: JSON.stringify({ tagIds }),
1694
+ headers: {
1695
+ "Content-Type": "application/json",
1696
+ ...options?.headers
1697
+ }
1698
+ });
1699
+ }
1700
+ /**
1701
+ * Get all tags assigned to a client
1702
+ * GET /api/v1/clients/:clientId/tags
1703
+ */
1704
+ async getClientTags(clientId, options) {
1705
+ return this.client.get(`clients/${clientId}/tags`, void 0, options);
1706
+ }
1707
+ };
1708
+
1403
1709
  // src/sdk.ts
1404
1710
  var GymSpaceSdk = class {
1405
1711
  constructor(config) {
@@ -1430,6 +1736,9 @@ var GymSpaceSdk = class {
1430
1736
  this.paymentMethods = new PaymentMethodsResource(this.client);
1431
1737
  this.whatsapp = new WhatsAppResource(this.client);
1432
1738
  this.whatsappTemplates = new WhatsAppTemplatesResource(this.client);
1739
+ this.bulkMessaging = new BulkMessagingResource(this.client);
1740
+ this.activities = new ActivitiesResource(this.client);
1741
+ this.tags = new TagsResource(this.client);
1433
1742
  }
1434
1743
  /**
1435
1744
  * Set the authentication token
@@ -1856,6 +2165,25 @@ function getRoleCapabilities(roleName) {
1856
2165
  }
1857
2166
  }
1858
2167
 
2168
+ // src/models/contracts.ts
2169
+ var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
2170
+ CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
2171
+ CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
2172
+ CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
2173
+ CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
2174
+ CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
2175
+ CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
2176
+ CancellationReason2["OTHER"] = "OTHER";
2177
+ return CancellationReason2;
2178
+ })(CancellationReason || {});
2179
+ var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
2180
+ SuspensionType2["VACATION"] = "vacation";
2181
+ SuspensionType2["MEDICAL"] = "medical";
2182
+ SuspensionType2["FINANCIAL"] = "financial";
2183
+ SuspensionType2["OTHER"] = "other";
2184
+ return SuspensionType2;
2185
+ })(SuspensionType || {});
2186
+
1859
2187
  // src/models/onboarding.ts
1860
2188
  var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
1861
2189
  OnboardingStep2["ACCOUNT_CREATED"] = "account_created";
@@ -1865,6 +2193,7 @@ var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
1865
2193
  return OnboardingStep2;
1866
2194
  })(OnboardingStep || {});
1867
2195
 
2196
+ exports.ActivitiesResource = ActivitiesResource;
1868
2197
  exports.AdminSubscriptionManagementResource = AdminSubscriptionManagementResource;
1869
2198
  exports.ApiClient = ApiClient;
1870
2199
  exports.AssetCategory = AssetCategory;
@@ -1873,7 +2202,9 @@ exports.AssetsResource = AssetsResource;
1873
2202
  exports.AuthResource = AuthResource;
1874
2203
  exports.AuthenticationError = AuthenticationError;
1875
2204
  exports.AuthorizationError = AuthorizationError;
2205
+ exports.BulkMessagingResource = BulkMessagingResource;
1876
2206
  exports.CACHE_TTL = CACHE_TTL;
2207
+ exports.CancellationReason = CancellationReason;
1877
2208
  exports.CheckInsResource = CheckInsResource;
1878
2209
  exports.ClientStatus = ClientStatus;
1879
2210
  exports.ClientsResource = ClientsResource;
@@ -1921,6 +2252,8 @@ exports.SubscriptionPlansResource = SubscriptionPlansResource;
1921
2252
  exports.SubscriptionStatus = SubscriptionStatus;
1922
2253
  exports.SubscriptionsResource = SubscriptionsResource;
1923
2254
  exports.SuppliersResource = SuppliersResource;
2255
+ exports.SuspensionType = SuspensionType;
2256
+ exports.TagsResource = TagsResource;
1924
2257
  exports.UserType = UserType;
1925
2258
  exports.UsersResource = UsersResource;
1926
2259
  exports.ValidationError = ValidationError;