node-paytmpg 8.0.5 → 8.0.6

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.
@@ -341,10 +341,25 @@ class SubscriptionController {
341
341
  async getSubscriptions(req, res) {
342
342
  try {
343
343
  const clientId = req.query.clientId || req.query.client_id || req.headers['x-client-id'] || '';
344
+ const userId = req.query.userId || req.query.user_id || req.query.cusId;
345
+ const userEmail = req.query.userEmail || req.query.user_email || req.query.email;
344
346
  const query = {};
345
347
  if (clientId) {
346
348
  query.clientId = clientId;
347
349
  }
350
+ if (userId) {
351
+ query.cusId = userId;
352
+ }
353
+ if (userEmail) {
354
+ const user = await this.db.getOne(this.tableNames.USER, { email: userEmail }).catch(() => null);
355
+ if (user) {
356
+ query.cusId = user.id;
357
+ }
358
+ else {
359
+ res.send({ limit: 20, offset: 0, count: 0, subscriptions: [] });
360
+ return;
361
+ }
362
+ }
348
363
  const limit = Math.min(parseInt(req.query.limit, 10) || 20, 100);
349
364
  const offset = Math.max(parseInt(req.query.offset, 10) || 0, 0);
350
365
  const subs = await this.db.get(this.tableNames.SUBSCRIPTION, query, {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-paytmpg",
3
- "version": "8.0.5",
3
+ "version": "8.0.6",
4
4
  "description": "Payment Gateway Integration using NodeJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-paytmpg",
3
- "version": "8.0.5",
3
+ "version": "8.0.6",
4
4
  "description": "Payment Gateway Integration using NodeJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",