zudello-integration-sdk 1.0.63 → 1.0.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudello-integration-sdk",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "Zudello Integrations SDK",
5
5
  "main": "./src/index.js",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -20,6 +20,8 @@ const SybizSDK = require('./sdk/Sybiz')
20
20
  const XeroSDK = require('./sdk/Xero')
21
21
  const JobReadySDK = require('./sdk/JobReady')
22
22
  const JobReadyLiveSDK = require('./sdk/JobReadyLive')
23
+ const InspHireSDK = require('./sdk/InspHire')
24
+ const S4SDK = require('./sdk/S4')
23
25
  const X3SDK = require('./sdk/X3')
24
26
  const SAPB1SDK = require('./sdk/SAPB1')
25
27
  const GPSDK = require('./sdk/GP')
@@ -95,6 +97,8 @@ module.exports = {
95
97
  XeroSDK,
96
98
  JobReadySDK,
97
99
  JobReadyLiveSDK,
100
+ InspHireSDK,
101
+ S4SDK,
98
102
  Logger,
99
103
  Metadata,
100
104
  Message,
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ const BaseSDK = require('./Base')
4
+ const UniversalModule = require('./submodules/insphire/Universal')
5
+
6
+ class InspHireSDK extends BaseSDK {
7
+ /**
8
+ * Constructor.
9
+ * @param {class} auth Auth class object with authorized api instance.
10
+ * @param {string} connectionUUID The UUID of the Connection we're working on.
11
+ */
12
+ constructor (auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
13
+ super({
14
+ auth,
15
+ connectionUUID,
16
+ organizationUUID,
17
+ apiURL,
18
+ apiVersion,
19
+ appUUIDKey: 'insphire',
20
+ integrationName: 'InspHire',
21
+ loggerClass
22
+ })
23
+
24
+ /**
25
+ * Create submodule instances.
26
+ */
27
+ this.universal = new UniversalModule(this)
28
+ }
29
+ }
30
+
31
+ module.exports = InspHireSDK
@@ -17,7 +17,7 @@ class JobReadyLiveSDK extends BaseSDK {
17
17
  apiURL,
18
18
  apiVersion,
19
19
  appUUIDKey: 'jobreadylive',
20
- integrationName: 'JobReady Live',
20
+ integrationName: 'JobReadyLive',
21
21
  loggerClass
22
22
  })
23
23
 
