@gymspace/sdk 1.7.4 → 1.8.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/.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.js
CHANGED
|
@@ -2154,6 +2154,231 @@ var MessagesResource = class extends BaseResource {
|
|
|
2154
2154
|
}
|
|
2155
2155
|
};
|
|
2156
2156
|
|
|
2157
|
+
// src/resources/credits.ts
|
|
2158
|
+
var CreditsResource = class extends BaseResource {
|
|
2159
|
+
constructor() {
|
|
2160
|
+
super(...arguments);
|
|
2161
|
+
// Admin endpoints for specific organization
|
|
2162
|
+
this.adminOrgCreditsPath = (organizationId) => `admin/organizations/${organizationId}/credits`;
|
|
2163
|
+
// Organization endpoints (non-admin)
|
|
2164
|
+
this.orgCreditsPath = (organizationId) => `organizations/${organizationId}/credits`;
|
|
2165
|
+
// Global admin endpoints
|
|
2166
|
+
this.adminCreditsPath = "admin/credits";
|
|
2167
|
+
}
|
|
2168
|
+
/**
|
|
2169
|
+
* Get credit account for own organization (non-admin)
|
|
2170
|
+
*/
|
|
2171
|
+
async getCreditAccount(organizationId, options) {
|
|
2172
|
+
return this.client.get(this.orgCreditsPath(organizationId), void 0, options);
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Get credit account for a specific organization (admin only)
|
|
2176
|
+
*/
|
|
2177
|
+
async getAdminCreditAccount(organizationId, options) {
|
|
2178
|
+
return this.client.get(
|
|
2179
|
+
this.adminOrgCreditsPath(organizationId),
|
|
2180
|
+
void 0,
|
|
2181
|
+
options
|
|
2182
|
+
);
|
|
2183
|
+
}
|
|
2184
|
+
/**
|
|
2185
|
+
* Get credit transaction history for own organization (non-admin)
|
|
2186
|
+
*/
|
|
2187
|
+
async getCreditTransactions(organizationId, limit, options) {
|
|
2188
|
+
const params = limit ? { limit } : void 0;
|
|
2189
|
+
return this.client.get(
|
|
2190
|
+
`${this.orgCreditsPath(organizationId)}/transactions`,
|
|
2191
|
+
params,
|
|
2192
|
+
options
|
|
2193
|
+
);
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Get credit transaction history for a specific organization (admin only)
|
|
2197
|
+
*/
|
|
2198
|
+
async getAdminCreditTransactions(organizationId, limit, options) {
|
|
2199
|
+
const params = limit ? { limit } : void 0;
|
|
2200
|
+
return this.client.get(
|
|
2201
|
+
`${this.adminOrgCreditsPath(organizationId)}/transactions`,
|
|
2202
|
+
params,
|
|
2203
|
+
options
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* Adjust credits for a specific organization (admin only)
|
|
2208
|
+
*/
|
|
2209
|
+
async adjustCredits(organizationId, adjustment, options) {
|
|
2210
|
+
return this.client.post(
|
|
2211
|
+
`${this.adminOrgCreditsPath(organizationId)}/adjust`,
|
|
2212
|
+
adjustment,
|
|
2213
|
+
options
|
|
2214
|
+
);
|
|
2215
|
+
}
|
|
2216
|
+
/**
|
|
2217
|
+
* Get credit usage report for own organization (non-admin)
|
|
2218
|
+
*/
|
|
2219
|
+
async getUsageReport(organizationId, query, options) {
|
|
2220
|
+
return this.client.get(
|
|
2221
|
+
`${this.orgCreditsPath(organizationId)}/usage-report`,
|
|
2222
|
+
query,
|
|
2223
|
+
options
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Get credit usage report for a specific organization (admin only)
|
|
2228
|
+
*/
|
|
2229
|
+
async getAdminUsageReport(organizationId, query, options) {
|
|
2230
|
+
return this.client.get(
|
|
2231
|
+
`${this.adminOrgCreditsPath(organizationId)}/usage-report`,
|
|
2232
|
+
query,
|
|
2233
|
+
options
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Get all organizations with credit accounts (Super Admin only)
|
|
2238
|
+
*/
|
|
2239
|
+
async getAllCreditAccounts(limit, offset, options) {
|
|
2240
|
+
const params = {
|
|
2241
|
+
limit: limit || 50,
|
|
2242
|
+
offset: offset || 0
|
|
2243
|
+
};
|
|
2244
|
+
return this.client.get(
|
|
2245
|
+
`${this.adminCreditsPath}/organizations`,
|
|
2246
|
+
params,
|
|
2247
|
+
options
|
|
2248
|
+
);
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Get credit stats for current organization (existing endpoint)
|
|
2252
|
+
*/
|
|
2253
|
+
async getCreditStats(organizationId, options) {
|
|
2254
|
+
return this.client.get(
|
|
2255
|
+
`whatsapp/bulk-messaging/ai-usage-stats`,
|
|
2256
|
+
void 0,
|
|
2257
|
+
options
|
|
2258
|
+
);
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Search credit transactions with filters
|
|
2262
|
+
*/
|
|
2263
|
+
async searchTransactions(organizationId, filters, limit, options) {
|
|
2264
|
+
const params = {
|
|
2265
|
+
...filters,
|
|
2266
|
+
limit: limit || 50
|
|
2267
|
+
};
|
|
2268
|
+
return this.client.get(
|
|
2269
|
+
`${this.orgCreditsPath(organizationId)}/transactions/search`,
|
|
2270
|
+
params,
|
|
2271
|
+
options
|
|
2272
|
+
);
|
|
2273
|
+
}
|
|
2274
|
+
/**
|
|
2275
|
+
* Get credit summary for multiple organizations
|
|
2276
|
+
*/
|
|
2277
|
+
async getOrganizationsCreditSummary(organizationIds, options) {
|
|
2278
|
+
return this.client.post(`${this.adminCreditsPath}/summary`, { organizationIds }, options);
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
|
|
2282
|
+
// src/resources/pricing-packages.ts
|
|
2283
|
+
var PricingPackagesResource = class extends BaseResource {
|
|
2284
|
+
constructor() {
|
|
2285
|
+
super(...arguments);
|
|
2286
|
+
this.basePath = "pricing-packages";
|
|
2287
|
+
}
|
|
2288
|
+
// CREATE - POST /pricing-packages/plans/:planId/packages
|
|
2289
|
+
async createPricingPackage(planId, data, options) {
|
|
2290
|
+
return this.client.post(
|
|
2291
|
+
`${this.basePath}/plans/${planId}/packages`,
|
|
2292
|
+
data,
|
|
2293
|
+
options
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
// GET ONE - GET /pricing-packages/:id
|
|
2297
|
+
async getPricingPackage(id, options) {
|
|
2298
|
+
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
2299
|
+
}
|
|
2300
|
+
// UPDATE - PUT /pricing-packages/:id
|
|
2301
|
+
async updatePricingPackage(id, data, options) {
|
|
2302
|
+
return this.client.put(`${this.basePath}/${id}`, data, options);
|
|
2303
|
+
}
|
|
2304
|
+
// SEARCH - GET /pricing-packages
|
|
2305
|
+
async searchPricingPackages(params, options) {
|
|
2306
|
+
return this.paginate(
|
|
2307
|
+
this.basePath,
|
|
2308
|
+
{
|
|
2309
|
+
page: params?.page || 1,
|
|
2310
|
+
limit: params?.limit || 20,
|
|
2311
|
+
...params
|
|
2312
|
+
},
|
|
2313
|
+
options
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2316
|
+
// GET BY PLAN - GET /pricing-packages/plans/:planId/packages
|
|
2317
|
+
async getPricingPackagesByPlan(planId, options) {
|
|
2318
|
+
return this.client.get(
|
|
2319
|
+
`${this.basePath}/plans/${planId}/packages`,
|
|
2320
|
+
void 0,
|
|
2321
|
+
options
|
|
2322
|
+
);
|
|
2323
|
+
}
|
|
2324
|
+
// DELETE - DELETE /pricing-packages/:id
|
|
2325
|
+
async deletePricingPackage(id, options) {
|
|
2326
|
+
return this.client.delete(`${this.basePath}/${id}`, options);
|
|
2327
|
+
}
|
|
2328
|
+
};
|
|
2329
|
+
|
|
2330
|
+
// src/resources/promo-codes.ts
|
|
2331
|
+
var PromoCodesResource = class extends BaseResource {
|
|
2332
|
+
constructor() {
|
|
2333
|
+
super(...arguments);
|
|
2334
|
+
this.basePath = "promo-codes";
|
|
2335
|
+
}
|
|
2336
|
+
// CREATE - POST /promo-codes
|
|
2337
|
+
async createPromoCode(data, options) {
|
|
2338
|
+
return this.client.post(this.basePath, data, options);
|
|
2339
|
+
}
|
|
2340
|
+
// VALIDATE - POST /promo-codes/validate
|
|
2341
|
+
async validatePromoCode(data, options) {
|
|
2342
|
+
return this.client.post(
|
|
2343
|
+
`${this.basePath}/validate`,
|
|
2344
|
+
data,
|
|
2345
|
+
options
|
|
2346
|
+
);
|
|
2347
|
+
}
|
|
2348
|
+
// SEARCH - GET /promo-codes
|
|
2349
|
+
async searchPromoCodes(params, options) {
|
|
2350
|
+
return this.paginate(
|
|
2351
|
+
this.basePath,
|
|
2352
|
+
{
|
|
2353
|
+
page: params?.page || 1,
|
|
2354
|
+
limit: params?.limit || 20,
|
|
2355
|
+
...params
|
|
2356
|
+
},
|
|
2357
|
+
options
|
|
2358
|
+
);
|
|
2359
|
+
}
|
|
2360
|
+
// GET ANALYTICS - GET /promo-codes/analytics/:id
|
|
2361
|
+
async getPromoCodeAnalytics(id, options) {
|
|
2362
|
+
return this.client.get(
|
|
2363
|
+
`${this.basePath}/analytics/${id}`,
|
|
2364
|
+
void 0,
|
|
2365
|
+
options
|
|
2366
|
+
);
|
|
2367
|
+
}
|
|
2368
|
+
// GET ONE - GET /promo-codes/:id
|
|
2369
|
+
async getPromoCode(id, options) {
|
|
2370
|
+
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
2371
|
+
}
|
|
2372
|
+
// UPDATE - PUT /promo-codes/:id
|
|
2373
|
+
async updatePromoCode(id, data, options) {
|
|
2374
|
+
return this.client.put(`${this.basePath}/${id}`, data, options);
|
|
2375
|
+
}
|
|
2376
|
+
// DELETE - DELETE /promo-codes/:id
|
|
2377
|
+
async deletePromoCode(id, options) {
|
|
2378
|
+
return this.client.delete(`${this.basePath}/${id}`, options);
|
|
2379
|
+
}
|
|
2380
|
+
};
|
|
2381
|
+
|
|
2157
2382
|
// src/sdk.ts
|
|
2158
2383
|
var GymSpaceSdk = class {
|
|
2159
2384
|
constructor(config) {
|
|
@@ -2194,6 +2419,9 @@ var GymSpaceSdk = class {
|
|
|
2194
2419
|
this.commissionReports = new CommissionReportsResource(this.client);
|
|
2195
2420
|
this.commissionPromotions = new CommissionPromotionsResource(this.client);
|
|
2196
2421
|
this.messages = new MessagesResource(this.client);
|
|
2422
|
+
this.credits = new CreditsResource(this.client);
|
|
2423
|
+
this.pricingPackages = new PricingPackagesResource(this.client);
|
|
2424
|
+
this.promoCodes = new PromoCodesResource(this.client);
|
|
2197
2425
|
}
|
|
2198
2426
|
/**
|
|
2199
2427
|
* Set the authentication token
|
|
@@ -2261,7 +2489,8 @@ var TemplateCode = {
|
|
|
2261
2489
|
PAYMENT_REMINDER: "PAYMENT_REMINDER",
|
|
2262
2490
|
BIRTHDAY: "BIRTHDAY",
|
|
2263
2491
|
PAYMENT_RECEIPT: "PAYMENT_RECEIPT",
|
|
2264
|
-
SHARE_CATALOG: "SHARE_CATALOG"
|
|
2492
|
+
SHARE_CATALOG: "SHARE_CATALOG",
|
|
2493
|
+
SALE_PAYMENT_REMINDER: "SALE_PAYMENT_REMINDER"
|
|
2265
2494
|
};
|
|
2266
2495
|
var TemplateType = {
|
|
2267
2496
|
STATIC: "STATIC",
|
|
@@ -2275,7 +2504,8 @@ var TEMPLATE_CODES = {
|
|
|
2275
2504
|
PAYMENT_REMINDER: TemplateCode.PAYMENT_REMINDER,
|
|
2276
2505
|
BIRTHDAY: TemplateCode.BIRTHDAY,
|
|
2277
2506
|
PAYMENT_RECEIPT: TemplateCode.PAYMENT_RECEIPT,
|
|
2278
|
-
SHARE_CATALOG: TemplateCode.SHARE_CATALOG
|
|
2507
|
+
SHARE_CATALOG: TemplateCode.SHARE_CATALOG,
|
|
2508
|
+
SALE_PAYMENT_REMINDER: TemplateCode.SALE_PAYMENT_REMINDER
|
|
2279
2509
|
};
|
|
2280
2510
|
var WHATSAPP_TEMPLATE_EVENTS = {
|
|
2281
2511
|
SEND_TEMPLATE: "whatsapp/template.send",
|
|
@@ -2373,7 +2603,9 @@ var TEMPLATE_METADATA = {
|
|
|
2373
2603
|
"clientName",
|
|
2374
2604
|
"items",
|
|
2375
2605
|
"amount",
|
|
2376
|
-
"paymentMethod"
|
|
2606
|
+
"paymentMethod",
|
|
2607
|
+
"saleItems",
|
|
2608
|
+
"currency"
|
|
2377
2609
|
],
|
|
2378
2610
|
exampleValues: {
|
|
2379
2611
|
gymName: "GymSpace",
|
|
@@ -2382,7 +2614,12 @@ var TEMPLATE_METADATA = {
|
|
|
2382
2614
|
clientName: "Juan P\xE9rez",
|
|
2383
2615
|
items: "\u2022 Prote\xEDna x2 = Q100.00\n\u2022 Creatina x1 = Q50.00",
|
|
2384
2616
|
amount: "Q150.00",
|
|
2385
|
-
paymentMethod: "Efectivo"
|
|
2617
|
+
paymentMethod: "Efectivo",
|
|
2618
|
+
saleItems: [
|
|
2619
|
+
{ product: { name: "Prote\xEDna" }, quantity: 2, total: "100.00" },
|
|
2620
|
+
{ product: { name: "Creatina" }, quantity: 1, total: "50.00" }
|
|
2621
|
+
],
|
|
2622
|
+
currency: "Q"
|
|
2386
2623
|
}
|
|
2387
2624
|
},
|
|
2388
2625
|
[TemplateCode.SHARE_CATALOG]: {
|
|
@@ -2396,6 +2633,35 @@ var TEMPLATE_METADATA = {
|
|
|
2396
2633
|
gymName: "GymSpace",
|
|
2397
2634
|
urlCatalog: "https://gymspace.app/catalog/gym-123"
|
|
2398
2635
|
}
|
|
2636
|
+
},
|
|
2637
|
+
[TemplateCode.SALE_PAYMENT_REMINDER]: {
|
|
2638
|
+
code: TemplateCode.SALE_PAYMENT_REMINDER,
|
|
2639
|
+
title: "Recordatorio de Pago de Venta",
|
|
2640
|
+
description: "Recordatorio para ventas con pago pendiente",
|
|
2641
|
+
icon: "AlertCircle",
|
|
2642
|
+
variables: [
|
|
2643
|
+
"clientName",
|
|
2644
|
+
"saleNumber",
|
|
2645
|
+
"total",
|
|
2646
|
+
"saleDate",
|
|
2647
|
+
"daysOverdue",
|
|
2648
|
+
"items",
|
|
2649
|
+
"saleItems",
|
|
2650
|
+
"currency"
|
|
2651
|
+
],
|
|
2652
|
+
exampleValues: {
|
|
2653
|
+
clientName: "Manuel Trainer",
|
|
2654
|
+
saleNumber: "#202511130003",
|
|
2655
|
+
total: "S/ 205.00",
|
|
2656
|
+
saleDate: "13/11/2025",
|
|
2657
|
+
daysOverdue: "3",
|
|
2658
|
+
items: "\u2022 BCAA x2\n\u2022 Pre-Entreno x1",
|
|
2659
|
+
saleItems: [
|
|
2660
|
+
{ product: { name: "BCAA" }, quantity: 2 },
|
|
2661
|
+
{ product: { name: "Pre-Entreno" }, quantity: 1 }
|
|
2662
|
+
],
|
|
2663
|
+
currency: "S/ "
|
|
2664
|
+
}
|
|
2399
2665
|
}
|
|
2400
2666
|
};
|
|
2401
2667
|
var BULK_MESSAGE_VARIABLES = [
|
|
@@ -3160,6 +3426,20 @@ var LeadGender = /* @__PURE__ */ ((LeadGender2) => {
|
|
|
3160
3426
|
return LeadGender2;
|
|
3161
3427
|
})(LeadGender || {});
|
|
3162
3428
|
|
|
3429
|
+
// src/models/credits.ts
|
|
3430
|
+
var FeatureType = /* @__PURE__ */ ((FeatureType2) => {
|
|
3431
|
+
FeatureType2["AI_GENERATION"] = "ai_generation";
|
|
3432
|
+
FeatureType2["BULK_WHATSAPP"] = "bulk_whatsapp";
|
|
3433
|
+
return FeatureType2;
|
|
3434
|
+
})(FeatureType || {});
|
|
3435
|
+
|
|
3436
|
+
// src/models/promo-codes.ts
|
|
3437
|
+
var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
|
|
3438
|
+
DiscountType2["PERCENTAGE"] = "PERCENTAGE";
|
|
3439
|
+
DiscountType2["FIXED_AMOUNT"] = "FIXED_AMOUNT";
|
|
3440
|
+
return DiscountType2;
|
|
3441
|
+
})(DiscountType || {});
|
|
3442
|
+
|
|
3163
3443
|
exports.ACTIVITY_EVENTS = ACTIVITY_EVENTS;
|
|
3164
3444
|
exports.ACTIVITY_MESSAGE_VARIABLES = ACTIVITY_MESSAGE_VARIABLES;
|
|
3165
3445
|
exports.ActivitiesResource = ActivitiesResource;
|
|
@@ -3195,9 +3475,12 @@ exports.CommissionStatus = CommissionStatus;
|
|
|
3195
3475
|
exports.ContractAssetType = ContractAssetType;
|
|
3196
3476
|
exports.ContractStatus = ContractStatus;
|
|
3197
3477
|
exports.ContractsResource = ContractsResource;
|
|
3478
|
+
exports.CreditsResource = CreditsResource;
|
|
3198
3479
|
exports.DATE_FORMATS = DATE_FORMATS;
|
|
3199
3480
|
exports.DashboardResource = DashboardResource;
|
|
3481
|
+
exports.DiscountType = DiscountType;
|
|
3200
3482
|
exports.FILE_LIMITS = FILE_LIMITS;
|
|
3483
|
+
exports.FeatureType = FeatureType;
|
|
3201
3484
|
exports.FilesResource = FilesResource;
|
|
3202
3485
|
exports.GymSpaceError = GymSpaceError;
|
|
3203
3486
|
exports.GymSpaceSdk = GymSpaceSdk;
|
|
@@ -3222,7 +3505,9 @@ exports.PaymentFrequency = PaymentFrequency;
|
|
|
3222
3505
|
exports.PaymentMethodsResource = PaymentMethodsResource;
|
|
3223
3506
|
exports.PlanStatus = PlanStatus;
|
|
3224
3507
|
exports.PlanType = PlanType;
|
|
3508
|
+
exports.PricingPackagesResource = PricingPackagesResource;
|
|
3225
3509
|
exports.ProductsResource = ProductsResource;
|
|
3510
|
+
exports.PromoCodesResource = PromoCodesResource;
|
|
3226
3511
|
exports.PublicCatalogResource = PublicCatalogResource;
|
|
3227
3512
|
exports.ROLE_NAMES = ROLE_NAMES;
|
|
3228
3513
|
exports.ROLE_PERMISSIONS = ROLE_PERMISSIONS;
|