@stamhoofd/models 2.39.0 → 2.40.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.
Files changed (352) hide show
  1. package/dist/src/factories/AddressFactory.d.ts +3 -4
  2. package/dist/src/factories/AddressFactory.d.ts.map +1 -1
  3. package/dist/src/factories/AddressFactory.js +13 -13
  4. package/dist/src/factories/EmergencyContactFactory.d.ts +3 -4
  5. package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -1
  6. package/dist/src/factories/EmergencyContactFactory.js +27 -27
  7. package/dist/src/factories/EmergencyContactFactory.js.map +1 -1
  8. package/dist/src/factories/GroupFactory.d.ts +4 -4
  9. package/dist/src/factories/GroupFactory.d.ts.map +1 -1
  10. package/dist/src/factories/GroupFactory.js +8 -8
  11. package/dist/src/factories/GroupFactory.js.map +1 -1
  12. package/dist/src/factories/MemberFactory.d.ts +4 -4
  13. package/dist/src/factories/MemberFactory.d.ts.map +1 -1
  14. package/dist/src/factories/MemberFactory.js +17 -17
  15. package/dist/src/factories/MemberFactory.js.map +1 -1
  16. package/dist/src/factories/OrganizationFactory.d.ts +4 -4
  17. package/dist/src/factories/OrganizationFactory.js +8 -8
  18. package/dist/src/factories/OrganizationFactory.js.map +1 -1
  19. package/dist/src/factories/ParentFactory.d.ts +1 -1
  20. package/dist/src/factories/ParentFactory.js +19 -19
  21. package/dist/src/factories/ParentFactory.js.map +1 -1
  22. package/dist/src/factories/RecordFactory.d.ts +2 -3
  23. package/dist/src/factories/RecordFactory.d.ts.map +1 -1
  24. package/dist/src/factories/RecordFactory.js +1 -1
  25. package/dist/src/factories/RecordFactory.js.map +1 -1
  26. package/dist/src/factories/RegisterCodeFactory.d.ts +2 -2
  27. package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -1
  28. package/dist/src/factories/RegisterCodeFactory.js +2 -2
  29. package/dist/src/factories/RegistrationFactory.d.ts +3 -3
  30. package/dist/src/factories/RegistrationFactory.d.ts.map +1 -1
  31. package/dist/src/factories/RegistrationFactory.js.map +1 -1
  32. package/dist/src/factories/RegistrationPeriodFactory.d.ts +2 -2
  33. package/dist/src/factories/RegistrationPeriodFactory.js.map +1 -1
  34. package/dist/src/factories/UserFactory.d.ts +3 -3
  35. package/dist/src/factories/UserFactory.d.ts.map +1 -1
  36. package/dist/src/factories/UserFactory.js +3 -3
  37. package/dist/src/factories/UserFactory.js.map +1 -1
  38. package/dist/src/factories/WebshopFactory.d.ts +4 -4
  39. package/dist/src/factories/WebshopFactory.d.ts.map +1 -1
  40. package/dist/src/factories/WebshopFactory.js +1 -1
  41. package/dist/src/factories/WebshopFactory.js.map +1 -1
  42. package/dist/src/helpers/DNSValidator.d.ts +1 -1
  43. package/dist/src/helpers/DNSValidator.d.ts.map +1 -1
  44. package/dist/src/helpers/DNSValidator.js +33 -33
  45. package/dist/src/helpers/DNSValidator.js.map +1 -1
  46. package/dist/src/helpers/EmailBuilder.d.ts +10 -10
  47. package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
  48. package/dist/src/helpers/EmailBuilder.js +34 -34
  49. package/dist/src/helpers/EmailBuilder.js.map +1 -1
  50. package/dist/src/helpers/GroupBuilder.d.ts.map +1 -1
  51. package/dist/src/helpers/GroupBuilder.js +57 -57
  52. package/dist/src/helpers/GroupBuilder.js.map +1 -1
  53. package/dist/src/helpers/Handlebars.d.ts.map +1 -1
  54. package/dist/src/helpers/Handlebars.js +29 -29
  55. package/dist/src/helpers/Handlebars.js.map +1 -1
  56. package/dist/src/helpers/MemberMerger.d.ts +1 -1
  57. package/dist/src/helpers/MemberMerger.d.ts.map +1 -1
  58. package/dist/src/helpers/MemberMerger.js +33 -33
  59. package/dist/src/helpers/MemberMerger.js.map +1 -1
  60. package/dist/src/helpers/MemberMerger.test.js +194 -194
  61. package/dist/src/helpers/MemberMerger.test.js.map +1 -1
  62. package/dist/src/helpers/RateLimiter.d.ts.map +1 -1
  63. package/dist/src/helpers/RateLimiter.js +2 -2
  64. package/dist/src/helpers/RateLimiter.js.map +1 -1
  65. package/dist/src/helpers/SetupStepsUpdater.d.ts +22 -0
  66. package/dist/src/helpers/SetupStepsUpdater.d.ts.map +1 -0
  67. package/dist/src/helpers/SetupStepsUpdater.js +255 -0
  68. package/dist/src/helpers/SetupStepsUpdater.js.map +1 -0
  69. package/dist/src/helpers/WebshopCounter.d.ts +1 -1
  70. package/dist/src/helpers/WebshopCounter.d.ts.map +1 -1
  71. package/dist/src/helpers/WebshopCounter.js +1 -1
  72. package/dist/src/helpers/WebshopCounter.js.map +1 -1
  73. package/dist/src/helpers/WebshopCounter.test.js +6 -6
  74. package/dist/src/helpers/WebshopCounter.test.js.map +1 -1
  75. package/dist/src/index.d.ts +20 -19
  76. package/dist/src/index.d.ts.map +1 -1
  77. package/dist/src/index.js +1 -0
  78. package/dist/src/index.js.map +1 -1
  79. package/dist/src/migrations/1605262045-import-postcodes.js +12 -12
  80. package/dist/src/migrations/1605262046-import-postcodes-nl.js +10 -10
  81. package/dist/src/models/BalanceItem.d.ts.map +1 -1
  82. package/dist/src/models/BalanceItem.js +37 -37
  83. package/dist/src/models/BalanceItem.js.map +1 -1
  84. package/dist/src/models/BalanceItemPayment.d.ts.map +1 -1
  85. package/dist/src/models/BalanceItemPayment.js +13 -13
  86. package/dist/src/models/BalanceItemPayment.js.map +1 -1
  87. package/dist/src/models/BuckarooPayment.d.ts +1 -1
  88. package/dist/src/models/BuckarooPayment.d.ts.map +1 -1
  89. package/dist/src/models/BuckarooPayment.js +5 -5
  90. package/dist/src/models/BuckarooPayment.js.map +1 -1
  91. package/dist/src/models/CachedOutstandingBalance.d.ts.map +1 -1
  92. package/dist/src/models/CachedOutstandingBalance.js +37 -37
  93. package/dist/src/models/CachedOutstandingBalance.js.map +1 -1
  94. package/dist/src/models/Document.d.ts +4 -4
  95. package/dist/src/models/Document.d.ts.map +1 -1
  96. package/dist/src/models/Document.js +27 -27
  97. package/dist/src/models/Document.js.map +1 -1
  98. package/dist/src/models/DocumentTemplate.d.ts +4 -4
  99. package/dist/src/models/DocumentTemplate.d.ts.map +1 -1
  100. package/dist/src/models/DocumentTemplate.js +72 -72
  101. package/dist/src/models/DocumentTemplate.js.map +1 -1
  102. package/dist/src/models/Email.d.ts.map +1 -1
  103. package/dist/src/models/Email.js +63 -64
  104. package/dist/src/models/Email.js.map +1 -1
  105. package/dist/src/models/EmailRecipient.d.ts.map +1 -1
  106. package/dist/src/models/EmailRecipient.js +20 -20
  107. package/dist/src/models/EmailRecipient.js.map +1 -1
  108. package/dist/src/models/EmailTemplate.d.ts +3 -3
  109. package/dist/src/models/EmailTemplate.d.ts.map +1 -1
  110. package/dist/src/models/EmailTemplate.js +16 -16
  111. package/dist/src/models/EmailTemplate.js.map +1 -1
  112. package/dist/src/models/EmailVerificationCode.d.ts +2 -2
  113. package/dist/src/models/EmailVerificationCode.d.ts.map +1 -1
  114. package/dist/src/models/EmailVerificationCode.js +57 -55
  115. package/dist/src/models/EmailVerificationCode.js.map +1 -1
  116. package/dist/src/models/Event.d.ts +2 -2
  117. package/dist/src/models/Event.d.ts.map +1 -1
  118. package/dist/src/models/Event.js +15 -15
  119. package/dist/src/models/Event.js.map +1 -1
  120. package/dist/src/models/Group.d.ts +3 -1
  121. package/dist/src/models/Group.d.ts.map +1 -1
  122. package/dist/src/models/Group.js +46 -35
  123. package/dist/src/models/Group.js.map +1 -1
  124. package/dist/src/models/Image.d.ts +1 -1
  125. package/dist/src/models/Image.d.ts.map +1 -1
  126. package/dist/src/models/Image.js +26 -26
  127. package/dist/src/models/Image.js.map +1 -1
  128. package/dist/src/models/Member.d.ts +8 -8
  129. package/dist/src/models/Member.d.ts.map +1 -1
  130. package/dist/src/models/Member.js +60 -60
  131. package/dist/src/models/Member.js.map +1 -1
  132. package/dist/src/models/MemberPlatformMembership.d.ts +3 -3
  133. package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
  134. package/dist/src/models/MemberPlatformMembership.js +26 -26
  135. package/dist/src/models/MemberPlatformMembership.js.map +1 -1
  136. package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
  137. package/dist/src/models/MemberResponsibilityRecord.js +13 -13
  138. package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
  139. package/dist/src/models/MergedMember.d.ts +3 -3
  140. package/dist/src/models/MergedMember.d.ts.map +1 -1
  141. package/dist/src/models/MergedMember.js +19 -19
  142. package/dist/src/models/MergedMember.js.map +1 -1
  143. package/dist/src/models/MolliePayment.d.ts +1 -1
  144. package/dist/src/models/MolliePayment.d.ts.map +1 -1
  145. package/dist/src/models/MolliePayment.js +5 -5
  146. package/dist/src/models/MolliePayment.js.map +1 -1
  147. package/dist/src/models/MollieToken.d.ts.map +1 -1
  148. package/dist/src/models/MollieToken.js +60 -60
  149. package/dist/src/models/MollieToken.js.map +1 -1
  150. package/dist/src/models/OneTimeToken.d.ts +2 -2
  151. package/dist/src/models/OneTimeToken.d.ts.map +1 -1
  152. package/dist/src/models/OneTimeToken.js +13 -13
  153. package/dist/src/models/OneTimeToken.js.map +1 -1
  154. package/dist/src/models/Order.d.ts +1 -1
  155. package/dist/src/models/Order.d.ts.map +1 -1
  156. package/dist/src/models/Order.js +70 -70
  157. package/dist/src/models/Order.js.map +1 -1
  158. package/dist/src/models/Organization.d.ts +5 -5
  159. package/dist/src/models/Organization.d.ts.map +1 -1
  160. package/dist/src/models/Organization.js +127 -127
  161. package/dist/src/models/Organization.js.map +1 -1
  162. package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -1
  163. package/dist/src/models/OrganizationRegistrationPeriod.js +15 -15
  164. package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -1
  165. package/dist/src/models/PasswordToken.d.ts +3 -3
  166. package/dist/src/models/PasswordToken.d.ts.map +1 -1
  167. package/dist/src/models/PasswordToken.js +17 -17
  168. package/dist/src/models/PasswordToken.js.map +1 -1
  169. package/dist/src/models/PayconiqPayment.d.ts +1 -1
  170. package/dist/src/models/PayconiqPayment.d.ts.map +1 -1
  171. package/dist/src/models/PayconiqPayment.js +49 -49
  172. package/dist/src/models/PayconiqPayment.js.map +1 -1
  173. package/dist/src/models/Payment.d.ts +3 -3
  174. package/dist/src/models/Payment.d.ts.map +1 -1
  175. package/dist/src/models/Payment.js +36 -36
  176. package/dist/src/models/Payment.js.map +1 -1
  177. package/dist/src/models/Platform.d.ts +2 -2
  178. package/dist/src/models/Platform.d.ts.map +1 -1
  179. package/dist/src/models/Platform.js +8 -8
  180. package/dist/src/models/Platform.js.map +1 -1
  181. package/dist/src/models/RegisterCode.d.ts +1 -1
  182. package/dist/src/models/RegisterCode.d.ts.map +1 -1
  183. package/dist/src/models/RegisterCode.js +11 -11
  184. package/dist/src/models/RegisterCode.js.map +1 -1
  185. package/dist/src/models/Registration.d.ts +1 -1
  186. package/dist/src/models/Registration.d.ts.map +1 -1
  187. package/dist/src/models/Registration.js +88 -88
  188. package/dist/src/models/Registration.js.map +1 -1
  189. package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
  190. package/dist/src/models/RegistrationPeriod.js +12 -12
  191. package/dist/src/models/RegistrationPeriod.js.map +1 -1
  192. package/dist/src/models/STCredit.d.ts +1 -1
  193. package/dist/src/models/STCredit.d.ts.map +1 -1
  194. package/dist/src/models/STCredit.js +12 -12
  195. package/dist/src/models/STCredit.js.map +1 -1
  196. package/dist/src/models/STInvoice.d.ts +1 -1
  197. package/dist/src/models/STInvoice.d.ts.map +1 -1
  198. package/dist/src/models/STInvoice.js +16 -16
  199. package/dist/src/models/STInvoice.js.map +1 -1
  200. package/dist/src/models/STPackage.d.ts +1 -1
  201. package/dist/src/models/STPackage.d.ts.map +1 -1
  202. package/dist/src/models/STPackage.js +39 -39
  203. package/dist/src/models/STPackage.js.map +1 -1
  204. package/dist/src/models/STPendingInvoice.d.ts +1 -1
  205. package/dist/src/models/STPendingInvoice.d.ts.map +1 -1
  206. package/dist/src/models/STPendingInvoice.js +11 -11
  207. package/dist/src/models/STPendingInvoice.js.map +1 -1
  208. package/dist/src/models/StripeAccount.d.ts.map +1 -1
  209. package/dist/src/models/StripeAccount.js +13 -13
  210. package/dist/src/models/StripeAccount.js.map +1 -1
  211. package/dist/src/models/StripeCheckoutSession.d.ts +1 -1
  212. package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -1
  213. package/dist/src/models/StripeCheckoutSession.js +7 -7
  214. package/dist/src/models/StripeCheckoutSession.js.map +1 -1
  215. package/dist/src/models/StripePaymentIntent.d.ts +1 -1
  216. package/dist/src/models/StripePaymentIntent.d.ts.map +1 -1
  217. package/dist/src/models/StripePaymentIntent.js +7 -7
  218. package/dist/src/models/StripePaymentIntent.js.map +1 -1
  219. package/dist/src/models/Ticket.d.ts +2 -2
  220. package/dist/src/models/Ticket.d.ts.map +1 -1
  221. package/dist/src/models/Ticket.js +23 -23
  222. package/dist/src/models/Ticket.js.map +1 -1
  223. package/dist/src/models/Token.d.ts +3 -3
  224. package/dist/src/models/Token.d.ts.map +1 -1
  225. package/dist/src/models/Token.js +27 -27
  226. package/dist/src/models/Token.js.map +1 -1
  227. package/dist/src/models/Token.test.js +11 -11
  228. package/dist/src/models/UsedRegisterCode.d.ts +1 -1
  229. package/dist/src/models/UsedRegisterCode.d.ts.map +1 -1
  230. package/dist/src/models/UsedRegisterCode.js +10 -10
  231. package/dist/src/models/UsedRegisterCode.js.map +1 -1
  232. package/dist/src/models/User.d.ts +4 -4
  233. package/dist/src/models/User.d.ts.map +1 -1
  234. package/dist/src/models/User.js +53 -51
  235. package/dist/src/models/User.js.map +1 -1
  236. package/dist/src/models/UserPermissions.d.ts +3 -3
  237. package/dist/src/models/UserPermissions.d.ts.map +1 -1
  238. package/dist/src/models/UserPermissions.js +12 -12
  239. package/dist/src/models/UserPermissions.js.map +1 -1
  240. package/dist/src/models/Webshop.d.ts +1 -1
  241. package/dist/src/models/Webshop.d.ts.map +1 -1
  242. package/dist/src/models/Webshop.js +23 -23
  243. package/dist/src/models/Webshop.js.map +1 -1
  244. package/dist/src/models/WebshopDiscountCode.d.ts +1 -1
  245. package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -1
  246. package/dist/src/models/WebshopDiscountCode.js +16 -16
  247. package/dist/src/models/WebshopDiscountCode.js.map +1 -1
  248. package/dist/src/models/addresses/City.d.ts.map +1 -1
  249. package/dist/src/models/addresses/City.js +9 -9
  250. package/dist/src/models/addresses/City.js.map +1 -1
  251. package/dist/src/models/addresses/PostalCode.d.ts.map +1 -1
  252. package/dist/src/models/addresses/PostalCode.js +11 -11
  253. package/dist/src/models/addresses/PostalCode.js.map +1 -1
  254. package/dist/src/models/addresses/PostalCode.test.js +22 -22
  255. package/dist/src/models/addresses/PostalCode.test.js.map +1 -1
  256. package/dist/src/models/addresses/Province.d.ts.map +1 -1
  257. package/dist/src/models/addresses/Province.js +5 -5
  258. package/dist/src/models/addresses/Province.js.map +1 -1
  259. package/dist/src/models/addresses/Street.d.ts.map +1 -1
  260. package/dist/src/models/addresses/Street.js +6 -6
  261. package/dist/src/models/addresses/Street.js.map +1 -1
  262. package/dist/src/models/index.d.ts +46 -46
  263. package/dist/src/models/index.d.ts.map +1 -1
  264. package/dist/src/models/index.js +0 -1
  265. package/dist/src/models/index.js.map +1 -1
  266. package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -1
  267. package/dist/src/structures/OrganizationServerMetaData.js +4 -4
  268. package/dist/src/structures/OrganizationServerMetaData.js.map +1 -1
  269. package/dist/tests/jest.global.setup.d.ts.map +1 -1
  270. package/dist/tests/jest.global.setup.js +15 -13
  271. package/dist/tests/jest.global.setup.js.map +1 -1
  272. package/dist/tests/jest.setup.js +3 -1
  273. package/dist/tests/jest.setup.js.map +1 -1
  274. package/dist/tsconfig.tsbuildinfo +1 -0
  275. package/package.json +3 -3
  276. package/src/factories/AddressFactory.ts +17 -17
  277. package/src/factories/EmergencyContactFactory.ts +30 -31
  278. package/src/factories/GroupFactory.ts +30 -30
  279. package/src/factories/MemberFactory.ts +41 -38
  280. package/src/factories/OrganizationFactory.ts +15 -15
  281. package/src/factories/ParentFactory.ts +24 -24
  282. package/src/factories/RecordFactory.ts +5 -4
  283. package/src/factories/RegisterCodeFactory.ts +7 -7
  284. package/src/factories/RegistrationFactory.ts +16 -16
  285. package/src/factories/RegistrationPeriodFactory.ts +5 -5
  286. package/src/factories/UserFactory.ts +20 -19
  287. package/src/factories/WebshopFactory.ts +14 -14
  288. package/src/helpers/DNSValidator.ts +89 -84
  289. package/src/helpers/EmailBuilder.ts +141 -135
  290. package/src/helpers/GroupBuilder.ts +181 -181
  291. package/src/helpers/Handlebars.ts +57 -54
  292. package/src/helpers/MemberMerger.test.ts +702 -702
  293. package/src/helpers/MemberMerger.ts +83 -77
  294. package/src/helpers/RateLimiter.ts +25 -27
  295. package/src/helpers/SetupStepsUpdater.ts +402 -0
  296. package/src/helpers/WebshopCounter.test.ts +12 -12
  297. package/src/helpers/WebshopCounter.ts +20 -19
  298. package/src/index.ts +20 -19
  299. package/src/migrations/1605262045-import-postcodes.ts +59 -63
  300. package/src/migrations/1605262046-import-postcodes-nl.ts +41 -43
  301. package/src/models/BalanceItem.ts +173 -172
  302. package/src/models/BalanceItemPayment.ts +32 -33
  303. package/src/models/BuckarooPayment.ts +7 -7
  304. package/src/models/CachedOutstandingBalance.ts +98 -99
  305. package/src/models/Document.ts +90 -87
  306. package/src/models/DocumentTemplate.ts +207 -198
  307. package/src/models/Email.ts +198 -200
  308. package/src/models/EmailRecipient.ts +38 -39
  309. package/src/models/EmailTemplate.ts +36 -37
  310. package/src/models/EmailVerificationCode.ts +146 -142
  311. package/src/models/Event.ts +53 -53
  312. package/src/models/Group.ts +136 -123
  313. package/src/models/Image.ts +48 -48
  314. package/src/models/Member.ts +277 -275
  315. package/src/models/MemberPlatformMembership.ts +71 -71
  316. package/src/models/MemberResponsibilityRecord.ts +32 -32
  317. package/src/models/MergedMember.ts +77 -77
  318. package/src/models/MolliePayment.ts +7 -7
  319. package/src/models/MollieToken.ts +131 -126
  320. package/src/models/OneTimeToken.ts +40 -39
  321. package/src/models/Order.ts +379 -372
  322. package/src/models/Organization.ts +332 -325
  323. package/src/models/OrganizationRegistrationPeriod.ts +50 -50
  324. package/src/models/PasswordToken.ts +42 -42
  325. package/src/models/PayconiqPayment.ts +80 -76
  326. package/src/models/Payment.ts +86 -86
  327. package/src/models/Platform.ts +21 -22
  328. package/src/models/RegisterCode.ts +26 -26
  329. package/src/models/Registration.ts +167 -168
  330. package/src/models/RegistrationPeriod.ts +29 -29
  331. package/src/models/STCredit.ts +24 -25
  332. package/src/models/STInvoice.ts +34 -34
  333. package/src/models/STPackage.ts +143 -136
  334. package/src/models/STPendingInvoice.ts +26 -26
  335. package/src/models/StripeAccount.ts +27 -27
  336. package/src/models/StripeCheckoutSession.ts +10 -10
  337. package/src/models/StripePaymentIntent.ts +10 -10
  338. package/src/models/Ticket.ts +51 -52
  339. package/src/models/Token.test.ts +13 -13
  340. package/src/models/Token.ts +64 -63
  341. package/src/models/UsedRegisterCode.ts +20 -21
  342. package/src/models/User.ts +148 -144
  343. package/src/models/UserPermissions.ts +25 -28
  344. package/src/models/Webshop.ts +53 -53
  345. package/src/models/WebshopDiscountCode.ts +33 -33
  346. package/src/models/addresses/City.ts +12 -12
  347. package/src/models/addresses/PostalCode.test.ts +68 -69
  348. package/src/models/addresses/PostalCode.ts +57 -57
  349. package/src/models/addresses/Province.ts +8 -8
  350. package/src/models/addresses/Street.ts +10 -12
  351. package/src/models/index.ts +54 -55
  352. package/src/structures/OrganizationServerMetaData.ts +36 -36
