@gymspace/sdk 1.7.5 → 1.8.1
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/.tsbuildinfo +1 -0
- package/dist/index.d.mts +350 -13
- package/dist/index.d.ts +350 -13
- package/dist/index.js +289 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +285 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
- package/src/client.ts +5 -6
- package/src/errors.ts +3 -5
- package/src/models/activities.ts +12 -3
- package/src/models/bulk-messaging.ts +26 -7
- package/src/models/contracts.ts +18 -0
- package/src/models/credits.ts +79 -0
- package/src/models/index.ts +3 -0
- package/src/models/membership-plans.ts +4 -0
- package/src/models/pricing-packages.ts +65 -0
- package/src/models/promo-codes.ts +97 -0
- package/src/resources/credits.ts +203 -0
- package/src/resources/index.ts +3 -0
- package/src/resources/pricing-packages.ts +72 -0
- package/src/resources/promo-codes.ts +76 -0
- package/src/sdk.ts +9 -0
package/dist/index.mjs
CHANGED
|
@@ -2148,6 +2148,231 @@ var MessagesResource = class extends BaseResource {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
};
|
|
2150
2150
|
|
|
2151
|
+
// src/resources/credits.ts
|
|
2152
|
+
var CreditsResource = class extends BaseResource {
|
|
2153
|
+
constructor() {
|
|
2154
|
+
super(...arguments);
|
|
2155
|
+
// Admin endpoints for specific organization
|
|
2156
|
+
this.adminOrgCreditsPath = (organizationId) => `admin/organizations/${organizationId}/credits`;
|
|
2157
|
+
// Organization endpoints (non-admin)
|
|
2158
|
+
this.orgCreditsPath = (organizationId) => `organizations/${organizationId}/credits`;
|
|
2159
|
+
// Global admin endpoints
|
|
2160
|
+
this.adminCreditsPath = "admin/credits";
|
|
2161
|
+
}
|
|
2162
|
+
/**
|
|
2163
|
+
* Get credit account for own organization (non-admin)
|
|
2164
|
+
*/
|
|
2165
|
+
async getCreditAccount(organizationId, options) {
|
|
2166
|
+
return this.client.get(this.orgCreditsPath(organizationId), void 0, options);
|
|
2167
|
+
}
|
|
2168
|
+
/**
|
|
2169
|
+
* Get credit account for a specific organization (admin only)
|
|
2170
|
+
*/
|
|
2171
|
+
async getAdminCreditAccount(organizationId, options) {
|
|
2172
|
+
return this.client.get(
|
|
2173
|
+
this.adminOrgCreditsPath(organizationId),
|
|
2174
|
+
void 0,
|
|
2175
|
+
options
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2178
|
+
/**
|
|
2179
|
+
* Get credit transaction history for own organization (non-admin)
|
|
2180
|
+
*/
|
|
2181
|
+
async getCreditTransactions(organizationId, limit, options) {
|
|
2182
|
+
const params = limit ? { limit } : void 0;
|
|
2183
|
+
return this.client.get(
|
|
2184
|
+
`${this.orgCreditsPath(organizationId)}/transactions`,
|
|
2185
|
+
params,
|
|
2186
|
+
options
|
|
2187
|
+
);
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Get credit transaction history for a specific organization (admin only)
|
|
2191
|
+
*/
|
|
2192
|
+
async getAdminCreditTransactions(organizationId, limit, options) {
|
|
2193
|
+
const params = limit ? { limit } : void 0;
|
|
2194
|
+
return this.client.get(
|
|
2195
|
+
`${this.adminOrgCreditsPath(organizationId)}/transactions`,
|
|
2196
|
+
params,
|
|
2197
|
+
options
|
|
2198
|
+
);
|
|
2199
|
+
}
|
|
2200
|
+
/**
|
|
2201
|
+
* Adjust credits for a specific organization (admin only)
|
|
2202
|
+
*/
|
|
2203
|
+
async adjustCredits(organizationId, adjustment, options) {
|
|
2204
|
+
return this.client.post(
|
|
2205
|
+
`${this.adminOrgCreditsPath(organizationId)}/adjust`,
|
|
2206
|
+
adjustment,
|
|
2207
|
+
options
|
|
2208
|
+
);
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Get credit usage report for own organization (non-admin)
|
|
2212
|
+
*/
|
|
2213
|
+
async getUsageReport(organizationId, query, options) {
|
|
2214
|
+
return this.client.get(
|
|
2215
|
+
`${this.orgCreditsPath(organizationId)}/usage-report`,
|
|
2216
|
+
query,
|
|
2217
|
+
options
|
|
2218
|
+
);
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* Get credit usage report for a specific organization (admin only)
|
|
2222
|
+
*/
|
|
2223
|
+
async getAdminUsageReport(organizationId, query, options) {
|
|
2224
|
+
return this.client.get(
|
|
2225
|
+
`${this.adminOrgCreditsPath(organizationId)}/usage-report`,
|
|
2226
|
+
query,
|
|
2227
|
+
options
|
|
2228
|
+
);
|
|
2229
|
+
}
|
|
2230
|
+
/**
|
|
2231
|
+
* Get all organizations with credit accounts (Super Admin only)
|
|
2232
|
+
*/
|
|
2233
|
+
async getAllCreditAccounts(limit, offset, options) {
|
|
2234
|
+
const params = {
|
|
2235
|
+
limit: limit || 50,
|
|
2236
|
+
offset: offset || 0
|
|
2237
|
+
};
|
|
2238
|
+
return this.client.get(
|
|
2239
|
+
`${this.adminCreditsPath}/organizations`,
|
|
2240
|
+
params,
|
|
2241
|
+
options
|
|
2242
|
+
);
|
|
2243
|
+
}
|
|
2244
|
+
/**
|
|
2245
|
+
* Get credit stats for current organization (existing endpoint)
|
|
2246
|
+
*/
|
|
2247
|
+
async getCreditStats(organizationId, options) {
|
|
2248
|
+
return this.client.get(
|
|
2249
|
+
`whatsapp/bulk-messaging/ai-usage-stats`,
|
|
2250
|
+
void 0,
|
|
2251
|
+
options
|
|
2252
|
+
);
|
|
2253
|
+
}
|
|
2254
|
+
/**
|
|
2255
|
+
* Search credit transactions with filters
|
|
2256
|
+
*/
|
|
2257
|
+
async searchTransactions(organizationId, filters, limit, options) {
|
|
2258
|
+
const params = {
|
|
2259
|
+
...filters,
|
|
2260
|
+
limit: limit || 50
|
|
2261
|
+
};
|
|
2262
|
+
return this.client.get(
|
|
2263
|
+
`${this.orgCreditsPath(organizationId)}/transactions/search`,
|
|
2264
|
+
params,
|
|
2265
|
+
options
|
|
2266
|
+
);
|
|
2267
|
+
}
|
|
2268
|
+
/**
|
|
2269
|
+
* Get credit summary for multiple organizations
|
|
2270
|
+
*/
|
|
2271
|
+
async getOrganizationsCreditSummary(organizationIds, options) {
|
|
2272
|
+
return this.client.post(`${this.adminCreditsPath}/summary`, { organizationIds }, options);
|
|
2273
|
+
}
|
|
2274
|
+
};
|
|
2275
|
+
|
|
2276
|
+
// src/resources/pricing-packages.ts
|
|
2277
|
+
var PricingPackagesResource = class extends BaseResource {
|
|
2278
|
+
constructor() {
|
|
2279
|
+
super(...arguments);
|
|
2280
|
+
this.basePath = "pricing-packages";
|
|
2281
|
+
}
|
|
2282
|
+
// CREATE - POST /pricing-packages/plans/:planId/packages
|
|
2283
|
+
async createPricingPackage(planId, data, options) {
|
|
2284
|
+
return this.client.post(
|
|
2285
|
+
`${this.basePath}/plans/${planId}/packages`,
|
|
2286
|
+
data,
|
|
2287
|
+
options
|
|
2288
|
+
);
|
|
2289
|
+
}
|
|
2290
|
+
// GET ONE - GET /pricing-packages/:id
|
|
2291
|
+
async getPricingPackage(id, options) {
|
|
2292
|
+
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
2293
|
+
}
|
|
2294
|
+
// UPDATE - PUT /pricing-packages/:id
|
|
2295
|
+
async updatePricingPackage(id, data, options) {
|
|
2296
|
+
return this.client.put(`${this.basePath}/${id}`, data, options);
|
|
2297
|
+
}
|
|
2298
|
+
// SEARCH - GET /pricing-packages
|
|
2299
|
+
async searchPricingPackages(params, options) {
|
|
2300
|
+
return this.paginate(
|
|
2301
|
+
this.basePath,
|
|
2302
|
+
{
|
|
2303
|
+
page: params?.page || 1,
|
|
2304
|
+
limit: params?.limit || 20,
|
|
2305
|
+
...params
|
|
2306
|
+
},
|
|
2307
|
+
options
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
// GET BY PLAN - GET /pricing-packages/plans/:planId/packages
|
|
2311
|
+
async getPricingPackagesByPlan(planId, options) {
|
|
2312
|
+
return this.client.get(
|
|
2313
|
+
`${this.basePath}/plans/${planId}/packages`,
|
|
2314
|
+
void 0,
|
|
2315
|
+
options
|
|
2316
|
+
);
|
|
2317
|
+
}
|
|
2318
|
+
// DELETE - DELETE /pricing-packages/:id
|
|
2319
|
+
async deletePricingPackage(id, options) {
|
|
2320
|
+
return this.client.delete(`${this.basePath}/${id}`, options);
|
|
2321
|
+
}
|
|
2322
|
+
};
|
|
2323
|
+
|
|
2324
|
+
// src/resources/promo-codes.ts
|
|
2325
|
+
var PromoCodesResource = class extends BaseResource {
|
|
2326
|
+
constructor() {
|
|
2327
|
+
super(...arguments);
|
|
2328
|
+
this.basePath = "promo-codes";
|
|
2329
|
+
}
|
|
2330
|
+
// CREATE - POST /promo-codes
|
|
2331
|
+
async createPromoCode(data, options) {
|
|
2332
|
+
return this.client.post(this.basePath, data, options);
|
|
2333
|
+
}
|
|
2334
|
+
// VALIDATE - POST /promo-codes/validate
|
|
2335
|
+
async validatePromoCode(data, options) {
|
|
2336
|
+
return this.client.post(
|
|
2337
|
+
`${this.basePath}/validate`,
|
|
2338
|
+
data,
|
|
2339
|
+
options
|
|
2340
|
+
);
|
|
2341
|
+
}
|
|
2342
|
+
// SEARCH - GET /promo-codes
|
|
2343
|
+
async searchPromoCodes(params, options) {
|
|
2344
|
+
return this.paginate(
|
|
2345
|
+
this.basePath,
|
|
2346
|
+
{
|
|
2347
|
+
page: params?.page || 1,
|
|
2348
|
+
limit: params?.limit || 20,
|
|
2349
|
+
...params
|
|
2350
|
+
},
|
|
2351
|
+
options
|
|
2352
|
+
);
|
|
2353
|
+
}
|
|
2354
|
+
// GET ANALYTICS - GET /promo-codes/analytics/:id
|
|
2355
|
+
async getPromoCodeAnalytics(id, options) {
|
|
2356
|
+
return this.client.get(
|
|
2357
|
+
`${this.basePath}/analytics/${id}`,
|
|
2358
|
+
void 0,
|
|
2359
|
+
options
|
|
2360
|
+
);
|
|
2361
|
+
}
|
|
2362
|
+
// GET ONE - GET /promo-codes/:id
|
|
2363
|
+
async getPromoCode(id, options) {
|
|
2364
|
+
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
2365
|
+
}
|
|
2366
|
+
// UPDATE - PUT /promo-codes/:id
|
|
2367
|
+
async updatePromoCode(id, data, options) {
|
|
2368
|
+
return this.client.put(`${this.basePath}/${id}`, data, options);
|
|
2369
|
+
}
|
|
2370
|
+
// DELETE - DELETE /promo-codes/:id
|
|
2371
|
+
async deletePromoCode(id, options) {
|
|
2372
|
+
return this.client.delete(`${this.basePath}/${id}`, options);
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2151
2376
|
// src/sdk.ts
|
|
2152
2377
|
var GymSpaceSdk = class {
|
|
2153
2378
|
constructor(config) {
|
|
@@ -2188,6 +2413,9 @@ var GymSpaceSdk = class {
|
|
|
2188
2413
|
this.commissionReports = new CommissionReportsResource(this.client);
|
|
2189
2414
|
this.commissionPromotions = new CommissionPromotionsResource(this.client);
|
|
2190
2415
|
this.messages = new MessagesResource(this.client);
|
|
2416
|
+
this.credits = new CreditsResource(this.client);
|
|
2417
|
+
this.pricingPackages = new PricingPackagesResource(this.client);
|
|
2418
|
+
this.promoCodes = new PromoCodesResource(this.client);
|
|
2191
2419
|
}
|
|
2192
2420
|
/**
|
|
2193
2421
|
* Set the authentication token
|
|
@@ -2255,7 +2483,8 @@ var TemplateCode = {
|
|
|
2255
2483
|
PAYMENT_REMINDER: "PAYMENT_REMINDER",
|
|
2256
2484
|
BIRTHDAY: "BIRTHDAY",
|
|
2257
2485
|
PAYMENT_RECEIPT: "PAYMENT_RECEIPT",
|
|
2258
|
-
SHARE_CATALOG: "SHARE_CATALOG"
|
|
2486
|
+
SHARE_CATALOG: "SHARE_CATALOG",
|
|
2487
|
+
SALE_PAYMENT_REMINDER: "SALE_PAYMENT_REMINDER"
|
|
2259
2488
|
};
|
|
2260
2489
|
var TemplateType = {
|
|
2261
2490
|
STATIC: "STATIC",
|
|
@@ -2269,7 +2498,8 @@ var TEMPLATE_CODES = {
|
|
|
2269
2498
|
PAYMENT_REMINDER: TemplateCode.PAYMENT_REMINDER,
|
|
2270
2499
|
BIRTHDAY: TemplateCode.BIRTHDAY,
|
|
2271
2500
|
PAYMENT_RECEIPT: TemplateCode.PAYMENT_RECEIPT,
|
|
2272
|
-
SHARE_CATALOG: TemplateCode.SHARE_CATALOG
|
|
2501
|
+
SHARE_CATALOG: TemplateCode.SHARE_CATALOG,
|
|
2502
|
+
SALE_PAYMENT_REMINDER: TemplateCode.SALE_PAYMENT_REMINDER
|
|
2273
2503
|
};
|
|
2274
2504
|
var WHATSAPP_TEMPLATE_EVENTS = {
|
|
2275
2505
|
SEND_TEMPLATE: "whatsapp/template.send",
|
|
@@ -2367,7 +2597,9 @@ var TEMPLATE_METADATA = {
|
|
|
2367
2597
|
"clientName",
|
|
2368
2598
|
"items",
|
|
2369
2599
|
"amount",
|
|
2370
|
-
"paymentMethod"
|
|
2600
|
+
"paymentMethod",
|
|
2601
|
+
"saleItems",
|
|
2602
|
+
"currency"
|
|
2371
2603
|
],
|
|
2372
2604
|
exampleValues: {
|
|
2373
2605
|
gymName: "GymSpace",
|
|
@@ -2376,7 +2608,12 @@ var TEMPLATE_METADATA = {
|
|
|
2376
2608
|
clientName: "Juan P\xE9rez",
|
|
2377
2609
|
items: "\u2022 Prote\xEDna x2 = Q100.00\n\u2022 Creatina x1 = Q50.00",
|
|
2378
2610
|
amount: "Q150.00",
|
|
2379
|
-
paymentMethod: "Efectivo"
|
|
2611
|
+
paymentMethod: "Efectivo",
|
|
2612
|
+
saleItems: [
|
|
2613
|
+
{ product: { name: "Prote\xEDna" }, quantity: 2, total: "100.00" },
|
|
2614
|
+
{ product: { name: "Creatina" }, quantity: 1, total: "50.00" }
|
|
2615
|
+
],
|
|
2616
|
+
currency: "Q"
|
|
2380
2617
|
}
|
|
2381
2618
|
},
|
|
2382
2619
|
[TemplateCode.SHARE_CATALOG]: {
|
|
@@ -2390,6 +2627,35 @@ var TEMPLATE_METADATA = {
|
|
|
2390
2627
|
gymName: "GymSpace",
|
|
2391
2628
|
urlCatalog: "https://gymspace.app/catalog/gym-123"
|
|
2392
2629
|
}
|
|
2630
|
+
},
|
|
2631
|
+
[TemplateCode.SALE_PAYMENT_REMINDER]: {
|
|
2632
|
+
code: TemplateCode.SALE_PAYMENT_REMINDER,
|
|
2633
|
+
title: "Recordatorio de Pago de Venta",
|
|
2634
|
+
description: "Recordatorio para ventas con pago pendiente",
|
|
2635
|
+
icon: "AlertCircle",
|
|
2636
|
+
variables: [
|
|
2637
|
+
"clientName",
|
|
2638
|
+
"saleNumber",
|
|
2639
|
+
"total",
|
|
2640
|
+
"saleDate",
|
|
2641
|
+
"daysOverdue",
|
|
2642
|
+
"items",
|
|
2643
|
+
"saleItems",
|
|
2644
|
+
"currency"
|
|
2645
|
+
],
|
|
2646
|
+
exampleValues: {
|
|
2647
|
+
clientName: "Manuel Trainer",
|
|
2648
|
+
saleNumber: "#202511130003",
|
|
2649
|
+
total: "S/ 205.00",
|
|
2650
|
+
saleDate: "13/11/2025",
|
|
2651
|
+
daysOverdue: "3",
|
|
2652
|
+
items: "\u2022 BCAA x2\n\u2022 Pre-Entreno x1",
|
|
2653
|
+
saleItems: [
|
|
2654
|
+
{ product: { name: "BCAA" }, quantity: 2 },
|
|
2655
|
+
{ product: { name: "Pre-Entreno" }, quantity: 1 }
|
|
2656
|
+
],
|
|
2657
|
+
currency: "S/ "
|
|
2658
|
+
}
|
|
2393
2659
|
}
|
|
2394
2660
|
};
|
|
2395
2661
|
var BULK_MESSAGE_VARIABLES = [
|
|
@@ -3154,6 +3420,20 @@ var LeadGender = /* @__PURE__ */ ((LeadGender2) => {
|
|
|
3154
3420
|
return LeadGender2;
|
|
3155
3421
|
})(LeadGender || {});
|
|
3156
3422
|
|
|
3157
|
-
|
|
3423
|
+
// src/models/credits.ts
|
|
3424
|
+
var FeatureType = /* @__PURE__ */ ((FeatureType2) => {
|
|
3425
|
+
FeatureType2["AI_GENERATION"] = "ai_generation";
|
|
3426
|
+
FeatureType2["BULK_WHATSAPP"] = "bulk_whatsapp";
|
|
3427
|
+
return FeatureType2;
|
|
3428
|
+
})(FeatureType || {});
|
|
3429
|
+
|
|
3430
|
+
// src/models/promo-codes.ts
|
|
3431
|
+
var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
|
|
3432
|
+
DiscountType2["PERCENTAGE"] = "PERCENTAGE";
|
|
3433
|
+
DiscountType2["FIXED_AMOUNT"] = "FIXED_AMOUNT";
|
|
3434
|
+
return DiscountType2;
|
|
3435
|
+
})(DiscountType || {});
|
|
3436
|
+
|
|
3437
|
+
export { ACTIVITY_EVENTS, ACTIVITY_MESSAGE_VARIABLES, ActivitiesResource, AdminCatalogResource, AdminSubscriptionManagementResource, ApiClient, AssetCategory, AssetStatus, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, BULK_MESSAGE_VARIABLES, BULK_MESSAGE_VARIABLE_CATEGORIES, BULK_MESSAGING_EVENTS, BulkMessagingResource, CACHE_TTL, CancellationReason, CheckInsResource, ClientStatus, ClientsResource, CollaboratorStatus, CollaboratorsResource, CommissionCalculationsResource, CommissionChangeType, CommissionConfigResource, CommissionEntityType, CommissionPromotionsResource, CommissionReportsResource, CommissionRuleType, CommissionRulesResource, CommissionStatus, ContractAssetType, ContractStatus, ContractsResource, CreditsResource, DATE_FORMATS, DashboardResource, DiscountType, FILE_LIMITS, FeatureType, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, InvitationStatus, InvitationsResource, LeadGender, MembershipPlansResource, MessageStatus, MessagesResource, NetworkError, NotFoundError, OnboardingCacheStatus, OnboardingResource, OnboardingStep, OrganizationsResource, PAGINATION_DEFAULTS, PERMISSIONS, PaymentFrequency, PaymentMethodsResource, PlanStatus, PlanType, PricingPackagesResource, ProductsResource, PromoCodesResource, PublicCatalogResource, ROLE_NAMES, ROLE_PERMISSIONS, RoleNames, RolesResource, SalesResource, SubscriptionPlansResource, SubscriptionStatus, SubscriptionsResource, SuppliersResource, SuspensionType, TEMPLATE_CODES, TEMPLATE_METADATA, TagsResource, TemplateCode, TemplateType, UserType, UsersResource, VARIABLE_CONTEXT_MAP, ValidationError, WHATSAPP_EVENTS, WHATSAPP_TEMPLATE_EVENTS, WhatsAppResource, WhatsAppTemplatesResource, activityNotificationGenerationRequestSchema, activityNotificationSchema, aiGeneratedTemplateSchema, bulkMessageGenerationRequestSchema, bulkMessageSchema, canAccessFeature, getRoleCapabilities, getRoleDescription, getRoleDisplayName, getVariablesByContext, isAdminRole, isEncargadoRole, isValidPeruvianPhone, normalizePhoneForEvolution, templateGenerationRequestSchema, validateVariablesInContext };
|
|
3158
3438
|
//# sourceMappingURL=index.mjs.map
|
|
3159
3439
|
//# sourceMappingURL=index.mjs.map
|