zudello-integration-sdk 1.0.62 → 1.0.64

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.62",
3
+ "version": "1.0.64",
4
4
  "description": "Zudello Integrations SDK",
5
5
  "main": "./src/index.js",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -19,6 +19,8 @@ const MYOBAccountRightSDK = require('./sdk/MYOBAccountRight')
19
19
  const SybizSDK = require('./sdk/Sybiz')
20
20
  const XeroSDK = require('./sdk/Xero')
21
21
  const JobReadySDK = require('./sdk/JobReady')
22
+ const JobReadyLiveSDK = require('./sdk/JobReadyLive')
23
+ const InspHireSDK = require('./sdk/InspHire')
22
24
  const X3SDK = require('./sdk/X3')
23
25
  const SAPB1SDK = require('./sdk/SAPB1')
24
26
  const GPSDK = require('./sdk/GP')
@@ -93,6 +95,8 @@ module.exports = {
93
95
  SFTPSDK,
94
96
  XeroSDK,
95
97
  JobReadySDK,
98
+ JobReadyLiveSDK,
99
+ InspHireSDK,
96
100
  Logger,
97
101
  Metadata,
98
102
  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
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ const BaseSDK = require('./Base')
4
+ const UniversalModule = require('./submodules/jobreadylive/Universal')
5
+
6
+ class JobReadyLiveSDK 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: 'jobreadylive',
20
+ integrationName: 'JobReadyLive',
21
+ loggerClass
22
+ })
23
+
24
+ /**
25
+ * Create submodule instances.
26
+ */
27
+ this.universal = new UniversalModule(this)
28
+ }
29
+ }
30
+
31
+ module.exports = JobReadyLiveSDK
@@ -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;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ class UniversalModule {
4
+ /**
5
+ * Constructor.
6
+ * @param {class} parentModule Object of JobReady Live 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} header Headers to pass to the block
17
+ * @param {object} qs Some available filters inside: offset, limit.
18
+ * @param {object} body Some available data inside.
19
+ * @returns {object} Universal Request Response.
20
+ */
21
+ async request({ url, method, header = {}, qs = {}, body = {} }) {
22
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method });
23
+
24
+ if (!validateIsEmpty.valid) {
25
+ return this.module.responseHandler.error(validateIsEmpty.errors);
26
+ }
27
+
28
+ return await this.module.makeRequest(
29
+ "POST",
30
+ `${this.module.apiURL}/zintegrations/action/9b7d99ab-f64c-4460-b5b1-ccc46905ec17`,
31
+ {
32
+ mappable_parameters: {
33
+ url: {
34
+ value: url,
35
+ },
36
+ method: {
37
+ value: method,
38
+ },
39
+ header: {
40
+ value: JSON.stringify(header),
41
+ },
42
+ qs: {
43
+ isMap: true,
44
+ value: JSON.stringify(qs),
45
+ },
46
+ body: {
47
+ isMap: true,
48
+ value: JSON.stringify(body),
49
+ },
50
+ },
51
+ }
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Universal List By URL and Method.
57
+ * @param {string} url URL of listed data.
58
+ * @param {string} method Method of listed data.
59
+ * @param {object} header Headers to pass to the block
60
+ * @param {object} qs Some available filters inside: Page, Limit.
61
+ * @param {object} body Some available data inside.
62
+ * @returns {object} Universal List Response.
63
+ */
64
+ async list({ url, method, header = {}, qs = {}, body = {} }) {
65
+ const validateIsEmpty = this.module.validator.isEmpty({ url, method });
66
+
67
+ if (!validateIsEmpty.valid) {
68
+ return this.module.responseHandler.error(validateIsEmpty.errors);
69
+ }
70
+
71
+ if (!qs.page) {
72
+ qs.page = 1;
73
+ }
74
+
75
+ return await this.request({ url, method, header, qs, body });
76
+ }
77
+
78
+ /**
79
+ * Universal Auto Pagination Listing By URL and Method.
80
+ * @param {string} url URL of listed data.
81
+ * @param {string} method Method of listed data.
82
+ * @param {object} header Headers to pass to the block
83
+ * @param {object} qs Some available filters inside: Page, Limit.
84
+ * @param {object} body Some available data inside.
85
+ * @returns {object} Auto Pagination responses.
86
+ */
87
+ async *autoPaginationList({ url, method, header = {}, qs = {}, body = {} }) {
88
+ if (!qs.page) {
89
+ qs.page = 1;
90
+ }
91
+ if (!qs.per_page) {
92
+ qs.per_page = 25;
93
+ }
94
+
95
+ let response = await this.list({ url, method, header, qs, body });
96
+ let currentPageCount = response?.data?.length;
97
+
98
+ yield response;
99
+
100
+ if (currentPageCount && currentPageCount === qs.per_page ) {
101
+ while (currentPageCount === qs.per_page ) {
102
+ qs.page = qs.page + 1;
103
+
104
+ response = await this.list({ url, method, header, qs, body });
105
+ currentPageCount = response?.data?.length;
106
+
107
+ yield response;
108
+ }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Upload Attachment
114
+ * @param {string} uploadUrl
115
+ * @param {string} fileUrl
116
+ * @param {array} tags
117
+ */
118
+ async addAttachment({ uploadUrl, fileUrl, tags }) {
119
+ return await this.module.makeRequest(
120
+ "POST",
121
+ `${this.module.apiURL}/zintegrations/action/5e3e35eb-71c9-430b-8843-1a9a13f6ca73`,
122
+ {
123
+ mappable_parameters: {
124
+ uploadUrl: {
125
+ value: uploadUrl,
126
+ },
127
+ fileUrl: {
128
+ value: fileUrl,
129
+ },
130
+ tags: {
131
+ value: tags,
132
+ }
133
+ },
134
+ }
135
+ );
136
+ }
137
+ }
138
+
139
+ module.exports = UniversalModule;