goldstars-services 1.0.15 → 1.0.16

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.
@@ -0,0 +1,56 @@
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 bankAccountSchema = new Schema({
13
+ method: {
14
+ type: String,
15
+ enum: ["zelle", "transferencia", "pagoMovil"],
16
+ required: true
17
+ },
18
+ bank: {
19
+ type: String,
20
+ required: false
21
+ },
22
+ account: {
23
+ name: {
24
+ type: String,
25
+ required: true
26
+ },
27
+ id: {
28
+ type: String,
29
+ required: false
30
+ },
31
+ email: {
32
+ type: String,
33
+ required: false
34
+ },
35
+ phone: {
36
+ type: String,
37
+ required: false
38
+ },
39
+ number: {
40
+ type: String,
41
+ required: false
42
+ },
43
+ currency: {
44
+ type: String,
45
+ required: true,
46
+ enum: ["USD", "BS"],
47
+ default: "BS"
48
+ }
49
+ },
50
+ active: {
51
+ type: Boolean,
52
+ default: true
53
+ }
54
+ });
55
+ var BankAccount = _mongoose.default.model("BankAccount", bankAccountSchema);
56
+ var _default = exports.default = BankAccount;
@@ -6,57 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _mongoose = _interopRequireDefault(require("mongoose"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
13
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
9
  var {
15
10
  Schema
16
11
  } = _mongoose.default;
17
- var bankAccounts = {
18
- method: {
19
- type: String,
20
- enum: ["zelle", "transferencia", "pagoMovil"]
21
- },
22
- bank: {
23
- type: String,
24
- required: false
25
- },
26
- account: {
27
- name: {
28
- type: String,
29
- required: true
30
- },
31
- id: {
32
- type: String,
33
- required: false
34
- },
35
- email: {
36
- type: String,
37
- required: false
38
- },
39
- phone: {
40
- type: String,
41
- required: false
42
- },
43
- number: {
44
- type: String,
45
- required: false
46
- },
47
- currency: {
48
- type: String,
49
- required: true,
50
- enum: ["USD", "BS"],
51
- default: "BS"
52
- }
53
- },
54
- active: {
55
- type: Boolean,
56
- required: false,
57
- default: true
58
- }
59
- };
60
12
  var configSchema = Schema({
61
13
  dolarPrice: {
62
14
  pacient: {
@@ -72,7 +24,6 @@ var configSchema = Schema({
72
24
  type: Number,
73
25
  required: false
74
26
  },
75
- banks: [_objectSpread({}, bankAccounts)],
76
27
  paypal: {
77
28
  type: Boolean,
78
29
  default: false
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _bankAccount = _interopRequireDefault(require("../models/bankAccount.model"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ 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); }
10
+ 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); }); }; }
11
+ /**
12
+ * @description Get all bank accounts
13
+ * @returns {Promise<Array<Object>>}
14
+ */
15
+ var getAllBankAccounts = /*#__PURE__*/function () {
16
+ var _ref = _asyncToGenerator(function* () {
17
+ try {
18
+ return yield _bankAccount.default.find({});
19
+ } catch (error) {
20
+ console.error(error);
21
+ throw error;
22
+ }
23
+ });
24
+ return function getAllBankAccounts() {
25
+ return _ref.apply(this, arguments);
26
+ };
27
+ }();
28
+
29
+ /**
30
+ * @description Get a single bank account by ID
31
+ * @param {String} id
32
+ * @returns {Promise<Object>}
33
+ */
34
+ var getBankAccountById = /*#__PURE__*/function () {
35
+ var _ref2 = _asyncToGenerator(function* (id) {
36
+ try {
37
+ return yield _bankAccount.default.findById(id);
38
+ } catch (error) {
39
+ console.error(error);
40
+ throw error;
41
+ }
42
+ });
43
+ return function getBankAccountById(_x) {
44
+ return _ref2.apply(this, arguments);
45
+ };
46
+ }();
47
+
48
+ /**
49
+ * @description Create a new bank account
50
+ * @param {Object} accountData
51
+ * @returns {Promise<Object>}
52
+ */
53
+ var createBankAccount = /*#__PURE__*/function () {
54
+ var _ref3 = _asyncToGenerator(function* (accountData) {
55
+ try {
56
+ var newBankAccount = new _bankAccount.default(accountData);
57
+ return yield newBankAccount.save();
58
+ } catch (error) {
59
+ console.error(error);
60
+ throw error;
61
+ }
62
+ });
63
+ return function createBankAccount(_x2) {
64
+ return _ref3.apply(this, arguments);
65
+ };
66
+ }();
67
+
68
+ /**
69
+ * @description Update a bank account by ID
70
+ * @param {String} id
71
+ * @param {Object} accountData
72
+ * @returns {Promise<Object>}
73
+ */
74
+ var updateBankAccount = /*#__PURE__*/function () {
75
+ var _ref4 = _asyncToGenerator(function* (id, accountData) {
76
+ try {
77
+ var updatedAccount = yield _bankAccount.default.findByIdAndUpdate(id, accountData, {
78
+ new: true,
79
+ useFindAndModify: false
80
+ });
81
+ return updatedAccount;
82
+ } catch (error) {
83
+ console.error(error);
84
+ throw error;
85
+ }
86
+ });
87
+ return function updateBankAccount(_x3, _x4) {
88
+ return _ref4.apply(this, arguments);
89
+ };
90
+ }();
91
+
92
+ /**
93
+ * @description Delete a bank account by ID
94
+ * @param {String} id
95
+ * @returns {Promise<Object>}
96
+ */
97
+ var deleteBankAccount = /*#__PURE__*/function () {
98
+ var _ref5 = _asyncToGenerator(function* (id) {
99
+ try {
100
+ return yield _bankAccount.default.findByIdAndDelete(id);
101
+ } catch (error) {
102
+ console.error(error);
103
+ throw error;
104
+ }
105
+ });
106
+ return function deleteBankAccount(_x5) {
107
+ return _ref5.apply(this, arguments);
108
+ };
109
+ }();
110
+
111
+ /**
112
+ * @description Change the active status of a bank account
113
+ * @param {String} id
114
+ * @param {Boolean} newStatus
115
+ * @returns {Promise<Object>}
116
+ */
117
+ var changeBankStatus = /*#__PURE__*/function () {
118
+ var _ref6 = _asyncToGenerator(function* (id, newStatus) {
119
+ try {
120
+ var updatedAccount = yield _bankAccount.default.findByIdAndUpdate(id, {
121
+ active: newStatus
122
+ }, {
123
+ new: true,
124
+ useFindAndModify: false
125
+ });
126
+ return updatedAccount;
127
+ } catch (error) {
128
+ console.error(error);
129
+ throw error;
130
+ }
131
+ });
132
+ return function changeBankStatus(_x6, _x7) {
133
+ return _ref6.apply(this, arguments);
134
+ };
135
+ }();
136
+ var _default = exports.default = {
137
+ getAllBankAccounts,
138
+ getBankAccountById,
139
+ createBankAccount,
140
+ updateBankAccount,
141
+ deleteBankAccount,
142
+ changeBankStatus
143
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstars-services",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "This is the services layer for GoldStars",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {