zudello-integration-sdk 1.0.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 (201) hide show
  1. package/README.md +1 -0
  2. package/package.json +23 -0
  3. package/src/index.js +62 -0
  4. package/src/integrations/samples/bc-zudello/account.js +40 -0
  5. package/src/integrations/samples/bc-zudello/accountingPeriod.js +52 -0
  6. package/src/integrations/samples/bc-zudello/currency.js +42 -0
  7. package/src/integrations/samples/bc-zudello/customer.js +45 -0
  8. package/src/integrations/samples/bc-zudello/dimension.js +85 -0
  9. package/src/integrations/samples/bc-zudello/employee.js +38 -0
  10. package/src/integrations/samples/bc-zudello/fixedAsset.js +48 -0
  11. package/src/integrations/samples/bc-zudello/item.js +45 -0
  12. package/src/integrations/samples/bc-zudello/itemCategory.js +37 -0
  13. package/src/integrations/samples/bc-zudello/location.js +37 -0
  14. package/src/integrations/samples/bc-zudello/paymentMethod.js +38 -0
  15. package/src/integrations/samples/bc-zudello/paymentTerm.js +41 -0
  16. package/src/integrations/samples/bc-zudello/project.js +38 -0
  17. package/src/integrations/samples/bc-zudello/purchaseCredit.js +109 -0
  18. package/src/integrations/samples/bc-zudello/purchaseInvoice.js +138 -0
  19. package/src/integrations/samples/bc-zudello/purchaseOrder.js +150 -0
  20. package/src/integrations/samples/bc-zudello/purchaseOrderFetch.js +100 -0
  21. package/src/integrations/samples/bc-zudello/supplier.js +40 -0
  22. package/src/integrations/samples/bc-zudello/taxRate.js +39 -0
  23. package/src/integrations/samples/bc-zudello/uom.js +42 -0
  24. package/src/integrations/samples/dear-zudello/account.js +20 -0
  25. package/src/integrations/samples/dear-zudello/customer.js +23 -0
  26. package/src/integrations/samples/dear-zudello/item.js +30 -0
  27. package/src/integrations/samples/dear-zudello/location.js +19 -0
  28. package/src/integrations/samples/dear-zudello/salesOrder.js +126 -0
  29. package/src/integrations/samples/dear-zudello/supplier.js +23 -0
  30. package/src/integrations/samples/dear-zudello/taxRate.js +19 -0
  31. package/src/integrations/samples/fo-zudello/account.js +20 -0
  32. package/src/integrations/samples/fo-zudello/costCentre.js +20 -0
  33. package/src/integrations/samples/fo-zudello/department.js +20 -0
  34. package/src/integrations/samples/fo-zudello/item.js +21 -0
  35. package/src/integrations/samples/fo-zudello/location.js +20 -0
  36. package/src/integrations/samples/fo-zudello/project.js +18 -0
  37. package/src/integrations/samples/fo-zudello/subsidiary.js +20 -0
  38. package/src/integrations/samples/fo-zudello/supplier.js +23 -0
  39. package/src/integrations/samples/fo-zudello/taxRate.js +20 -0
  40. package/src/integrations/samples/intacct-zudello/account.js +56 -0
  41. package/src/integrations/samples/intacct-zudello/accountGroup.js +54 -0
  42. package/src/integrations/samples/intacct-zudello/accountingPeriod.js +67 -0
  43. package/src/integrations/samples/intacct-zudello/apBill.js +146 -0
  44. package/src/integrations/samples/intacct-zudello/apBillFetch.js +195 -0
  45. package/src/integrations/samples/intacct-zudello/costCentre.js +54 -0
  46. package/src/integrations/samples/intacct-zudello/costType.js +54 -0
  47. package/src/integrations/samples/intacct-zudello/customerCategory.js +54 -0
  48. package/src/integrations/samples/intacct-zudello/customerGroup.js +54 -0
  49. package/src/integrations/samples/intacct-zudello/department.js +54 -0
  50. package/src/integrations/samples/intacct-zudello/employee.js +51 -0
  51. package/src/integrations/samples/intacct-zudello/expense-create.js +156 -0
  52. package/src/integrations/samples/intacct-zudello/item.js +64 -0
  53. package/src/integrations/samples/intacct-zudello/itemCategory.js +54 -0
  54. package/src/integrations/samples/intacct-zudello/itemGroup.js +54 -0
  55. package/src/integrations/samples/intacct-zudello/location.js +54 -0
  56. package/src/integrations/samples/intacct-zudello/paymentTerm.js +56 -0
  57. package/src/integrations/samples/intacct-zudello/project.js +54 -0
  58. package/src/integrations/samples/intacct-zudello/projectGroup.js +54 -0
  59. package/src/integrations/samples/intacct-zudello/projectTask.js +40 -0
  60. package/src/integrations/samples/intacct-zudello/subsidiary.js +54 -0
  61. package/src/integrations/samples/intacct-zudello/supplier.js +168 -0
  62. package/src/integrations/samples/intacct-zudello/supplierCategory.js +54 -0
  63. package/src/integrations/samples/intacct-zudello/supplierGroup.js +54 -0
  64. package/src/integrations/samples/intacct-zudello/supplierV2.js +64 -0
  65. package/src/integrations/samples/intacct-zudello/taxRate.js +34 -0
  66. package/src/integrations/samples/intacct-zudello/taxSolution.js +35 -0
  67. package/src/integrations/samples/intacct-zudello/uom.js +37 -0
  68. package/src/integrations/samples/intacct-zudello/warehouse.js +54 -0
  69. package/src/integrations/samples/intacct-zudello/zone.js +54 -0
  70. package/src/integrations/samples/nexvia-zudello/account.js +20 -0
  71. package/src/integrations/samples/nexvia-zudello/costCentre.js +19 -0
  72. package/src/integrations/samples/nexvia-zudello/costType.js +19 -0
  73. package/src/integrations/samples/nexvia-zudello/currency.js +20 -0
  74. package/src/integrations/samples/nexvia-zudello/department.js +20 -0
  75. package/src/integrations/samples/nexvia-zudello/itemCategory.js +19 -0
  76. package/src/integrations/samples/nexvia-zudello/location.js +20 -0
  77. package/src/integrations/samples/nexvia-zudello/project.js +20 -0
  78. package/src/integrations/samples/nexvia-zudello/supplier.js +21 -0
  79. package/src/integrations/samples/nexvia-zudello/taxRate.js +21 -0
  80. package/src/integrations/samples/nexvia-zudello/uom.js +19 -0
  81. package/src/integrations/samples/nexvia-zudello/zone.js +20 -0
  82. package/src/integrations/samples/zenoti-zudello/location.js +20 -0
  83. package/src/integrations/samples/zenoti-zudello/product.js +32 -0
  84. package/src/integrations/samples/zenoti-zudello/purchaseOrder.js +193 -0
  85. package/src/sdk/Auth.js +42 -0
  86. package/src/sdk/Base.js +118 -0
  87. package/src/sdk/BusinessCentral.js +31 -0
  88. package/src/sdk/Dear.js +31 -0
  89. package/src/sdk/Fo.js +31 -0
  90. package/src/sdk/Intacct.js +103 -0
  91. package/src/sdk/JobReady.js +31 -0
  92. package/src/sdk/MYOBAcumatica.js +33 -0
  93. package/src/sdk/Netsuite.js +31 -0
  94. package/src/sdk/NetsuiteSOAP.js +92 -0
  95. package/src/sdk/Nexvia.js +31 -0
  96. package/src/sdk/RetailExpress.js +31 -0
  97. package/src/sdk/Sybiz.js +31 -0
  98. package/src/sdk/Zenoti.js +31 -0
  99. package/src/sdk/Zudello.js +206 -0
  100. package/src/sdk/submodules/bc/Universal.js +109 -0
  101. package/src/sdk/submodules/dear/Universal.js +110 -0
  102. package/src/sdk/submodules/fo/Universal.js +111 -0
  103. package/src/sdk/submodules/intacct/Account.js +31 -0
  104. package/src/sdk/submodules/intacct/AccountGroup.js +31 -0
  105. package/src/sdk/submodules/intacct/AccountingPeriod.js +31 -0
  106. package/src/sdk/submodules/intacct/ApAdjustment.js +35 -0
  107. package/src/sdk/submodules/intacct/ApBill.js +52 -0
  108. package/src/sdk/submodules/intacct/ApTerm.js +31 -0
  109. package/src/sdk/submodules/intacct/ArAdjustment.js +35 -0
  110. package/src/sdk/submodules/intacct/ArInvoice.js +35 -0
  111. package/src/sdk/submodules/intacct/ArTerm.js +31 -0
  112. package/src/sdk/submodules/intacct/Budget.js +31 -0
  113. package/src/sdk/submodules/intacct/Class.js +31 -0
  114. package/src/sdk/submodules/intacct/CostType.js +31 -0
  115. package/src/sdk/submodules/intacct/Customer.js +31 -0
  116. package/src/sdk/submodules/intacct/CustomerGroup.js +31 -0
  117. package/src/sdk/submodules/intacct/CustomerType.js +31 -0
  118. package/src/sdk/submodules/intacct/Department.js +31 -0
  119. package/src/sdk/submodules/intacct/Employee.js +31 -0
  120. package/src/sdk/submodules/intacct/Entity.js +31 -0
  121. package/src/sdk/submodules/intacct/File.js +26 -0
  122. package/src/sdk/submodules/intacct/Item.js +31 -0
  123. package/src/sdk/submodules/intacct/ItemGroup.js +31 -0
  124. package/src/sdk/submodules/intacct/Location.js +31 -0
  125. package/src/sdk/submodules/intacct/PoDocument.js +52 -0
  126. package/src/sdk/submodules/intacct/ProductLine.js +31 -0
  127. package/src/sdk/submodules/intacct/Project.js +31 -0
  128. package/src/sdk/submodules/intacct/ProjectGroup.js +31 -0
  129. package/src/sdk/submodules/intacct/Task.js +31 -0
  130. package/src/sdk/submodules/intacct/TaxDetail.js +31 -0
  131. package/src/sdk/submodules/intacct/TaxGroups.js +31 -0
  132. package/src/sdk/submodules/intacct/TaxSolution.js +31 -0
  133. package/src/sdk/submodules/intacct/Universal.js +139 -0
  134. package/src/sdk/submodules/intacct/Uom.js +31 -0
  135. package/src/sdk/submodules/intacct/Vendor.js +31 -0
  136. package/src/sdk/submodules/intacct/VendorGroup.js +31 -0
  137. package/src/sdk/submodules/intacct/VendorTypes.js +31 -0
  138. package/src/sdk/submodules/intacct/Warehouse.js +31 -0
  139. package/src/sdk/submodules/intacct/Zone.js +31 -0
  140. package/src/sdk/submodules/intacct/apAdjustment/Item.js +31 -0
  141. package/src/sdk/submodules/intacct/apBill/Item.js +31 -0
  142. package/src/sdk/submodules/intacct/arAdjustment/Item.js +31 -0
  143. package/src/sdk/submodules/intacct/arInvoice/Item.js +31 -0
  144. package/src/sdk/submodules/intacct/poDocument/Item.js +31 -0
  145. package/src/sdk/submodules/jobready/Universal.js +107 -0
  146. package/src/sdk/submodules/myobAcumatica/OData.js +109 -0
  147. package/src/sdk/submodules/myobAcumatica/Universal.js +109 -0
  148. package/src/sdk/submodules/netsuite/Universal.js +97 -0
  149. package/src/sdk/submodules/netsuite-soap/PurchaseOrder.js +39 -0
  150. package/src/sdk/submodules/netsuite-soap/Receipt.js +39 -0
  151. package/src/sdk/submodules/netsuite-soap/Universal.js +124 -0
  152. package/src/sdk/submodules/netsuite-soap/UniversalTransaction.js +138 -0
  153. package/src/sdk/submodules/netsuite-soap/VendorBill.js +41 -0
  154. package/src/sdk/submodules/netsuite-soap/VendorCredit.js +39 -0
  155. package/src/sdk/submodules/nexvia/Universal.js +108 -0
  156. package/src/sdk/submodules/retailExpress/Universal.js +107 -0
  157. package/src/sdk/submodules/sybiz/Universal.js +108 -0
  158. package/src/sdk/submodules/zenoti/Universal.js +110 -0
  159. package/src/sdk/submodules/zudello/Account.js +63 -0
  160. package/src/sdk/submodules/zudello/AccountGroup.js +63 -0
  161. package/src/sdk/submodules/zudello/AccountingPeriod.js +63 -0
  162. package/src/sdk/submodules/zudello/CostCentre.js +63 -0
  163. package/src/sdk/submodules/zudello/CostType.js +63 -0
  164. package/src/sdk/submodules/zudello/Currency.js +63 -0
  165. package/src/sdk/submodules/zudello/Customer.js +63 -0
  166. package/src/sdk/submodules/zudello/CustomerCategory.js +63 -0
  167. package/src/sdk/submodules/zudello/CustomerGroup.js +63 -0
  168. package/src/sdk/submodules/zudello/Department.js +63 -0
  169. package/src/sdk/submodules/zudello/Employee.js +63 -0
  170. package/src/sdk/submodules/zudello/FixedAsset.js +63 -0
  171. package/src/sdk/submodules/zudello/Item.js +63 -0
  172. package/src/sdk/submodules/zudello/ItemCategory.js +63 -0
  173. package/src/sdk/submodules/zudello/ItemGroup.js +63 -0
  174. package/src/sdk/submodules/zudello/Location.js +63 -0
  175. package/src/sdk/submodules/zudello/PaymentMethod.js +63 -0
  176. package/src/sdk/submodules/zudello/PaymentTerm.js +63 -0
  177. package/src/sdk/submodules/zudello/Project.js +63 -0
  178. package/src/sdk/submodules/zudello/ProjectGroup.js +63 -0
  179. package/src/sdk/submodules/zudello/ProjectTask.js +63 -0
  180. package/src/sdk/submodules/zudello/PurchaseOrder.js +63 -0
  181. package/src/sdk/submodules/zudello/Subsidiary.js +63 -0
  182. package/src/sdk/submodules/zudello/Supplier.js +63 -0
  183. package/src/sdk/submodules/zudello/SupplierCategory.js +63 -0
  184. package/src/sdk/submodules/zudello/SupplierGroup.js +63 -0
  185. package/src/sdk/submodules/zudello/Universal.js +31 -0
  186. package/src/sdk/submodules/zudello/Uom.js +63 -0
  187. package/src/sdk/submodules/zudello/Warehouse.js +63 -0
  188. package/src/sdk/submodules/zudello/Zone.js +63 -0
  189. package/src/sdk/submodules/zudello/tax/Rate.js +63 -0
  190. package/src/sdk/submodules/zudello/tax/Solution.js +63 -0
  191. package/src/utils/apiInstance.js +198 -0
  192. package/src/utils/config.js +18 -0
  193. package/src/utils/logger.js +122 -0
  194. package/src/utils/metadata.js +102 -0
  195. package/src/utils/miscHelper.js +24 -0
  196. package/src/utils/modelHelper.js +140 -0
  197. package/src/utils/properties.js +32 -0
  198. package/src/utils/responseHandler.js +28 -0
  199. package/src/utils/s3Client.js +128 -0
  200. package/src/utils/tags.js +32 -0
  201. package/src/utils/validator.js +73 -0