package/src/sdk/S4.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ const BaseSDK = require("./Base");
4
+ const UniversalModule = require("./submodules/s4/Universal");
5
+
6
+ class S4SDK extends BaseSDK {
7
+ /**
8
+ * Constructor.
9
+ * @param {class} auth Auth class object with authorized api instance.
10
+ * @param {string} connectionUUID The UUID of the Connection we're working on.
11
+ */
12
+ constructor(
13
+ auth,
14
+ connectionUUID,
15
+ organizationUUID,
16
+ apiURL,
17
+ apiVersion,
18
+ loggerClass = null
19
+ ) {
20
+ super({
21
+ auth,
22
+ connectionUUID,
23
+ organizationUUID,
24
+ apiURL,
25
+ apiVersion,
26
+ appUUIDKey: "s4",
27
+ integrationName: "S4",
28
+ loggerClass,
29
+ });
30
+
31
+ /**
32
+ * Create submodule instances.
33
+ */
34
+ this.universal = new UniversalModule(this);
35
+ }
36
+ }
37
+
38
+ module.exports = S4SDK;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ class UniversalModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of InspHire 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(
28
+ "POST",
29
+ `${this.module.apiURL}/zintegrations/action/9aa2c181-67f8-436a-8429-dd5dd2a4099d`,
30
+ {
31
+ mappable_parameters: {
32
+ url: {
33
+ value: url,
34
+ },
35
+ method: {
36
+ value: method,
37
+ },
38
+ qs: {
39
+ isMap: true,
40
+ value: JSON.stringify(qs),
41
+ },
42
+ body: {
43
+ isMap: true,
44
+ value: JSON.stringify(body),
45
+ },
46
+ },
47
+ }
48
+ );
49
+ }
50
+
51
+ /**
52
+ * Universal List By URL and Method.
53
+ * @param {string} url URL of listed data.
54
+ * @param {string} method Method of listed data.
55
+ * @param {object} qs Some available filters inside: $skip, $top, $filter, $orderby.
56
+ * @param {object} body Some available data inside.
57
+ * @returns {object} Universal List Response.
58
+ */
59
+ async list({ url, method, qs = {}, body = {} }) {
60
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method });
61
+
62
+ if (!validateIsEmpty.valid) {
63
+ return this.module.responseHandler.error(validateIsEmpty.errors);
64
+ }
65
+
66
+ if (!qs.$skip) qs.$skip = 0;
67
+ if (!qs.$top) qs.$top = 100;
68
+
69
+ return await this.request({ url, method, qs, body });
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: $skip, $top, $filter, $orderby.
77
+ * @param {object} body Some available data inside.
78
+ * @returns {object} Auto Pagination responses.
79
+ */
80
+ async *autoPaginationList({ url, method, qs = {}, body = {} }) {
81
+ if (!qs.$skip) qs.$skip = 0;
82
+ if (!qs.$top) qs.$top = 100;
83
+
84
+ let response = await this.list({ url, method, qs, body });
85
+ let currentPageCount = response?.data?.length;
86
+
87
+ yield response;
88
+
89
+ if (currentPageCount && currentPageCount === qs.$top) {
90
+ while (currentPageCount === qs.$top) {
91
+ qs.$skip = qs.$skip + qs.$top;
92
+
93
+ response = await this.list({ url, method, qs, body });
94
+ currentPageCount = response?.data?.length;
95
+
96
+ yield response;
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ module.exports = UniversalModule;
@@ -136,6 +136,4 @@ class UniversalModule {
136
136
  }
137
137
  }
138
138
 
139
- module.exports = UniversalModule;
140
-
141
-
139
+ module.exports = UniversalModule;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ class UniversalModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of S4 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(
28
+ "POST",
29
+ `${this.module.apiURL}/zintegrations/action/cedcf9fe-001d-44cb-935d-ccaa9ee8816f`,
30
+ {
31
+ mappable_parameters: {
32
+ url: {
33
+ value: url,
34
+ },
35
+ method: {
36
+ value: method,
37
+ },
38
+ qs: {
39
+ isMap: true,
40
+ value: JSON.stringify(qs),
41
+ },
42
+ body: {
43
+ isMap: true,
44
+ value: JSON.stringify(body),
45
+ },
46
+ },
47
+ }
48
+ );
49
+ }
50
+
51
+ /**
52
+ * Universal List By URL and Method.
53
+ * @param {string} url URL of listed data.
54
+ * @param {string} method Method of listed data.
55
+ * @param {object} qs Some available filters inside: $skip, $top, $filter, $orderby, $select, $expand.
56
+ * @param {object} body Some available data inside.
57
+ * @returns {object} Universal List Response.
58
+ */
59
+ async list({ url, method, qs = {}, body = {} }) {
60
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method });
61
+
62
+ if (!validateIsEmpty.valid) {
63
+ return this.module.responseHandler.error(validateIsEmpty.errors);
64
+ }
65
+
66
+ if (!qs.$skip) qs.$skip = 0;
67
+ if (!qs.$top) qs.$top = 100;
68
+
69
+ return await this.request({ url, method, qs, body });
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: $skip, $top, $filter, $orderby, $select, $expand.
77
+ * @param {object} body Some available data inside.
78
+ * @returns {object} Auto Pagination responses.
79
+ */
80
+ async *autoPaginationList({ url, method, qs = {}, body = {} }) {
81
+ if (!qs.$skip) qs.$skip = 0;
82
+ if (!qs.$top) qs.$top = 100;
83
+
84
+ let response = await this.list({ url, method, qs, body });
85
+
86
+ let currentPageCount = response?.data?.d?.results?.length || 0;
87
+
88
+ yield response;
89
+
90
+ while (currentPageCount === qs.$top) {
91
+ qs.$skip = qs.$skip + qs.$top;
92
+
93
+ response = await this.list({ url, method, qs, body });
94
+ currentPageCount = response?.data?.d?.results?.length || 0;
95
+
96
+ yield response;
97
+ }
98
+ }
99
+ }
100
+
101
+ module.exports = UniversalModule;