@@ -1,126 +1,126 @@
1
1
  import { column, Model } from '@simonbackx/simple-database';
2
2
  import { Group as GroupStruct, OrganizationRegistrationPeriodSettings, OrganizationRegistrationPeriod as OrganizationRegistrationPeriodStruct, SetupSteps } from '@stamhoofd/structures';
3
3
  import { Formatter } from '@stamhoofd/utility';
4
- import { v4 as uuidv4 } from "uuid";
4
+ import { v4 as uuidv4 } from 'uuid';
5
5
  import { Group, RegistrationPeriod } from '.';
6
6
 
7
7
  export class OrganizationRegistrationPeriod extends Model {
8
- static table = "organization_registration_periods";
8
+ static table = 'organization_registration_periods';
9
9
 
10
10
  @column({
11
- primary: true, type: "string", beforeSave(value) {
11
+ primary: true, type: 'string', beforeSave(value) {
12
12
  return value ?? uuidv4();
13
- }
13
+ },
14
14
  })
15
15
  id!: string;
16
16
 
17
- @column({ type: "string" })
17
+ @column({ type: 'string' })
18
18
  organizationId: string;
19
19
 
20
- @column({ type: "string" })
21
- periodId: string
20
+ @column({ type: 'string' })
21
+ periodId: string;
22
22
 
23
- @column({ type: "json", decoder: OrganizationRegistrationPeriodSettings })
24
- settings = OrganizationRegistrationPeriodSettings.create({})
23
+ @column({ type: 'json', decoder: OrganizationRegistrationPeriodSettings })
24
+ settings = OrganizationRegistrationPeriodSettings.create({});
25
25
 
26
26
  @column({
27
- type: "datetime", beforeSave(old?: any) {
27
+ type: 'datetime', beforeSave(old?: any) {
28
28
  if (old !== undefined) {
29
29
  return old;
30
30
  }
31
- const date = new Date()
32
- date.setMilliseconds(0)
33
- return date
34
- }
31
+ const date = new Date();
32
+ date.setMilliseconds(0);
33
+ return date;
34
+ },
35
35
  })
36
- createdAt: Date
36
+ createdAt: Date;
37
37
 
38
38
  @column({
39
- type: "datetime", beforeSave() {
40
- const date = new Date()
41
- date.setMilliseconds(0)
42
- return date
39
+ type: 'datetime', beforeSave() {
40
+ const date = new Date();
41
+ date.setMilliseconds(0);
42
+ return date;
43
43
  },
44
- skipUpdate: true
44
+ skipUpdate: true,
45
45
  })
46
- updatedAt: Date
46
+ updatedAt: Date;
47
47
 
48
- @column({ type: "json", decoder: SetupSteps })
49
- setupSteps = SetupSteps.create({})
48
+ @column({ type: 'json', decoder: SetupSteps })
49
+ setupSteps = SetupSteps.create({});
50
50
 
51
51
  getStructure(this: OrganizationRegistrationPeriod, period: RegistrationPeriod, groups: Group[]) {
52
52
  return OrganizationRegistrationPeriodStruct.create({
53
53
  ...this,
54
54
  period: period.getStructure(),
55
- groups: groups.map(g => g.getStructure()).sort(GroupStruct.defaultSort)
56
- })
55
+ groups: groups.map(g => g.getStructure()).sort(GroupStruct.defaultSort),
56
+ });
57
57
  }
58
58
 
59
59
  getPrivateStructure(this: OrganizationRegistrationPeriod, period: RegistrationPeriod, groups: Group[]) {
60
60
  return OrganizationRegistrationPeriodStruct.create({
61
61
  ...this,
62
62
  period: period.getStructure(),
63
- groups: groups.map(g => g.getPrivateStructure()).sort(GroupStruct.defaultSort)
64
- })
63
+ groups: groups.map(g => g.getPrivateStructure()).sort(GroupStruct.defaultSort),
64
+ });
65
65
  }
66
66
 
67
- async cleanCategories(groups: {id: string}[]) {
68
- const reachable = new Map<string, boolean>()
69
- const queue = [this.settings.rootCategoryId]
70
- reachable.set(this.settings.rootCategoryId, true)
67
+ async cleanCategories(groups: { id: string }[]) {
68
+ const reachable = new Map<string, boolean>();
69
+ const queue = [this.settings.rootCategoryId];
70
+ reachable.set(this.settings.rootCategoryId, true);
71
71
  let shouldSave = false;
72
72
 
73
- const usedGroupIds = new Set<string>()
73
+ const usedGroupIds = new Set<string>();
74
74
 
75
75
  while (queue.length > 0) {
76
- const id = queue.shift()
76
+ const id = queue.shift();
77
77
  if (!id) {
78
- break
78
+ break;
79
79
  }
80
80
 
81
- const category = this.settings.categories.find(c => c.id === id)
81
+ const category = this.settings.categories.find(c => c.id === id);
82
82
  if (!category) {
83
- continue
83
+ continue;
84
84
  }
85
85
 
86
86
  for (const i of category.categoryIds) {
87
87
  if (!reachable.get(i)) {
88
- reachable.set(i, true)
89
- queue.push(i)
88
+ reachable.set(i, true);
89
+ queue.push(i);
90
90
  }
91
91
  }
92
92
 
93
93
  // Remove groupIds that no longer exist or are in a different category already
94
- let filtered = category.groupIds.filter(id => !!groups.find(g => g.id === id) && !usedGroupIds.has(id))
94
+ let filtered = category.groupIds.filter(id => !!groups.find(g => g.id === id) && !usedGroupIds.has(id));
95
95
 
96
96
  // Remove duplicate groups
97
- filtered = Formatter.uniqueArray(filtered)
97
+ filtered = Formatter.uniqueArray(filtered);
98
98
 
99
99
  if (filtered.length !== category.groupIds.length) {
100
100
  shouldSave = true;
101
- console.log("Deleted "+ (category.groupIds.length - filtered.length) +" group ids from category " + category.id + ", in organization period "+this.id)
102
- category.groupIds = filtered
101
+ console.log('Deleted ' + (category.groupIds.length - filtered.length) + ' group ids from category ' + category.id + ', in organization period ' + this.id);
102
+ category.groupIds = filtered;
103
103
  }
104
104
 
105
105
  for (const groupId of category.groupIds) {
106
- usedGroupIds.add(groupId)
106
+ usedGroupIds.add(groupId);
107
107
  }
108
108
  }
109
109
 
110
- const reachableCategoryIds = [...reachable.keys()]
110
+ const reachableCategoryIds = [...reachable.keys()];
111
111
 
112
112
  // Delete all categories that are not reachable anymore
113
113
  const beforeCount = this.settings.categories.length;
114
- this.settings.categories = this.settings.categories.filter(c => reachableCategoryIds.includes(c.id))
114
+ this.settings.categories = this.settings.categories.filter(c => reachableCategoryIds.includes(c.id));
115
115
 
116
116
  if (this.settings.categories.length !== beforeCount) {
117
- console.log("Deleted "+ (beforeCount - this.settings.categories.length) +" categories from organizaton period "+this.id)
118
- await this.save()
119
- } else {
117
+ console.log('Deleted ' + (beforeCount - this.settings.categories.length) + ' categories from organizaton period ' + this.id);
118
+ await this.save();
119
+ }
120
+ else {
120
121
  if (shouldSave) {
121
- await this.save()
122
+ await this.save();
122
123
  }
123
124
  }
124
125
  }
125
-
126
126
  }
@@ -1,12 +1,11 @@
1
+ import { column, Database, ManyToOneRelation, Model } from '@simonbackx/simple-database';
2
+ import { I18n } from '@stamhoofd/backend-i18n';
3
+ import basex from 'base-x';
4
+ import crypto from 'crypto';
1
5
 
2
- import { column, Database, ManyToOneRelation, Model } from "@simonbackx/simple-database";
3
- import { I18n } from "@stamhoofd/backend-i18n";
4
- import basex from "base-x";
5
- import crypto from "crypto";
6
-
7
- import { Organization, User } from "./";
8
- const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
9
- const bs58 = basex(ALPHABET)
6
+ import { Organization, User } from './';
7
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
8
+ const bs58 = basex(ALPHABET);
10
9
 
11
10
  export type PasswordTokenWithUser = PasswordToken & { user: User };
12
11
 
@@ -23,47 +22,47 @@ async function randomBytes(size: number): Promise<Buffer> {
23
22
  }
24
23
 
25
24
  export class PasswordToken extends Model {
26
- static table = "password_tokens";
27
-
25
+ static table = 'password_tokens';
26
+
28
27
  // Columns
29
- @column({ primary: true, type: "string" })
28
+ @column({ primary: true, type: 'string' })
30
29
  token: string;
31
30
 
32
- @column({ type: "datetime" })
31
+ @column({ type: 'datetime' })
33
32
  validUntil: Date;
34
33
 
35
34
  @column({
36
- type: "datetime", beforeSave(old?: any) {
35
+ type: 'datetime', beforeSave(old?: any) {
37
36
  if (old !== undefined) {
38
37
  return old;
39
38
  }
40
- const date = new Date()
41
- date.setMilliseconds(0)
42
- return date
43
- }
39
+ const date = new Date();
40
+ date.setMilliseconds(0);
41
+ return date;
42
+ },
44
43
  })
45
- createdAt: Date
44
+ createdAt: Date;
46
45
 
47
- @column({ type: "string", foreignKey: PasswordToken.user })
46
+ @column({ type: 'string', foreignKey: PasswordToken.user })
48
47
  userId: string;
49
48
 
50
- static user = new ManyToOneRelation(User, "user");
49
+ static user = new ManyToOneRelation(User, 'user');
51
50
 
52
51
  isExpired(): boolean {
53
- return this.validUntil < new Date()
52
+ return this.validUntil < new Date();
54
53
  }
55
-
54
+
56
55
  /**
57
56
  * Get a token
58
- * @param token
57
+ * @param token
59
58
  * @param ignoreExpireDate: do not return if it is expired
60
59
  */
61
60
  static async getToken(token: string, ignoreExpireDate = false): Promise<PasswordTokenWithUser | undefined> {
62
61
  const [rows] = await Database.select(
63
- `SELECT ${this.getDefaultSelect()}, ${User.getDefaultSelect("user")} FROM ${
62
+ `SELECT ${this.getDefaultSelect()}, ${User.getDefaultSelect('user')} FROM ${
64
63
  this.table
65
- } ${PasswordToken.user.joinQuery(this.table, "user")} WHERE ${this.primary.name} = ? LIMIT 1 `,
66
- [token]
64
+ } ${PasswordToken.user.joinQuery(this.table, 'user')} WHERE ${this.primary.name} = ? LIMIT 1 `,
65
+ [token],
67
66
  );
68
67
 
69
68
  if (rows.length == 0) {
@@ -78,13 +77,13 @@ export class PasswordToken extends Model {
78
77
 
79
78
  if (!ignoreExpireDate && passwordToken.isExpired()) {
80
79
  // If the refresh token is invalid, do not return it
81
- return undefined
80
+ return undefined;
82
81
  }
83
82
 
84
- const user = User.fromRow(rows[0]["user"]) || null;
83
+ const user = User.fromRow(rows[0]['user']) || null;
85
84
 
86
85
  if (!user) {
87
- console.error("Password token without a valid user!");
86
+ console.error('Password token without a valid user!');
88
87
  return undefined;
89
88
  }
90
89
 
@@ -98,8 +97,9 @@ export class PasswordToken extends Model {
98
97
  const token = new PasswordToken().setRelation(PasswordToken.user, user);
99
98
 
100
99
  if (validUntil) {
101
- token.validUntil = new Date(validUntil)
102
- } else {
100
+ token.validUntil = new Date(validUntil);
101
+ }
102
+ else {
103
103
  token.validUntil = new Date();
104
104
  token.validUntil.setTime(token.validUntil.getTime() + 3 * 3600 * 1000);
105
105
  }
@@ -109,31 +109,31 @@ export class PasswordToken extends Model {
109
109
  return token;
110
110
  }
111
111
 
112
- static async getPasswordRecoveryUrl(user: User, organization: Organization|null, i18n: I18n, validUntil?: Date) {
112
+ static async getPasswordRecoveryUrl(user: User, organization: Organization | null, i18n: I18n, validUntil?: Date) {
113
113
  if (user.organizationId !== null && ((user.organizationId ?? null) !== (organization?.id ?? null))) {
114
- throw new Error('Unexpected mismatch in organization id for PasswordToken')
114
+ throw new Error('Unexpected mismatch in organization id for PasswordToken');
115
115
  }
116
116
  // Send an e-mail to say you already have an account + follow password forgot flow
117
- const token = await PasswordToken.createToken(user, validUntil)
117
+ const token = await PasswordToken.createToken(user, validUntil);
118
118
 
119
119
  let host: string;
120
- if (user.permissions || !organization || STAMHOOFD.userMode === "platform") {
121
- host = "https://"+(STAMHOOFD.domains.dashboard)+"/"+i18n.locale
122
- return host+"/reset-password"+((user.organizationId || organization) ? ("/"+encodeURIComponent(user.organizationId ?? organization!.id)) : "")+"?token="+encodeURIComponent(token.token);
120
+ if (user.permissions || !organization || STAMHOOFD.userMode === 'platform') {
121
+ host = 'https://' + (STAMHOOFD.domains.dashboard) + '/' + i18n.locale;
122
+ return host + '/reset-password' + ((user.organizationId || organization) ? ('/' + encodeURIComponent(user.organizationId ?? organization!.id)) : '') + '?token=' + encodeURIComponent(token.token);
123
123
  }
124
124
 
125
- host = "https://"+organization.getHost(i18n)
126
- return host+"/reset-password?token="+encodeURIComponent(token.token);
125
+ host = 'https://' + organization.getHost(i18n);
126
+ return host + '/reset-password?token=' + encodeURIComponent(token.token);
127
127
  }
128
128
 
129
129
  static async getMagicSignInUrl(user: User, organization: Organization) {
130
130
  // For now we don't add a token yet for security. We might add some sort of email validation thing later on
131
- const host = "https://"+organization.getHost()
132
- return Promise.resolve(host+"/login"+"?email="+encodeURIComponent(user.email)+"&hasAccount="+(user.hasAccount() ? 1 : 0));
131
+ const host = 'https://' + organization.getHost();
132
+ return Promise.resolve(host + '/login' + '?email=' + encodeURIComponent(user.email) + '&hasAccount=' + (user.hasAccount() ? 1 : 0));
133
133
  }
134
134
 
135
135
  static async clearFor(userId: string) {
136
136
  const query = `DELETE from ${this.table} where userId = ?`;
137
- await Database.delete(query, [userId])
137
+ await Database.delete(query, [userId]);
138
138
  }
139
139
  }
@@ -1,127 +1,128 @@
1
- import { column, Model } from "@simonbackx/simple-database";
1
+ import { column, Model } from '@simonbackx/simple-database';
2
2
  import { SimpleError } from '@simonbackx/simple-errors';
3
3
  import { PayconiqAccount, PaymentStatus, Version } from '@stamhoofd/structures';
4
4
  import { IncomingMessage } from 'http';
5
- import https from "https";
6
- import { v4 as uuidv4 } from "uuid";
5
+ import https from 'https';
6
+ import { v4 as uuidv4 } from 'uuid';
7
7
 
8
8
  import { Organization, Payment } from './';
9
9
 
10
10
  export class PayconiqPayment extends Model {
11
- static table = "payconiq_payments";
11
+ static table = 'payconiq_payments';
12
12
 
13
13
  @column({
14
- primary: true, type: "string", beforeSave(value) {
14
+ primary: true, type: 'string', beforeSave(value) {
15
15
  return value ?? uuidv4();
16
- }
16
+ },
17
17
  })
18
18
  id!: string;
19
19
 
20
- @column({ type: "string" })
20
+ @column({ type: 'string' })
21
21
  paymentId: string;
22
22
 
23
- @column({ type: "string" })
23
+ @column({ type: 'string' })
24
24
  payconiqId: string;
25
25
 
26
26
  async getStatus(organization: Organization): Promise<PaymentStatus> {
27
- const apiKey = organization.privateMeta.payconiqApiKey
27
+ const apiKey = organization.privateMeta.payconiqApiKey;
28
28
  if (!apiKey) {
29
29
  throw new SimpleError({
30
- code: "",
31
- message: "Payconiq API key missing to check the status of the payment"
32
- })
30
+ code: '',
31
+ message: 'Payconiq API key missing to check the status of the payment',
32
+ });
33
33
  }
34
34
 
35
- const response = await PayconiqPayment.request("GET", "/v3/payments/"+this.payconiqId, {}, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment != 'production')
35
+ const response = await PayconiqPayment.request('GET', '/v3/payments/' + this.payconiqId, {}, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment !== 'production');
36
36
  if (response.status) {
37
37
  switch (response.status) {
38
- case "AUTHORIZED": return PaymentStatus.Pending;
39
- case "PENDING": return PaymentStatus.Created;
38
+ case 'AUTHORIZED': return PaymentStatus.Pending;
39
+ case 'PENDING': return PaymentStatus.Created;
40
40
 
41
- case "IDENTIFIED": return PaymentStatus.Pending; // Code has been scanned!
41
+ case 'IDENTIFIED': return PaymentStatus.Pending; // Code has been scanned!
42
42
 
43
- case "AUTHORIZATION_FAILED": return PaymentStatus.Failed;
44
- case "EXPIRED": return PaymentStatus.Failed;
45
- case "FAILED": return PaymentStatus.Failed;
46
- case "CANCELLED": return PaymentStatus.Failed;
43
+ case 'AUTHORIZATION_FAILED': return PaymentStatus.Failed;
44
+ case 'EXPIRED': return PaymentStatus.Failed;
45
+ case 'FAILED': return PaymentStatus.Failed;
46
+ case 'CANCELLED': return PaymentStatus.Failed;
47
47
 
48
- case "SUCCEEDED": return PaymentStatus.Succeeded;
48
+ case 'SUCCEEDED': return PaymentStatus.Succeeded;
49
49
  }
50
- return PaymentStatus.Pending // default to pending
50
+ return PaymentStatus.Pending; // default to pending
51
51
  }
52
52
  throw new SimpleError({
53
- code: "",
54
- message: "Status missing in response"
55
- })
53
+ code: '',
54
+ message: 'Status missing in response',
55
+ });
56
56
  }
57
57
 
58
58
  async cancel(organization: Organization): Promise<boolean> {
59
- const apiKey = organization.privateMeta.payconiqApiKey
59
+ const apiKey = organization.privateMeta.payconiqApiKey;
60
60
  if (!apiKey) {
61
61
  throw new SimpleError({
62
- code: "",
63
- message: "Payconiq API key missing to check the status of the payment"
64
- })
62
+ code: '',
63
+ message: 'Payconiq API key missing to check the status of the payment',
64
+ });
65
65
  }
66
66
 
67
67
  // Throws on failure
68
68
  try {
69
- await PayconiqPayment.request("DELETE", "/v3/payments/"+this.payconiqId, {}, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment != 'production')
69
+ await PayconiqPayment.request('DELETE', '/v3/payments/' + this.payconiqId, {}, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment !== 'production');
70
70
  return true;
71
- } catch (e) {
72
- console.error('Failed to cancel Payconiq payment', this.id, this.payconiqId, e)
71
+ }
72
+ catch (e) {
73
+ console.error('Failed to cancel Payconiq payment', this.id, this.payconiqId, e);
73
74
  return false;
74
75
  }
75
76
  }
76
77
 
77
- static async createTest(organization: Organization, payconiqAccount: PayconiqAccount): Promise<undefined|object> {
78
- const apiKey = payconiqAccount.apiKey
78
+ static async createTest(organization: Organization, payconiqAccount: PayconiqAccount): Promise<undefined | object> {
79
+ const apiKey = payconiqAccount.apiKey;
79
80
  if (!apiKey) {
80
- return
81
+ return;
81
82
  }
82
83
 
83
84
  try {
84
- const response = await this.request("POST", "/v3/payments", {
85
- reference: "test-"+(new Date().getTime()), // 36 chars, max length is 35...
85
+ const response = await this.request('POST', '/v3/payments', {
86
+ reference: 'test-' + (new Date().getTime()), // 36 chars, max length is 35...
86
87
  amount: 1,
87
- currency: "EUR",
88
- callbackUrl: 'https://'+organization.getApiHost(),
89
- description: "Key validation test",
88
+ currency: 'EUR',
89
+ callbackUrl: 'https://' + organization.getApiHost(),
90
+ description: 'Key validation test',
90
91
 
91
- }, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment != 'production')
92
+ }, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment !== 'production');
92
93
  return response;
93
- } catch (e) {
94
+ }
95
+ catch (e) {
94
96
  return;
95
97
  }
96
98
  }
97
99
 
98
-
99
100
  static async createPayment(payment: Payment, organization: Organization, description: string, returnUrl?: string, callbackUrl?: string) {
100
- const apiKey = organization.privateMeta.payconiqApiKey
101
+ const apiKey = organization.privateMeta.payconiqApiKey;
101
102
  if (!apiKey) {
102
103
  throw new SimpleError({
103
- code: "",
104
- message: "Betaling via Payconiq is tijdelijk onbeschikbaar"
105
- })
104
+ code: '',
105
+ message: 'Betaling via Payconiq is tijdelijk onbeschikbaar',
106
+ });
106
107
  }
107
108
 
108
- const response = await this.request("POST", "/v3/payments", {
109
- reference: payment.id.replace("-", ""), // 36 chars, max length is 35...
109
+ const response = await this.request('POST', '/v3/payments', {
110
+ reference: payment.id.replace('-', ''), // 36 chars, max length is 35...
110
111
  amount: payment.price,
111
- currency: "EUR",
112
- callbackUrl: callbackUrl ?? 'https://'+organization.getApiHost()+"/v"+Version+"/payments/"+encodeURIComponent(payment.id)+"?exchange=true",
112
+ currency: 'EUR',
113
+ callbackUrl: callbackUrl ?? 'https://' + organization.getApiHost() + '/v' + Version + '/payments/' + encodeURIComponent(payment.id) + '?exchange=true',
113
114
  returnUrl,
114
- description
115
- }, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment != 'production')
115
+ description,
116
+ }, apiKey, organization.privateMeta.useTestPayments ?? STAMHOOFD.environment !== 'production');
116
117
 
117
- const payconiqPayment = new PayconiqPayment()
118
- payconiqPayment.paymentId = payment.id
119
- payconiqPayment.payconiqId = response.paymentId
118
+ const payconiqPayment = new PayconiqPayment();
119
+ payconiqPayment.paymentId = payment.id;
120
+ payconiqPayment.payconiqId = response.paymentId;
120
121
 
121
122
  // Read link (currently we use checkout!)
122
123
  let link = response._links.checkout.href as string;
123
124
 
124
- if (organization.privateMeta.useTestPayments ?? STAMHOOFD.environment != 'production') {
125
+ if (organization.privateMeta.useTestPayments ?? STAMHOOFD.environment !== 'production') {
125
126
  // For checkout only!
126
127
  // We get the wrong link in development mode
127
128
  link = link.replace('https://payconiq.com/', 'https://ext.payconiq.com/');
@@ -138,20 +139,20 @@ export class PayconiqPayment extends Model {
138
139
  private static request(method: string, path: string, data = {}, auth: string | null = null, testMode: boolean): Promise<any> {
139
140
  return new Promise((resolve, reject) => {
140
141
  const jsonData = JSON.stringify(data);
141
- const hostname = !testMode ? "api.payconiq.com" : "api.ext.payconiq.com"
142
- const base = "https://"+hostname
142
+ const hostname = !testMode ? 'api.payconiq.com' : 'api.ext.payconiq.com';
143
+ const base = 'https://' + hostname;
143
144
 
144
145
  // Log all communication
145
- console.log(method+" "+base+path+"\n"+jsonData);
146
+ console.log(method + ' ' + base + path + '\n' + jsonData);
146
147
  console.log(jsonData);
147
148
 
148
149
  const headers = {
149
- "Content-Type": "application/json; charset=utf-8",
150
- "Content-Length": Buffer.byteLength(jsonData),
150
+ 'Content-Type': 'application/json; charset=utf-8',
151
+ 'Content-Length': Buffer.byteLength(jsonData),
151
152
  };
152
153
 
153
154
  if (auth) {
154
- headers["Authorization"] = "Bearer "+auth
155
+ headers['Authorization'] = 'Bearer ' + auth;
155
156
  }
156
157
 
157
158
  const req = https.request(
@@ -168,14 +169,14 @@ export class PayconiqPayment extends Model {
168
169
 
169
170
  const chunks: any[] = [];
170
171
 
171
- response.on("data", (chunk) => {
172
+ response.on('data', (chunk) => {
172
173
  chunks.push(chunk);
173
174
  });
174
175
 
175
- response.on("end", () => {
176
+ response.on('end', () => {
176
177
  try {
177
178
  if (!response.statusCode) {
178
- reject(new Error("Unexpected order of events"));
179
+ reject(new Error('Unexpected order of events'));
179
180
  return;
180
181
  }
181
182
  const body = Buffer.concat(chunks).toString();
@@ -189,20 +190,22 @@ export class PayconiqPayment extends Model {
189
190
  let json: any;
190
191
  try {
191
192
  json = JSON.parse(body);
192
- } catch (error) {
193
+ }
194
+ catch (error) {
193
195
  console.error(error);
194
-
196
+
195
197
  // invalid json
196
198
  if (response.statusCode < 200 || response.statusCode >= 300) {
197
199
  if (body.length == 0) {
198
200
  console.error(response.statusCode);
199
- reject(new Error("Status " + response.statusCode));
201
+ reject(new Error('Status ' + response.statusCode));
200
202
  return;
201
203
  }
202
- console.error(response.statusCode + " " + body);
204
+ console.error(response.statusCode + ' ' + body);
203
205
  reject(new Error(body));
204
206
  return;
205
- } else {
207
+ }
208
+ else {
206
209
  // something wrong: throw parse error
207
210
  reject(error);
208
211
  return;
@@ -211,25 +214,26 @@ export class PayconiqPayment extends Model {
211
214
 
212
215
  if (response.statusCode < 200 || response.statusCode >= 300) {
213
216
  console.error(body);
214
- reject(new Error(response.statusCode + " " + response.statusMessage));
217
+ reject(new Error(response.statusCode + ' ' + response.statusMessage));
215
218
  return;
216
219
  }
217
220
 
218
221
  resolve(json);
219
- } catch (error) {
222
+ }
223
+ catch (error) {
220
224
  console.error(error);
221
225
  reject(error);
222
226
  }
223
227
  });
224
- }
228
+ },
225
229
  );
226
230
 
227
231
  // use its "timeout" event to abort the request
228
- req.on("timeout", () => {
232
+ req.on('timeout', () => {
229
233
  req.abort();
230
234
  });
231
235
 
232
- req.on("error", (error) => {
236
+ req.on('error', (error) => {
233
237
  console.error(error);
234
238
  reject(error);
235
239
  });