@@ -0,0 +1,109 @@
1
+ 'use strict'
2
+
3
+ class ODataModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of MYOBAccumatica class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+ }
11
+
12
+ /**
13
+ * Universal Request By URL and Method.
14
+ * @param {string} url URL of request.
15
+ * @param {string} method Method of request.
16
+ * @param {object} qs Some available filters inside: offset, limit.
17
+ * @param {object} body Some available data inside.
18
+ * @returns {object} Universal Request Response.
19
+ */
20
+ async request ({ url, method, qs = {}, body = {} }) {
21
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method })
22
+
23
+ if (!validateIsEmpty.valid) {
24
+ return this.module.responseHandler.error(validateIsEmpty.errors)
25
+ }
26
+
27
+ return await this.module.makeRequest('GET', `${this.module.apiURL}/zintegrations/action/fd070d22-ec9e-4d85-82ab-6645d7fd4326`, {
28
+ mappable_parameters: {
29
+ url: {
30
+ value: url
31
+ },
32
+ method: {
33
+ value: method
34
+ },
35
+ qs: {
36
+ isMap: true,
37
+ value: JSON.stringify(qs)
38
+ },
39
+ body: {
40
+ isMap: true,
41
+ value: JSON.stringify(body)
42
+ }
43
+ }
44
+ })
45
+ }
46
+
47
+ /**
48
+ * Universal List By URL and Method.
49
+ * @param {string} url URL of listed data.
50
+ * @param {string} method Method of listed data.
51
+ * @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
52
+ * @returns {object} Universal List Response.
53
+ */
54
+ async list ({ url, method, qs = {} }) {
55
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method })
56
+
57
+ if (!validateIsEmpty.valid) {
58
+ return this.module.responseHandler.error(validateIsEmpty.errors)
59
+ }
60
+
61
+ if (!qs.$skip) {
62
+ qs.$skip = 0
63
+ }
64
+
65
+ if (!qs.$top) {
66
+ qs.$top = 100
67
+ }
68
+
69
+ return await this.request({ url, method, qs })
70
+ }
71
+
72
+ /**
73
+ * Universal Auto Pagination Listing By URL and Method.
74
+ * @param {string} url URL of listed data.
75
+ * @param {string} method Method of listed data.
76
+ * @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
77
+ * @returns {object} Auto Pagination responses.
78
+ */
79
+ async * autoPaginationList ({ url, method, qs = {} }) {
80
+ if (!qs.$skip) {
81
+ qs.$skip = 0
82
+ }
83
+
84
+ if (!qs.$top) {
85
+ qs.$top = 100
86
+ }
87
+
88
+ let response = await this.list({ url, method, qs })
89
+ let currentPageCount = response?.data?.value?.length
90
+ let currentOffset = qs.$skip
91
+
92
+ yield response
93
+
94
+ if (currentPageCount && currentPageCount === qs.$top) {
95
+ while (currentPageCount === qs.$top) {
96
+ currentOffset = currentOffset + qs.$top
97
+
98
+ qs.$skip = currentOffset
99
+
100
+ response = await this.list({ url, method, qs })
101
+ currentPageCount = response?.data?.value?.length
102
+
103
+ yield response
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ module.exports = ODataModule
@@ -0,0 +1,109 @@
1
+ 'use strict'
2
+
3
+ class UniversalModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of MYOBAccumatica class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+ }
11
+
12
+ /**
13
+ * Universal Request By URL and Method.
14
+ * @param {string} url URL of request.
15
+ * @param {string} method Method of request.
16
+ * @param {object} qs Some available filters inside: offset, limit.
17
+ * @param {object} body Some available data inside.
18
+ * @returns {object} Universal Request Response.
19
+ */
20
+ async request ({ url, method, qs = {}, body = {} }) {
21
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method })
22
+
23
+ if (!validateIsEmpty.valid) {
24
+ return this.module.responseHandler.error(validateIsEmpty.errors)
25
+ }
26
+
27
+ return await this.module.makeRequest('GET', `${this.module.apiURL}/zintegrations/action/5f752f97-03f9-4893-8245-7d03cf217e37`, {
28
+ mappable_parameters: {
29
+ url: {
30
+ value: url
31
+ },
32
+ method: {
33
+ value: method
34
+ },
35
+ qs: {
36
+ isMap: true,
37
+ value: JSON.stringify(qs)
38
+ },
39
+ body: {
40
+ isMap: true,
41
+ value: JSON.stringify(body)
42
+ }
43
+ }
44
+ })
45
+ }
46
+
47
+ /**
48
+ * Universal List By URL and Method.
49
+ * @param {string} url URL of listed data.
50
+ * @param {string} method Method of listed data.
51
+ * @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
52
+ * @returns {object} Universal List Response.
53
+ */
54
+ async list ({ url, method, qs = {} }) {
55
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method })
56
+
57
+ if (!validateIsEmpty.valid) {
58
+ return this.module.responseHandler.error(validateIsEmpty.errors)
59
+ }
60
+
61
+ if (!qs.$skip) {
62
+ qs.$skip = 0
63
+ }
64
+
65
+ if (!qs.$top) {
66
+ qs.$top = 100
67
+ }
68
+
69
+ return await this.request({ url, method, qs })
70
+ }
71
+
72
+ /**
73
+ * Universal Auto Pagination Listing By URL and Method.
74
+ * @param {string} url URL of listed data.
75
+ * @param {string} method Method of listed data.
76
+ * @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
77
+ * @returns {object} Auto Pagination responses.
78
+ */
79
+ async * autoPaginationList ({ url, method, qs = {} }) {
80
+ if (!qs.$skip) {
81
+ qs.$skip = 0
82
+ }
83
+
84
+ if (!qs.$top) {
85
+ qs.$top = 100
86
+ }
87
+
88
+ let response = await this.list({ url, method, qs })
89
+ let currentPageCount = response?.data?.length
90
+ let currentOffset = qs.$skip
91
+
92
+ yield response
93
+
94
+ if (currentPageCount && currentPageCount === qs.$top) {
95
+ while (currentPageCount === qs.$top) {
96
+ currentOffset = currentOffset + qs.$top
97
+
98
+ qs.$skip = currentOffset
99
+
100
+ response = await this.list({ url, method, qs })
101
+ currentPageCount = response?.data?.length
102
+
103
+ yield response
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ module.exports = UniversalModule
@@ -0,0 +1,97 @@
1
+ 'use strict'
2
+
3
+ class UniversalModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of Netsuite class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+ }
11
+
12
+ /**
13
+ * Universal Request By URL and Method.
14
+ * @param {string} url URL of request.
15
+ * @param {string} method Method of request.
16
+ * @param {object} qs Some available filters inside: offset, limit.
17
+ * @param {object} body Some available data inside.
18
+ * @returns {object} Universal Request Response.
19
+ */
20
+ async request ({ url, method, qs = {}, body = {} }) {
21
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method })
22
+
23
+ if (!validateIsEmpty.valid) {
24
+ return this.module.responseHandler.error(validateIsEmpty.errors)
25
+ }
26
+
27
+ url = `${url}?limit=${qs.limit}&offset=${qs.offset}`
28
+
29
+ return await this.module.makeRequest('GET', `${this.module.apiURL}/zintegrations/action/41a68068-6812-4634-a464-aab17d6b2358`, {
30
+ mappable_parameters: {
31
+ url: {
32
+ value: url
33
+ },
34
+ method: {
35
+ value: method
36
+ },
37
+ /*qs: {
38
+ isMap: true,
39
+ value: JSON.stringify(qs)
40
+ },*/
41
+ body: {
42
+ isMap: true,
43
+ value: JSON.stringify(body)
44
+ }
45
+ }
46
+ })
47
+ }
48
+
49
+ /**
50
+ * Universal List By URL.
51
+ * @param {number} offset Offset of listed data.
52
+ * @param {number} limit Limit of listed data.
53
+ * @param {string} query Query of listed data.
54
+ * @returns {object} Universal List Response.
55
+ */
56
+ async list ({ offset = 0, limit = 100, query = '' }) {
57
+ return await this.request({
58
+ url: 'query/v1/suiteql',
59
+ method: 'POST',
60
+ qs: {
61
+ offset,
62
+ limit
63
+ },
64
+ body: {
65
+ q: query
66
+ }
67
+ })
68
+ }
69
+
70
+ /**
71
+ * Universal Auto Pagination Listing.
72
+ * @param {number} offset Offset of listed data.
73
+ * @param {number} limit Limit of listed data.
74
+ * @param {string} query Query of listed data.
75
+ * @returns {object} Auto Pagination responses.
76
+ */
77
+ async * autoPaginationList ({ offset = 0, limit = 100, query = '' }) {
78
+ let response = await this.list({ offset, limit, query })
79
+ let currentOffset = offset
80
+
81
+ yield response
82
+
83
+ if (response?.data?.hasMore) {
84
+ while (response.data.hasMore) {
85
+ currentOffset = currentOffset + limit
86
+
87
+ offset = currentOffset
88
+
89
+ response = await this.list({ offset, limit, query })
90
+
91
+ yield response
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ module.exports = UniversalModule
@@ -0,0 +1,39 @@
1
+ 'use strict'
2
+
3
+ class PurchaseOrderModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of Netsuite class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+ }
11
+
12
+ /**
13
+ * Create purchase order.
14
+ * @param {object} body Body of purchase order.
15
+ * @param {string} memo Memo of purchase order.
16
+ * @param {string} customForm Custom purchase order form.
17
+ * @returns {object} Response.
18
+ */
19
+ async create ({ body, memo, customForm }) {
20
+ return await this.module.makeRequest('GET', `${this.module.apiURL}/zintegrations/action/23509d2d-47dd-4aa3-b8ab-a0057c5d3a0d`, {
21
+ mappable_parameters: {
22
+ debug: {
23
+ value: false
24
+ },
25
+ body: {
26
+ value: body
27
+ },
28
+ memo: {
29
+ value: memo
30
+ },
31
+ customForm: {
32
+ value: customForm
33
+ }
34
+ }
35
+ })
36
+ }
37
+ }
38
+
39
+ module.exports = PurchaseOrderModule
@@ -0,0 +1,39 @@
1
+ 'use strict'
2
+
3
+ class ReceiptModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of Netsuite class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+ }
11
+
12
+ /**
13
+ * Create receipt.
14
+ * @param {object} body Body of receipt.
15
+ * @param {string} memo Memo of receipt.
16
+ * @param {string} customForm Custom receipt form.
17
+ * @returns {object} Response.
18
+ */
19
+ async create ({ body, memo, customForm }) {
20
+ return await this.module.makeRequest('GET', `${this.module.apiURL}/zintegrations/action/76c5863a-4c54-47f7-a4a9-42edfac82300`, {
21
+ mappable_parameters: {
22
+ debug: {
23
+ value: false
24
+ },
25
+ body: {
26
+ value: body
27
+ },
28
+ memo: {
29
+ value: memo
30
+ },
31
+ customForm: {
32
+ value: customForm
33
+ }
34
+ }
35
+ })
36
+ }
37
+ }
38
+
39
+ module.exports = ReceiptModule
@@ -0,0 +1,124 @@
1
+ 'use strict'
2
+
3
+ class UniversalModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of Netsuite class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+
11
+ this.supportedTypes = [
12
+ 'accounts',
13
+ 'accounting-periods',
14
+ 'accounting-transactions',
15
+ 'addresses',
16
+ 'bins',
17
+ 'budgets',
18
+ 'classifications',
19
+ 'cost-types',
20
+ 'custom-lists',
21
+ 'customers',
22
+ 'customers.categories',
23
+ 'departments',
24
+ 'employees',
25
+ 'expense-categories',
26
+ 'exchange-rates',
27
+ 'items',
28
+ 'jobs',
29
+ 'jobs/tasks',
30
+ 'jobs/types',
31
+ 'jobs/statuses',
32
+ 'locations',
33
+ 'subsidiaries',
34
+ 'tax-types',
35
+ 'terms',
36
+ 'transactions',
37
+ 'vendors',
38
+ 'vendors/categories',
39
+ 'data-list/currency',
40
+ 'approvalStatus'
41
+ ]
42
+ }
43
+
44
+ /**
45
+ * Get Universal list.
46
+ * @param {string} type Universal Type.
47
+ * @param {array} filters Array with filters.
48
+ * @param {boolean} bodyFieldsOnly Flag to get only fields from body.
49
+ * @param {string} lastModifiedDate Last Modified Date.
50
+ * @param {number} limit Limit.
51
+ * @param {number} page Page.
52
+ * @param {string} searchID Search ID.
53
+ * @returns {object} Response.
54
+ */
55
+ async list ({ type, filters, bodyFieldsOnly = true, lastModifiedDate = '', limit = 100, page = 1, searchID = '' }) {
56
+ const validateIncludes = this.module.validator.includes(this.supportedTypes, type)
57
+
58
+ if (!validateIncludes.valid) {
59
+ return this.module.responseHandler.error(validateIncludes.errors)
60
+ }
61
+
62
+ return await this.module.makeRequest('GET', `${this.module.apiURL}/zintegrations/action/0491e05e-8f35-4422-a037-8490de1c37b4`, {
63
+ mappable_parameters: {
64
+ type: {
65
+ isMap: false,
66
+ value: type
67
+ },
68
+ bodyFieldsOnly: {
69
+ isMap: false,
70
+ value: bodyFieldsOnly
71
+ },
72
+ lastModifiedDate: {
73
+ isMap: false,
74
+ value: lastModifiedDate
75
+ },
76
+ filters: {
77
+ value: this.module.parseFilters(filters)
78
+ },
79
+ limit: {
80
+ isMap: false,
81
+ value: limit
82
+ },
83
+ page: {
84
+ isMap: false,
85
+ value: page
86
+ },
87
+ searchID: {
88
+ isMap: false,
89
+ value: searchID
90
+ }
91
+ }
92
+ })
93
+ }
94
+
95
+ /**
96
+ * Auto Paginate Universal list.
97
+ * @param {string} type Universal Type.
98
+ * @param {array} filters Array with filters.
99
+ * @param {boolean} bodyFieldsOnly Flag to get only fields from body.
100
+ * @param {string} lastModifiedDate Last Modified Date.
101
+ * @param {number} limit Limit.
102
+ * @param {number} page Page.
103
+ * @param {string} searchID Search ID.
104
+ * @returns {object} Responses.
105
+ */
106
+ async * autoPaginationList ({ type, filters, bodyFieldsOnly = true, lastModifiedDate = '', limit = 100, page = 1, searchID = '' }) {
107
+ let response = await this.list({ type, filters, bodyFieldsOnly, lastModifiedDate, limit, page, searchID })
108
+
109
+ const totalPages = response?.data?.searchResult?.totalPages || null
110
+ const currentSearchId = response?.data?.searchResult?.searchId || null
111
+
112
+ yield response
113
+
114
+ if (totalPages && currentSearchId && totalPages > page) {
115
+ for (let pageIndex = page + 1; pageIndex <= totalPages; pageIndex++) {
116
+ response = await this.list({ type, filters, bodyFieldsOnly, lastModifiedDate, limit, page: pageIndex, searchID: currentSearchId })
117
+
118
+ yield response
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ module.exports = UniversalModule
@@ -0,0 +1,138 @@
1
+ 'use strict'
2
+
3
+ class UniversalTransactionModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of Netsuite class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+
11
+ this.supportedTypes = [
12
+ '_assemblyBuild',
13
+ '_assemblyUnbuild',
14
+ '_binTransfer',
15
+ '_binWorksheet',
16
+ '_cashRefund',
17
+ '_cashSale',
18
+ '_check',
19
+ '_creditMemo',
20
+ '_custom',
21
+ '_customPurchase',
22
+ '_customSale',
23
+ '_customerDeposit',
24
+ '_customerPayment',
25
+ '_customerRefund',
26
+ '_deposit',
27
+ '_depositApplication',
28
+ '_estimate',
29
+ '_expenseReport',
30
+ '_inboundShipment',
31
+ '_inventoryAdjustment',
32
+ '_inventoryCostRevaluation',
33
+ '_inventoryTransfer',
34
+ '_invoice',
35
+ '_itemFulfillment',
36
+ '_itemReceipt',
37
+ '_journal',
38
+ '_opportunity',
39
+ '_paycheck',
40
+ '_paycheckJournal',
41
+ '_periodEndJournal',
42
+ '_purchaseOrder',
43
+ '_requisition',
44
+ '_returnAuthorization',
45
+ '_salesOrder',
46
+ '_transferOrder',
47
+ '_vendorBill',
48
+ '_vendorCredit',
49
+ '_vendorPayment',
50
+ '_vendorReturnAuthorization',
51
+ '_workOrder',
52
+ '_workOrderClose',
53
+ '_workOrderCompletion',
54
+ '_workOrderIssue'
55
+ ]
56
+ }
57
+
58
+ /**
59
+ * Get Transactions Universal list.
60
+ * @param {string} type Type.
61
+ * @param {array} filters Array with filters.
62
+ * @param {boolean} bodyFieldsOnly Flag to get only fields from body.
63
+ * @param {string} lastModifiedDate Last Modified Date.
64
+ * @param {number} limit Limit.
65
+ * @param {number} page Page.
66
+ * @param {string} searchID Search ID.
67
+ * @returns {object} Response.
68
+ */
69
+ async list ({ type, filters, bodyFieldsOnly = false, lastModifiedDate = '', limit = 100, page = 1, searchID = '' }) {
70
+ const validateIncludes = this.module.validator.includes(this.supportedTypes, type)
71
+
72
+ if (!validateIncludes.valid) {
73
+ return this.module.responseHandler.error(validateIncludes.errors)
74
+ }
75
+
76
+ return await this.module.makeRequest('GET', `${this.module.apiURL}/zintegrations/action/c0682187-6d05-4ccf-9a43-1250ca867588`, {
77
+ mappable_parameters: {
78
+ type: {
79
+ isMap: false,
80
+ value: type
81
+ },
82
+ bodyFieldsOnly: {
83
+ isMap: false,
84
+ value: bodyFieldsOnly
85
+ },
86
+ lastModifiedDate: {
87
+ isMap: false,
88
+ value: lastModifiedDate
89
+ },
90
+ filters: {
91
+ value: this.module.parseFilters(filters)
92
+ },
93
+ limit: {
94
+ isMap: false,
95
+ value: limit
96
+ },
97
+ page: {
98
+ isMap: false,
99
+ value: page
100
+ },
101
+ searchID: {
102
+ isMap: false,
103
+ value: searchID
104
+ }
105
+ }
106
+ })
107
+ }
108
+
109
+ /**
110
+ * Auto Paginate Transactions Universal list.
111
+ * @param {string} type Type.
112
+ * @param {array} filters Array with filters.
113
+ * @param {boolean} bodyFieldsOnly Flag to get only fields from body.
114
+ * @param {string} lastModifiedDate Last Modified Date.
115
+ * @param {number} limit Limit.
116
+ * @param {number} page Page.
117
+ * @param {string} searchID Search ID.
118
+ * @returns {object} Responses.
119
+ */
120
+ async * autoPaginationList ({ type, filters, bodyFieldsOnly = true, lastModifiedDate = '', limit = 100, page = 1, searchID = '' }) {
121
+ let response = await this.list({ type, filters, bodyFieldsOnly, lastModifiedDate, limit, page, searchID })
122
+
123
+ const totalPages = response?.data?.searchResult?.totalPages || null
124
+ const currentSearchId = response?.data?.searchResult?.searchId || null
125
+
126
+ yield response
127
+
128
+ if (totalPages && currentSearchId && totalPages > page) {
129
+ for (let pageIndex = page + 1; pageIndex <= totalPages; pageIndex++) {
130
+ response = await this.list({ type, filters, bodyFieldsOnly, lastModifiedDate, limit, page: pageIndex, searchID: currentSearchId })
131
+
132
+ yield response
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ module.exports = UniversalTransactionModule
@@ -0,0 +1,41 @@
1
+ 'use strict'
2
+
3
+ class VendorBillModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of Netsuite class.
7
+ */
8
+ constructor (parentModule) {
9
+ this.module = parentModule
10
+ }
11
+
12
+ /**
13
+ * Create vendor bill.
14
+ * @param {object} body Body of bill.
15
+ * @param {string} memo Memo of bill.
16
+ * @param {string} customForm Custom bill form.
17
+ * @returns {object} Response.
18
+ */
19
+ async create ({ body, memo, customForm }) {
20
+ return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/7bdf8c54-07b3-4cb3-9222-759181043eaa`, {
21
+ mappable_parameters: {
22
+ debug: {
23
+ value: false
24
+ },
25
+ body: {
26
+ value: body
27
+ },
28
+ memo: {
29
+ value: memo
30
+ },
31
+ customForm: {
32
+ value: customForm
33
+ }
34
+ }
35
+ }, {
36
+ _debug: true
37
+ })
38
+ }
39
+ }
40
+
41
+ module.exports = VendorBillModule