@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.mjs CHANGED
@@ -373,18 +373,10 @@ var GymsResource = class extends BaseResource {
373
373
  this.basePath = "gyms";
374
374
  }
375
375
  async createGym(data, options) {
376
- return this.client.post(
377
- this.basePath,
378
- data,
379
- options
380
- );
376
+ return this.client.post(this.basePath, data, options);
381
377
  }
382
378
  async getOrganizationGyms(options) {
383
- return this.client.get(
384
- this.basePath,
385
- void 0,
386
- options
387
- );
379
+ return this.client.get(this.basePath, void 0, options);
388
380
  }
389
381
  async getGym(id, options) {
390
382
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
@@ -407,6 +399,44 @@ var GymsResource = class extends BaseResource {
407
399
  async updateGymSocialMedia(id, data, options) {
408
400
  return this.client.put(`${this.basePath}/${id}/social-media`, data, options);
409
401
  }
402
+ /**
403
+ * Update current gym inventory settings (stock configuration)
404
+ * Uses gym from context (x-gym-id header)
405
+ * @param data Inventory settings data
406
+ * @param options Request options
407
+ * @returns Updated gym with new settings
408
+ *
409
+ * @example
410
+ * ```typescript
411
+ * const gym = await sdk.gyms.updateInventorySettings({
412
+ * defaultMinStock: 15,
413
+ * defaultMaxStock: 1000,
414
+ * enableLowStockAlerts: true
415
+ * });
416
+ * ```
417
+ */
418
+ async updateInventorySettings(data, options) {
419
+ return this.client.patch(`${this.basePath}/current/inventory-settings`, data, options);
420
+ }
421
+ /**
422
+ * Update current gym contract expiration settings
423
+ * Uses gym from context (x-gym-id header)
424
+ * @param data Contract settings data
425
+ * @param options Request options
426
+ * @returns Updated gym with new settings
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * const gym = await sdk.gyms.updateContractSettings({
431
+ * expiringSoonDays: 7,
432
+ * gracePeriodDays: 0,
433
+ * enableExpirationNotifications: true
434
+ * });
435
+ * ```
436
+ */
437
+ async updateContractSettings(data, options) {
438
+ return this.client.patch(`${this.basePath}/current/contract-settings`, data, options);
439
+ }
410
440
  };
411
441
 
412
442
  // src/resources/collaborators.ts
@@ -567,6 +597,29 @@ var ContractsResource = class extends BaseResource {
567
597
  async cancelContract(id, data, options) {
568
598
  return this.client.put(`${this.basePath}/${id}/cancel`, data, options);
569
599
  }
600
+ async suspendContract(id, data, options) {
601
+ return this.client.post(`${this.basePath}/${id}/suspend`, data, options);
602
+ }
603
+ async resumeContract(id, data, options) {
604
+ return this.client.post(`${this.basePath}/${id}/resume`, data, options);
605
+ }
606
+ async reactivateContract(id, data, options) {
607
+ return this.client.post(`${this.basePath}/${id}/reactivate`, data, options);
608
+ }
609
+ async getLifecycleHistory(id, options) {
610
+ return this.client.get(
611
+ `${this.basePath}/${id}/lifecycle-history`,
612
+ void 0,
613
+ options
614
+ );
615
+ }
616
+ async getCancellationAnalytics(params, options) {
617
+ return this.client.get(
618
+ `${this.basePath}/analytics/cancellation-reasons`,
619
+ params,
620
+ options
621
+ );
622
+ }
570
623
  async resendWhatsAppNotification(contractId, options) {
571
624
  return this.client.post(
572
625
  `${this.basePath}/${contractId}/resend-whatsapp`,
@@ -653,6 +706,19 @@ var CheckInsResource = class extends BaseResource {
653
706
  super(...arguments);
654
707
  this.basePath = "check-ins";
655
708
  }
709
+ /**
710
+ * Creates a new check-in for a client.
711
+ *
712
+ * **Permissions Required:**
713
+ * - Gym owners with full gym access
714
+ * - Active collaborators with CHECKINS_CREATE permission
715
+ *
716
+ * @param data - The check-in data including client ID and optional notes
717
+ * @param options - Optional request configuration
718
+ * @returns The created check-in record with client and user details
719
+ * @throws {ValidationError} When client is not found or already checked in
720
+ * @throws {AuthorizationError} When user lacks required permissions
721
+ */
656
722
  async createCheckIn(data, options) {
657
723
  return this.client.post(this.basePath, data, options);
658
724
  }
@@ -665,6 +731,25 @@ var CheckInsResource = class extends BaseResource {
665
731
  async getCheckIn(id, options) {
666
732
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
667
733
  }
734
+ /**
735
+ * Deletes a check-in record.
736
+ *
737
+ * **Permissions Required:**
738
+ * - Gym owners with full gym access
739
+ * - Active collaborators with CHECKINS_CREATE permission
740
+ *
741
+ * **Business Rules:**
742
+ * - Only check-ins from today can be deleted
743
+ * - The same permission level required for creation is required for deletion
744
+ * - Cannot delete check-ins from previous days
745
+ *
746
+ * @param id - The ID of the check-in to delete
747
+ * @param options - Optional request configuration
748
+ * @returns Promise that resolves when the check-in is successfully deleted
749
+ * @throws {NotFoundError} When the check-in is not found
750
+ * @throws {AuthorizationError} When user lacks required permissions
751
+ * @throws {ValidationError} When trying to delete a check-in from a previous day
752
+ */
668
753
  async deleteCheckIn(id, options) {
669
754
  return this.client.delete(`${this.basePath}/${id}`, options);
670
755
  }
@@ -1161,6 +1246,13 @@ var SubscriptionPlansResource = class extends BaseResource {
1161
1246
  constructor() {
1162
1247
  super(...arguments);
1163
1248
  this.basePath = "admin/subscription-plans";
1249
+ this.publicBasePath = "subscription-plans/public";
1250
+ }
1251
+ /**
1252
+ * List all active subscription plans (Public - no authentication required)
1253
+ */
1254
+ async listPublicPlans(options) {
1255
+ return this.client.get(`${this.publicBasePath}`, void 0, options);
1164
1256
  }
1165
1257
  /**
1166
1258
  * List all subscription plans (Super Admin only)
@@ -1394,6 +1486,220 @@ var WhatsAppTemplatesResource = class extends BaseResource {
1394
1486
  }
1395
1487
  };
1396
1488
 
1489
+ // src/resources/bulk-messaging.ts
1490
+ var BulkMessagingResource = class extends BaseResource {
1491
+ constructor() {
1492
+ super(...arguments);
1493
+ this.basePath = "whatsapp/bulk-messaging";
1494
+ this.templatesPath = "whatsapp/bulk-templates";
1495
+ }
1496
+ async createTemplate(data, options) {
1497
+ return this.client.post(this.templatesPath, data, options);
1498
+ }
1499
+ async getTemplates(options) {
1500
+ return this.client.get(this.templatesPath, void 0, options);
1501
+ }
1502
+ async getTemplate(id, options) {
1503
+ return this.client.get(`${this.templatesPath}/${id}`, void 0, options);
1504
+ }
1505
+ async updateTemplate(id, data, options) {
1506
+ return this.client.put(`${this.templatesPath}/${id}`, data, options);
1507
+ }
1508
+ async deleteTemplate(id, options) {
1509
+ return this.client.delete(`${this.templatesPath}/${id}`, options);
1510
+ }
1511
+ async getAvailableVariables(options) {
1512
+ return this.client.get(
1513
+ `${this.basePath}/available-variables`,
1514
+ void 0,
1515
+ options
1516
+ );
1517
+ }
1518
+ /**
1519
+ * Generate AI message with streaming support
1520
+ * Note: This proxies to the agent endpoint for streaming responses
1521
+ */
1522
+ async generateAIMessage(data, options) {
1523
+ return this.client.post(
1524
+ `${this.basePath}/generate-ai`,
1525
+ data,
1526
+ options
1527
+ );
1528
+ }
1529
+ /**
1530
+ * Send bulk messages to multiple clients
1531
+ * Note: SDK sends clientIds, API fetches full client and gym data before sending to agent
1532
+ */
1533
+ async send(data, options) {
1534
+ return this.client.post(`${this.basePath}/send`, data, options);
1535
+ }
1536
+ /**
1537
+ * Get logs for a bulk message send operation
1538
+ */
1539
+ async getLogs(sendId, options) {
1540
+ return this.client.get(`${this.basePath}/logs`, { sendId }, options);
1541
+ }
1542
+ };
1543
+
1544
+ // src/resources/activities.ts
1545
+ var ActivitiesResource = class extends BaseResource {
1546
+ constructor() {
1547
+ super(...arguments);
1548
+ this.basePath = "activities";
1549
+ }
1550
+ async createActivity(data, options) {
1551
+ return this.client.post(this.basePath, data, options);
1552
+ }
1553
+ async searchActivities(params, options) {
1554
+ return this.paginate(this.basePath, params, options);
1555
+ }
1556
+ async getActivity(id, options) {
1557
+ return this.client.get(`${this.basePath}/${id}`, void 0, options);
1558
+ }
1559
+ async updateActivity(id, data, options) {
1560
+ return this.client.patch(`${this.basePath}/${id}`, data, options);
1561
+ }
1562
+ async deleteActivity(id, params, options) {
1563
+ const queryString = params?.deleteRecurrence ? "?deleteRecurrence=true" : "";
1564
+ return this.client.delete(`${this.basePath}/${id}${queryString}`, options);
1565
+ }
1566
+ async createNotification(activityId, data, options) {
1567
+ return this.client.post(
1568
+ `${this.basePath}/${activityId}/notifications`,
1569
+ data,
1570
+ options
1571
+ );
1572
+ }
1573
+ async getNotifications(activityId, options) {
1574
+ return this.client.get(
1575
+ `${this.basePath}/${activityId}/notifications`,
1576
+ void 0,
1577
+ options
1578
+ );
1579
+ }
1580
+ async updateNotification(activityId, notificationId, data, options) {
1581
+ return this.client.patch(
1582
+ `${this.basePath}/${activityId}/notifications/${notificationId}`,
1583
+ data,
1584
+ options
1585
+ );
1586
+ }
1587
+ async deleteNotification(activityId, notificationId, options) {
1588
+ return this.client.delete(
1589
+ `${this.basePath}/${activityId}/notifications/${notificationId}`,
1590
+ options
1591
+ );
1592
+ }
1593
+ async getStats(params, options) {
1594
+ return this.client.get(`${this.basePath}/stats`, params, options);
1595
+ }
1596
+ async getEligibleClients(activityId, options) {
1597
+ return this.client.get(
1598
+ `${this.basePath}/${activityId}/eligible-clients`,
1599
+ void 0,
1600
+ options
1601
+ );
1602
+ }
1603
+ };
1604
+
1605
+ // src/resources/tags.ts
1606
+ var TagsResource = class extends BaseResource {
1607
+ constructor() {
1608
+ super(...arguments);
1609
+ this.basePath = "tags";
1610
+ }
1611
+ // ==================== Tag Management ====================
1612
+ /**
1613
+ * Create a new tag
1614
+ * POST /api/v1/tags
1615
+ */
1616
+ async createTag(data, options) {
1617
+ return this.client.post(this.basePath, data, options);
1618
+ }
1619
+ /**
1620
+ * List all tags with optional filters and pagination
1621
+ * GET /api/v1/tags
1622
+ */
1623
+ async searchTags(params, options) {
1624
+ return this.client.get(this.basePath, params, options);
1625
+ }
1626
+ /**
1627
+ * Get a specific tag by ID
1628
+ * GET /api/v1/tags/:id
1629
+ */
1630
+ async getTag(id, options) {
1631
+ return this.client.get(`${this.basePath}/${id}`, void 0, options);
1632
+ }
1633
+ /**
1634
+ * Update an existing tag
1635
+ * PUT /api/v1/tags/:id
1636
+ */
1637
+ async updateTag(id, data, options) {
1638
+ return this.client.put(`${this.basePath}/${id}`, data, options);
1639
+ }
1640
+ /**
1641
+ * Delete a tag (soft delete)
1642
+ * DELETE /api/v1/tags/:id
1643
+ * @param id - Tag ID
1644
+ * @param force - Force deletion even if tag has assigned clients
1645
+ */
1646
+ async deleteTag(id, force, options) {
1647
+ const path = force ? `${this.basePath}/${id}?force=true` : `${this.basePath}/${id}`;
1648
+ return this.client.delete(path, options);
1649
+ }
1650
+ /**
1651
+ * Get clients with a specific tag
1652
+ * GET /api/v1/tags/:id/clients
1653
+ */
1654
+ async getTagClients(id, params, options) {
1655
+ return this.client.get(`${this.basePath}/${id}/clients`, params, options);
1656
+ }
1657
+ /**
1658
+ * Get tag statistics
1659
+ * GET /api/v1/tags/stats
1660
+ */
1661
+ async getTagStats(options) {
1662
+ return this.client.get(`${this.basePath}/stats`, void 0, options);
1663
+ }
1664
+ // ==================== Client Tag Assignment ====================
1665
+ /**
1666
+ * Assign one or multiple tags to a client
1667
+ * POST /api/v1/clients/:clientId/tags
1668
+ */
1669
+ async assignTagsToClient(clientId, data, options) {
1670
+ return this.client.post(`clients/${clientId}/tags`, data, options);
1671
+ }
1672
+ /**
1673
+ * Remove a specific tag from a client
1674
+ * DELETE /api/v1/clients/:clientId/tags/:tagId
1675
+ */
1676
+ async removeTagFromClient(clientId, tagId, options) {
1677
+ return this.client.delete(`clients/${clientId}/tags/${tagId}`, options);
1678
+ }
1679
+ /**
1680
+ * Remove multiple tags from a client
1681
+ * DELETE /api/v1/clients/:clientId/tags
1682
+ * Note: This endpoint requires sending tagIds in the request body
1683
+ */
1684
+ async removeTagsFromClient(clientId, tagIds, options) {
1685
+ return this.request(`clients/${clientId}/tags`, {
1686
+ method: "DELETE",
1687
+ body: JSON.stringify({ tagIds }),
1688
+ headers: {
1689
+ "Content-Type": "application/json",
1690
+ ...options?.headers
1691
+ }
1692
+ });
1693
+ }
1694
+ /**
1695
+ * Get all tags assigned to a client
1696
+ * GET /api/v1/clients/:clientId/tags
1697
+ */
1698
+ async getClientTags(clientId, options) {
1699
+ return this.client.get(`clients/${clientId}/tags`, void 0, options);
1700
+ }
1701
+ };
1702
+
1397
1703
  // src/sdk.ts
1398
1704
  var GymSpaceSdk = class {
1399
1705
  constructor(config) {
@@ -1424,6 +1730,9 @@ var GymSpaceSdk = class {
1424
1730
  this.paymentMethods = new PaymentMethodsResource(this.client);
1425
1731
  this.whatsapp = new WhatsAppResource(this.client);
1426
1732
  this.whatsappTemplates = new WhatsAppTemplatesResource(this.client);
1733
+ this.bulkMessaging = new BulkMessagingResource(this.client);
1734
+ this.activities = new ActivitiesResource(this.client);
1735
+ this.tags = new TagsResource(this.client);
1427
1736
  }
1428
1737
  /**
1429
1738
  * Set the authentication token
@@ -1850,6 +2159,25 @@ function getRoleCapabilities(roleName) {
1850
2159
  }
1851
2160
  }
1852
2161
 
2162
+ // src/models/contracts.ts
2163
+ var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
2164
+ CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
2165
+ CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
2166
+ CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
2167
+ CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
2168
+ CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
2169
+ CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
2170
+ CancellationReason2["OTHER"] = "OTHER";
2171
+ return CancellationReason2;
2172
+ })(CancellationReason || {});
2173
+ var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
2174
+ SuspensionType2["VACATION"] = "vacation";
2175
+ SuspensionType2["MEDICAL"] = "medical";
2176
+ SuspensionType2["FINANCIAL"] = "financial";
2177
+ SuspensionType2["OTHER"] = "other";
2178
+ return SuspensionType2;
2179
+ })(SuspensionType || {});
2180
+
1853
2181
  // src/models/onboarding.ts
1854
2182
  var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
1855
2183
  OnboardingStep2["ACCOUNT_CREATED"] = "account_created";
@@ -1859,6 +2187,6 @@ var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
1859
2187
  return OnboardingStep2;
1860
2188
  })(OnboardingStep || {});
1861
2189
 
1862
- export { AdminSubscriptionManagementResource, ApiClient, AssetCategory, AssetStatus, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, CACHE_TTL, CheckInsResource, ClientStatus, ClientsResource, CollaboratorStatus, CollaboratorsResource, CommentType, ContractAssetType, ContractStatus, ContractsResource, DATE_FORMATS, DashboardResource, EvaluationAssetCategory, EvaluationAssetStage, EvaluationStatus, EvaluationType, FILE_LIMITS, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, InvitationStatus, InvitationsResource, LeadStatus, MembershipPlansResource, NetworkError, NotFoundError, OnboardingResource, OnboardingStep, OrganizationsResource, PAGINATION_DEFAULTS, PERMISSIONS, PaymentFrequency, PaymentMethodsResource, PlanStatus, ProductsResource, PublicCatalogResource, ROLE_NAMES, ROLE_PERMISSIONS, RoleNames, RolesResource, SalesResource, SubscriptionPlansResource, SubscriptionStatus, SubscriptionsResource, SuppliersResource, UserType, UsersResource, ValidationError, WhatsAppResource, WhatsAppTemplatesResource, canAccessFeature, getRoleCapabilities, getRoleDescription, getRoleDisplayName, isAdminRole, isEncargadoRole };
2190
+ export { ActivitiesResource, AdminSubscriptionManagementResource, ApiClient, AssetCategory, AssetStatus, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, BulkMessagingResource, CACHE_TTL, CancellationReason, CheckInsResource, ClientStatus, ClientsResource, CollaboratorStatus, CollaboratorsResource, CommentType, ContractAssetType, ContractStatus, ContractsResource, DATE_FORMATS, DashboardResource, EvaluationAssetCategory, EvaluationAssetStage, EvaluationStatus, EvaluationType, FILE_LIMITS, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, InvitationStatus, InvitationsResource, LeadStatus, MembershipPlansResource, NetworkError, NotFoundError, OnboardingResource, OnboardingStep, OrganizationsResource, PAGINATION_DEFAULTS, PERMISSIONS, PaymentFrequency, PaymentMethodsResource, PlanStatus, ProductsResource, PublicCatalogResource, ROLE_NAMES, ROLE_PERMISSIONS, RoleNames, RolesResource, SalesResource, SubscriptionPlansResource, SubscriptionStatus, SubscriptionsResource, SuppliersResource, SuspensionType, TagsResource, UserType, UsersResource, ValidationError, WhatsAppResource, WhatsAppTemplatesResource, canAccessFeature, getRoleCapabilities, getRoleDescription, getRoleDisplayName, isAdminRole, isEncargadoRole };
1863
2191
  //# sourceMappingURL=index.mjs.map
1864
2192
  //# sourceMappingURL=index.mjs.map