goldstars-services 1.0.9 → 1.0.10

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
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "TransactionService", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _transactions.default;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "UserService", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -24,4 +30,5 @@ Object.defineProperty(exports, "iniciarDb", {
24
30
  var _db = _interopRequireDefault(require("./db"));
25
31
  var _user = _interopRequireDefault(require("./services/user.service"));
26
32
  var _config = _interopRequireDefault(require("./services/config.service"));
33
+ var _transactions = _interopRequireDefault(require("./services/transactions.service"));
27
34
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _mongoose = _interopRequireDefault(require("mongoose"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var {
10
+ Schema
11
+ } = _mongoose.default;
12
+ var TransactionSchema = Schema({
13
+ type: {
14
+ type: String,
15
+ enum: ["deposit"]
16
+ },
17
+ method: {
18
+ type: String,
19
+ enum: ["zelle", "bolivares", "paypal", "stripe", "binance"]
20
+ },
21
+ user: {
22
+ type: Schema.Types.ObjectId,
23
+ ref: "User"
24
+ },
25
+ relatedPlan: [{
26
+ type: Schema.Types.ObjectId,
27
+ ref: "Session"
28
+ }],
29
+ creationDate: {
30
+ type: Date,
31
+ default: Date.now
32
+ },
33
+ idNumber: {
34
+ type: String
35
+ },
36
+ fullName: {
37
+ type: String
38
+ },
39
+ email: {
40
+ type: String
41
+ },
42
+ account: {
43
+ type: Number
44
+ },
45
+ transactionRef: {
46
+ type: String,
47
+ required: false
48
+ },
49
+ bank: {
50
+ type: String
51
+ },
52
+ amount: {
53
+ type: Number,
54
+ required: false
55
+ },
56
+ imageRef: {
57
+ type: String
58
+ },
59
+ status: {
60
+ type: String,
61
+ enum: ["approved", "rejected", "pending", "paid"],
62
+ default: "pending"
63
+ },
64
+ amountOfDolar: {
65
+ type: Number,
66
+ required: false
67
+ }
68
+ });
69
+ var Transaction = _mongoose.default.model("Transaction", TransactionSchema);
70
+ var _default = exports.default = Transaction;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _queries = require("../config/queries");
8
+ var _transanctions = _interopRequireDefault(require("../models/transanctions.model"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
12
+ /**
13
+ * @description Creates a new transaction
14
+ * @param {Object} transactionParams
15
+ * @returns
16
+ */
17
+ var createTransaction = function createTransaction() {
18
+ var transactionParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
19
+ return _transanctions.default.create(transactionParams);
20
+ };
21
+
22
+ /**
23
+ * @description Updates a transaction
24
+ * @param {string} queryParams
25
+ * @param {Object} paramsToUpdate
26
+ * @returns Promise<AxiosResponse<UserModel>>
27
+ */
28
+ var updateTransaction = (queryParams, paramsToUpdate) => {
29
+ var mongooseOptions = {
30
+ useFindAndModify: false
31
+ };
32
+ var updateOperation = _transanctions.default.findOneAndUpdate(queryParams, paramsToUpdate, mongooseOptions);
33
+ return updateOperation;
34
+ };
35
+
36
+ /**
37
+ * @description Get user transactions by query params
38
+ * @param {Object} transactionParams
39
+ * @param {Boolean} populate
40
+ * @returns
41
+ */
42
+ var getUserTransactions = function getUserTransactions() {
43
+ var transactionParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
44
+ return _transanctions.default.find(transactionParams);
45
+ };
46
+
47
+ /**
48
+ * @description Get transactions by query params
49
+ * @param {Object} transactionParams
50
+ * @param {Boolean} populate
51
+ * @returns
52
+ */
53
+ var getTransactions = function getTransactions() {
54
+ var transactionParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
55
+ var populate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
56
+ return _transanctions.default.find(transactionParams, _queries.QUERY_USER_PAY_METHOD).populate({
57
+ path: "user",
58
+ model: "User",
59
+ select: ["firstName", "lastName", "avatar", "paymentMethods", "isTrainer", "email"]
60
+ });
61
+ };
62
+
63
+ /**
64
+ * @description Returns the count of all transactions
65
+ * @returns {Promise<Number>}
66
+ */
67
+ var getTransactionCount = /*#__PURE__*/function () {
68
+ var _ref = _asyncToGenerator(function* () {
69
+ try {
70
+ var count = yield _transanctions.default.countDocuments();
71
+ return count;
72
+ } catch (error) {
73
+ console.error(error);
74
+ }
75
+ });
76
+ return function getTransactionCount() {
77
+ return _ref.apply(this, arguments);
78
+ };
79
+ }();
80
+
81
+ /**
82
+ * @description Returns the count of all deposit transactions
83
+ * @returns {Promise<Number>}
84
+ */
85
+ var getDepositTransactionCount = /*#__PURE__*/function () {
86
+ var _ref2 = _asyncToGenerator(function* () {
87
+ try {
88
+ var count = yield _transanctions.default.countDocuments({
89
+ type: 'deposit'
90
+ });
91
+ return count;
92
+ } catch (error) {
93
+ console.error(error);
94
+ }
95
+ });
96
+ return function getDepositTransactionCount() {
97
+ return _ref2.apply(this, arguments);
98
+ };
99
+ }();
100
+
101
+ /**
102
+ * @description Returns the count of all payment transactions
103
+ * @returns {Promise<Number>}
104
+ */
105
+ var getPaymentTransactionCount = /*#__PURE__*/function () {
106
+ var _ref3 = _asyncToGenerator(function* () {
107
+ try {
108
+ var count = yield _transanctions.default.countDocuments({
109
+ type: 'payment'
110
+ });
111
+ return count;
112
+ } catch (error) {
113
+ console.error(error);
114
+ }
115
+ });
116
+ return function getPaymentTransactionCount() {
117
+ return _ref3.apply(this, arguments);
118
+ };
119
+ }();
120
+ var _default = exports.default = {
121
+ createTransaction,
122
+ updateTransaction,
123
+ getUserTransactions,
124
+ getTransactionCount,
125
+ getTransactions,
126
+ getDepositTransactionCount,
127
+ getPaymentTransactionCount
128
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstars-services",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "This is the services layer for GoldStars",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {