@gymspace/sdk 1.5.1 → 1.6.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.js CHANGED
@@ -482,6 +482,22 @@ var GymsResource = class extends BaseResource {
482
482
  async updateContractSettings(data, options) {
483
483
  return this.client.patch(`${this.basePath}/current/contract-settings`, data, options);
484
484
  }
485
+ /**
486
+ * Soft delete a gym
487
+ * Cannot delete gym with active contracts or collaborators
488
+ * @param id Gym ID
489
+ * @param options Request options
490
+ * @returns Success response
491
+ *
492
+ * @example
493
+ * ```typescript
494
+ * const result = await sdk.gyms.deleteGym('gym-id');
495
+ * console.log(result.success); // true
496
+ * ```
497
+ */
498
+ async deleteGym(id, options) {
499
+ return this.client.delete(`${this.basePath}/${id}`, options);
500
+ }
485
501
  };
486
502
 
487
503
  // src/resources/collaborators.ts
@@ -829,6 +845,9 @@ var InvitationsResource = class extends BaseResource {
829
845
  async validateByCode(data, options) {
830
846
  return this.client.post(`${this.basePath}/validate-by-code`, data, options);
831
847
  }
848
+ async validateByToken(data, options) {
849
+ return this.client.post(`${this.basePath}/validate-by-token`, data, options);
850
+ }
832
851
  async acceptInvitation(data, options) {
833
852
  return this.client.post(`${this.basePath}/accept`, data, options);
834
853
  }
@@ -2100,6 +2119,27 @@ var CommissionPromotionsResource = class extends BaseResource {
2100
2119
  }
2101
2120
  };
2102
2121
 
2122
+ // src/resources/messages.ts
2123
+ var MessagesResource = class extends BaseResource {
2124
+ constructor() {
2125
+ super(...arguments);
2126
+ this.basePath = "messages";
2127
+ }
2128
+ async getMessages(params, options) {
2129
+ const response = await this.client.get(this.basePath, params, options);
2130
+ return response.data;
2131
+ }
2132
+ async getMessage(id, options) {
2133
+ return this.client.get(`${this.basePath}/${id}`, void 0, options);
2134
+ }
2135
+ async retryMessage(id, options) {
2136
+ return this.client.post(`${this.basePath}/${id}/retry`, void 0, options);
2137
+ }
2138
+ async cancelMessage(id, options) {
2139
+ return this.client.post(`${this.basePath}/${id}/cancel`, void 0, options);
2140
+ }
2141
+ };
2142
+
2103
2143
  // src/sdk.ts
2104
2144
  var GymSpaceSdk = class {
2105
2145
  constructor(config) {
@@ -2139,6 +2179,7 @@ var GymSpaceSdk = class {
2139
2179
  this.commissionCalculations = new CommissionCalculationsResource(this.client);
2140
2180
  this.commissionReports = new CommissionReportsResource(this.client);
2141
2181
  this.commissionPromotions = new CommissionPromotionsResource(this.client);
2182
+ this.messages = new MessagesResource(this.client);
2142
2183
  }
2143
2184
  /**
2144
2185
  * Set the authentication token
@@ -2570,16 +2611,24 @@ function getVariablesByContext(context) {
2570
2611
  return VARIABLE_CONTEXT_MAP[context] || BULK_MESSAGE_VARIABLES;
2571
2612
  }
2572
2613
  function validateVariablesInContext(message, context) {
2573
- const variablePattern = /{{(\w+)}}/g;
2574
- const matches = message.matchAll(variablePattern);
2614
+ const doubleBracePattern = /\{\{(\w+)\}\}/g;
2615
+ const singleBracePattern = /\{(\w+)\}/g;
2616
+ const doubleBraceMatches = message.matchAll(doubleBracePattern);
2617
+ const singleBraceMatches = message.matchAll(singleBracePattern);
2575
2618
  const invalidVariables = [];
2576
2619
  const validVariables = getVariablesByContext(context).map((v) => v.name);
2577
- for (const match of matches) {
2620
+ for (const match of doubleBraceMatches) {
2578
2621
  const variableName = match[1];
2579
2622
  if (!validVariables.includes(variableName)) {
2580
2623
  invalidVariables.push(variableName);
2581
2624
  }
2582
2625
  }
2626
+ for (const match of singleBraceMatches) {
2627
+ const variableName = match[1];
2628
+ if (!validVariables.includes(variableName) && !invalidVariables.includes(variableName)) {
2629
+ invalidVariables.push(variableName);
2630
+ }
2631
+ }
2583
2632
  return {
2584
2633
  valid: invalidVariables.length === 0,
2585
2634
  invalidVariables
@@ -3129,6 +3178,7 @@ exports.InvitationStatus = InvitationStatus;
3129
3178
  exports.InvitationsResource = InvitationsResource;
3130
3179
  exports.LeadGender = LeadGender;
3131
3180
  exports.MembershipPlansResource = MembershipPlansResource;
3181
+ exports.MessagesResource = MessagesResource;
3132
3182
  exports.NetworkError = NetworkError;
3133
3183
  exports.NotFoundError = NotFoundError;
3134
3184
  exports.OnboardingCacheStatus = OnboardingCacheStatus;