@foxtware/mineral 0.1.17 → 0.1.19

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 (96) hide show
  1. package/.creds.yml.sample +16 -7
  2. package/AGENTS.md +4 -0
  3. package/_build_scripts/createNewFunction.js +10 -5
  4. package/_build_scripts/publish.js +15 -1
  5. package/api/backblaze/backblaze.constants.js +11 -0
  6. package/api/backblaze/backblaze.utils.js +322 -0
  7. package/api/backblaze/backblazeBucketsGet.js +68 -0
  8. package/api/backblaze/backblazeFileDelete.js +62 -0
  9. package/api/backblaze/backblazeFileHide.js +62 -0
  10. package/api/backblaze/backblazeFileUpload.js +142 -0
  11. package/api/backblaze/backblazeFilesGet.js +85 -0
  12. package/api/backblaze/backblazeGet.js +139 -0
  13. package/api/backblaze/docs.md +6 -0
  14. package/api/etsy/etsyListingUpdate.js +1 -1
  15. package/api/gorgias/gorgias.constants.js +8 -0
  16. package/api/gorgias/gorgias.utils.js +46 -0
  17. package/api/gorgias/gorgiasAccountGet.js +51 -0
  18. package/api/gorgias/gorgiasCustomerGet.js +70 -0
  19. package/api/gorgias/gorgiasCustomersGet.js +56 -0
  20. package/api/gorgias/gorgiasGet.js +150 -0
  21. package/api/gorgias/gorgiasGetSingle.js +26 -0
  22. package/api/gorgias/gorgiasMessagesGet.js +56 -0
  23. package/api/gorgias/gorgiasTagsGet.js +52 -0
  24. package/api/gorgias/gorgiasTicketCreate.js +66 -0
  25. package/api/gorgias/gorgiasTicketGet.js +70 -0
  26. package/api/gorgias/gorgiasTicketMessageCreate.js +65 -0
  27. package/api/gorgias/gorgiasTicketMessagesGet.js +66 -0
  28. package/api/gorgias/gorgiasTicketUpdate.js +62 -0
  29. package/api/gorgias/gorgiasTicketsGet.js +58 -0
  30. package/api/gorgias/gorgiasUsersGet.js +52 -0
  31. package/api/gorgias/gorgiasViewItemsGet.js +57 -0
  32. package/api/gorgias/gorgiasViewsGet.js +72 -0
  33. package/api/linear/docs.md +6 -0
  34. package/api/linear/linear.constants.js +3 -0
  35. package/api/linear/linear.utils.js +59 -0
  36. package/api/linear/linearAttachmentCreate.js +77 -0
  37. package/api/linear/linearAttachmentDelete.js +68 -0
  38. package/api/linear/linearCommentCreate.js +77 -0
  39. package/api/linear/linearCommentDelete.js +68 -0
  40. package/api/linear/linearCommentGet.js +77 -0
  41. package/api/linear/linearCommentUpdate.js +87 -0
  42. package/api/linear/linearCommentsGet.js +70 -0
  43. package/api/linear/linearCyclesGet.js +67 -0
  44. package/api/linear/linearGet.js +218 -0
  45. package/api/linear/linearIssueAddLabel.js +77 -0
  46. package/api/linear/linearIssueArchive.js +74 -0
  47. package/api/linear/linearIssueCreate.js +94 -0
  48. package/api/linear/linearIssueDelete.js +74 -0
  49. package/api/linear/linearIssueGet.js +87 -0
  50. package/api/linear/linearIssueLabelCreate.js +81 -0
  51. package/api/linear/linearIssueLabelsGet.js +66 -0
  52. package/api/linear/linearIssueRemoveLabel.js +77 -0
  53. package/api/linear/linearIssueUpdate.js +96 -0
  54. package/api/linear/linearIssuesGet.js +39 -63
  55. package/api/linear/linearOrganizationGet.js +64 -0
  56. package/api/linear/linearProjectCreate.js +92 -0
  57. package/api/linear/linearProjectGet.js +74 -0
  58. package/api/linear/linearProjectUpdate.js +80 -0
  59. package/api/linear/linearProjectsGet.js +71 -0
  60. package/api/linear/linearTeamGet.js +71 -0
  61. package/api/linear/linearTeamsGet.js +66 -0
  62. package/api/linear/linearUserGet.js +72 -0
  63. package/api/linear/linearUsersGet.js +71 -0
  64. package/api/linear/linearViewerGet.js +65 -0
  65. package/api/linear/linearWebhookCreate.js +77 -0
  66. package/api/linear/linearWebhookDelete.js +68 -0
  67. package/api/linear/linearWebhooksGet.js +67 -0
  68. package/api/linear/linearWorkflowStatesGet.js +73 -0
  69. package/api/peoplevox/peoplevox.utils.js +25 -0
  70. package/api/pipe17/pipe17.utils.js +7 -20
  71. package/api/pipe17/pipe17ArrivalGet.js +1 -1
  72. package/api/pipe17/pipe17FulfillmentGet.js +1 -1
  73. package/api/pipe17/pipe17InventoryItemGet.js +1 -1
  74. package/api/pipe17/pipe17JobGet.js +11 -24
  75. package/api/pipe17/pipe17LocationGet.js +1 -1
  76. package/api/pipe17/pipe17OrderGet.js +1 -1
  77. package/api/pipe17/pipe17ProductGet.js +1 -1
  78. package/api/pipe17/pipe17PurchaseGet.js +1 -1
  79. package/api/pipe17/pipe17ReceiptGet.js +1 -1
  80. package/api/pipe17/pipe17ReturnGet.js +1 -1
  81. package/api/shopify/shopifyFileCreate.js +107 -0
  82. package/api/shopify/shopifyFulfillmentCreate.js +180 -0
  83. package/api/shopify/shopifyFulfillmentTrackingInfoUpdate.js +92 -0
  84. package/api/shopify/shopifyMetafieldDefinitionCreate.js +2 -0
  85. package/api/shopify/shopifyMetafieldDefinitionGet.js +108 -0
  86. package/api/shopify/shopifyMetafieldDefinitionPropagate.js +93 -86
  87. package/api/shopify/shopifyOrderFulfill.js +322 -0
  88. package/api/shopify/shopifyThemeFileGet.js +112 -0
  89. package/api/shopify/shopifyThemeFilePropagate.js +410 -0
  90. package/api/shopify/shopifyThemeFilesUpsert.js +88 -0
  91. package/api/starshipit/starshipit.utils.js +29 -3
  92. package/api/starshipit/starshipitOrderGet.js +2 -10
  93. package/api/starshipit/starshipitOrdersGet.js +96 -0
  94. package/api/utils.js +96 -5
  95. package/package.json +1 -1
  96. package/server.utils.js +1 -1
@@ -0,0 +1,150 @@
1
+ const { ArgsWarden, Getter } = require('../utils');
2
+ const { credsValidator } = require('../validators');
3
+ const { gorgiasClient } = require('../gorgias/gorgias.utils');
4
+ const { MAX_PER_PAGE } = require('../gorgias/gorgias.constants');
5
+
6
+ const argsWarden = new ArgsWarden([
7
+ ['credsPayload', credsValidator],
8
+ ['url'],
9
+ ]);
10
+
11
+ const digResults = (data, resultsKey) => {
12
+ if (resultsKey) {
13
+ return data?.[resultsKey] ?? [];
14
+ }
15
+
16
+ if (Array.isArray(data)) {
17
+ return data;
18
+ }
19
+
20
+ const arrayEntry = Object.entries(data || {}).find(([, value]) => Array.isArray(value));
21
+ return arrayEntry ? arrayEntry[1] : [];
22
+ };
23
+
24
+ const gorgiasGetPacket = async (
25
+ credsPayload,
26
+ url,
27
+ {
28
+ params,
29
+ perPage = MAX_PER_PAGE,
30
+ fetchClient = gorgiasClient,
31
+ } = {},
32
+ ) => {
33
+ return fetchClient.fetch({
34
+ requestPayload: {
35
+ url,
36
+ params: {
37
+ limit: Math.min(perPage, MAX_PER_PAGE),
38
+ ...params,
39
+ },
40
+ },
41
+ context: {
42
+ credsPayload,
43
+ },
44
+ });
45
+ };
46
+
47
+ const gorgiasGetPaginator = async (currentParams, response) => {
48
+ const { args, options } = currentParams;
49
+
50
+ if (!response?.ok) {
51
+ return [true];
52
+ }
53
+
54
+ const nextCursor = response?.data?.meta?.next_cursor;
55
+ if (!nextCursor) {
56
+ return [true];
57
+ }
58
+
59
+ const { params = {} } = options;
60
+
61
+ return [false, {
62
+ args,
63
+ options: {
64
+ ...options,
65
+ params: {
66
+ ...params,
67
+ cursor: nextCursor,
68
+ },
69
+ },
70
+ }];
71
+ };
72
+
73
+ const gorgiasGet = async (
74
+ returnGetter,
75
+
76
+ credsPayload,
77
+ url,
78
+ {
79
+ params,
80
+ perPage = MAX_PER_PAGE,
81
+ resultsKey = 'data',
82
+ fetchClient = gorgiasClient,
83
+ ...getterOptions
84
+ } = {},
85
+ ) => {
86
+
87
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
88
+ credsPayload,
89
+ url,
90
+ });
91
+ if (rejectResponse) {
92
+ return rejectResponse;
93
+ }
94
+
95
+ const getter = new Getter(
96
+ {
97
+ args: [credsPayload, url],
98
+ options: {
99
+ params,
100
+ perPage,
101
+ fetchClient,
102
+ },
103
+ },
104
+ {
105
+ func: gorgiasGetPacket,
106
+ digester: (response) => {
107
+ if (!response?.ok) {
108
+ return [];
109
+ }
110
+
111
+ return digResults(response.data, resultsKey);
112
+ },
113
+ paginator: gorgiasGetPaginator,
114
+ ...getterOptions,
115
+ },
116
+ );
117
+
118
+ if (returnGetter) {
119
+ return getter;
120
+ }
121
+
122
+ const data = await getter.run({ returnAll: true });
123
+
124
+ return {
125
+ ok: true,
126
+ data,
127
+ };
128
+ };
129
+
130
+ const funcApiConfig = {
131
+ argsWarden,
132
+ };
133
+
134
+ module.exports = {
135
+ gorgiasGet: (...args) => gorgiasGet(false, ...args),
136
+ gorgiasGetter: (...args) => gorgiasGet(true, ...args),
137
+ funcApiConfig,
138
+ };
139
+
140
+ /*
141
+ curl -X POST "http://localhost:8000/gorgiasGet" \
142
+ -H "Content-Type: application/json" \
143
+ -d '{
144
+ "credsPayload": { "credsPath": "gorgias" },
145
+ "url": "/tickets",
146
+ "options": {
147
+ "limit": 10
148
+ }
149
+ }'
150
+ */
@@ -0,0 +1,26 @@
1
+ const { gorgiasClient } = require('../gorgias/gorgias.utils');
2
+
3
+ const gorgiasGetSingle = async (
4
+ credsPayload,
5
+ collectionPath,
6
+ id,
7
+ {
8
+ inspect = false,
9
+ fetchClient = gorgiasClient,
10
+ } = {},
11
+ ) => {
12
+ const normalizedPath = collectionPath.replace(/\/$/, '');
13
+
14
+ return fetchClient.fetch({
15
+ requestPayload: {
16
+ method: 'get',
17
+ url: `${ normalizedPath }/${ id }`,
18
+ },
19
+ context: { credsPayload },
20
+ inspect,
21
+ });
22
+ };
23
+
24
+ module.exports = {
25
+ gorgiasGetSingle,
26
+ };
@@ -0,0 +1,56 @@
1
+ // https://developers.gorgias.com/reference/list-messages
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasGet, gorgiasGetter } = require('../gorgias/gorgiasGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const gorgiasMessagesGet = async (
12
+ returnGetter,
13
+
14
+ credsPayload,
15
+ getterOptions = {},
16
+ ) => {
17
+
18
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
19
+ credsPayload,
20
+ });
21
+ if (rejectResponse) {
22
+ return rejectResponse;
23
+ }
24
+
25
+ const getterArgs = [
26
+ credsPayload,
27
+ '/messages',
28
+ getterOptions,
29
+ ];
30
+
31
+ return returnGetter
32
+ ? gorgiasGetter(...getterArgs)
33
+ : gorgiasGet(...getterArgs);
34
+ };
35
+
36
+ const funcApiConfig = {
37
+ argsWarden,
38
+ };
39
+
40
+ module.exports = {
41
+ gorgiasMessagesGet: (...args) => gorgiasMessagesGet(false, ...args),
42
+ gorgiasMessagesGetter: (...args) => gorgiasMessagesGet(true, ...args),
43
+ funcApiConfig,
44
+ };
45
+
46
+ /*
47
+ curl -X POST "http://localhost:8000/gorgiasMessagesGet" \
48
+ -H "Content-Type: application/json" \
49
+ -d '{
50
+ "credsPayload": { "credsPath": "gorgias" },
51
+ "options": {
52
+ "params": { "ticket_id": 399815746 },
53
+ "limit": 20
54
+ }
55
+ }'
56
+ */
@@ -0,0 +1,52 @@
1
+ // https://developers.gorgias.com/reference/list-tags
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasGet, gorgiasGetter } = require('../gorgias/gorgiasGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const gorgiasTagsGet = async (
12
+ returnGetter,
13
+
14
+ credsPayload,
15
+ getterOptions = {},
16
+ ) => {
17
+
18
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
19
+ credsPayload,
20
+ });
21
+ if (rejectResponse) {
22
+ return rejectResponse;
23
+ }
24
+
25
+ const getterArgs = [
26
+ credsPayload,
27
+ '/tags',
28
+ getterOptions,
29
+ ];
30
+
31
+ return returnGetter
32
+ ? gorgiasGetter(...getterArgs)
33
+ : gorgiasGet(...getterArgs);
34
+ };
35
+
36
+ const funcApiConfig = {
37
+ argsWarden,
38
+ };
39
+
40
+ module.exports = {
41
+ gorgiasTagsGet: (...args) => gorgiasTagsGet(false, ...args),
42
+ gorgiasTagsGetter: (...args) => gorgiasTagsGet(true, ...args),
43
+ funcApiConfig,
44
+ };
45
+
46
+ /*
47
+ curl -X POST "http://localhost:8000/gorgiasTagsGet" \
48
+ -H "Content-Type: application/json" \
49
+ -d '{
50
+ "credsPayload": { "credsPath": "gorgias" }
51
+ }'
52
+ */
@@ -0,0 +1,66 @@
1
+ // https://developers.gorgias.com/reference/create-ticket
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasClient } = require('../gorgias/gorgias.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['ticketBody', valueProvided],
10
+ ]);
11
+
12
+ const gorgiasTicketCreate = async (
13
+ credsPayload,
14
+ ticketBody,
15
+ {
16
+ inspect = false,
17
+ fetchClient = gorgiasClient,
18
+ } = {},
19
+ ) => {
20
+
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
22
+ credsPayload,
23
+ ticketBody,
24
+ });
25
+ if (rejectResponse) {
26
+ return rejectResponse;
27
+ }
28
+
29
+ return fetchClient.fetch({
30
+ requestPayload: {
31
+ method: 'post',
32
+ url: '/tickets',
33
+ body: ticketBody,
34
+ },
35
+ context: { credsPayload },
36
+ inspect,
37
+ });
38
+ };
39
+
40
+ const funcApiConfig = {
41
+ argsWarden,
42
+ };
43
+
44
+ module.exports = {
45
+ gorgiasTicketCreate,
46
+ funcApiConfig,
47
+ };
48
+
49
+ /*
50
+ curl -X POST "http://localhost:8000/gorgiasTicketCreate" \
51
+ -H "Content-Type: application/json" \
52
+ -d '{
53
+ "credsPayload": { "credsPath": "gorgias" },
54
+ "ticketBody": {
55
+ "customer": { "email": "customer@example.com" },
56
+ "messages": [
57
+ {
58
+ "channel": "email",
59
+ "via": "email",
60
+ "from_agent": false,
61
+ "body_text": "Hello"
62
+ }
63
+ ]
64
+ }
65
+ }'
66
+ */
@@ -0,0 +1,70 @@
1
+ // https://developers.gorgias.com/reference/get-ticket
2
+
3
+ const { ArgsWarden, actionSingleOrMultiple } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasGetSingle } = require('../gorgias/gorgiasGetSingle');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['ticketId'],
10
+ ]);
11
+
12
+ const gorgiasTicketGetSingle = async (
13
+ credsPayload,
14
+ ticketId,
15
+ options = {},
16
+ ) => {
17
+ return gorgiasGetSingle(
18
+ credsPayload,
19
+ '/tickets',
20
+ ticketId,
21
+ options,
22
+ );
23
+ };
24
+
25
+ const gorgiasTicketGet = async (
26
+ credsPayload,
27
+ ticketId,
28
+ {
29
+ queueRunOptions,
30
+ ...options
31
+ } = {},
32
+ ) => {
33
+
34
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
35
+ credsPayload,
36
+ ticketId,
37
+ });
38
+ if (rejectResponse) {
39
+ return rejectResponse;
40
+ }
41
+
42
+ return actionSingleOrMultiple(
43
+ ticketId,
44
+ gorgiasTicketGetSingle,
45
+ (ticketIdItem) => ({
46
+ args: [credsPayload, ticketIdItem, options],
47
+ }),
48
+ {
49
+ ...(queueRunOptions ? { queueRunOptions } : {}),
50
+ },
51
+ );
52
+ };
53
+
54
+ const funcApiConfig = {
55
+ argsWarden,
56
+ };
57
+
58
+ module.exports = {
59
+ gorgiasTicketGet,
60
+ funcApiConfig,
61
+ };
62
+
63
+ /*
64
+ curl -X POST "http://localhost:8000/gorgiasTicketGet" \
65
+ -H "Content-Type: application/json" \
66
+ -d '{
67
+ "credsPayload": { "credsPath": "gorgias" },
68
+ "ticketId": "399815746"
69
+ }'
70
+ */
@@ -0,0 +1,65 @@
1
+ // https://developers.gorgias.com/reference/create-ticket-message
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasClient } = require('../gorgias/gorgias.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['ticketId'],
10
+ ['messageBody', valueProvided],
11
+ ]);
12
+
13
+ const gorgiasTicketMessageCreate = async (
14
+ credsPayload,
15
+ ticketId,
16
+ messageBody,
17
+ {
18
+ inspect = false,
19
+ fetchClient = gorgiasClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ ticketId,
26
+ messageBody,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ return fetchClient.fetch({
33
+ requestPayload: {
34
+ method: 'post',
35
+ url: `/tickets/${ ticketId }/messages`,
36
+ body: messageBody,
37
+ },
38
+ context: { credsPayload },
39
+ inspect,
40
+ });
41
+ };
42
+
43
+ const funcApiConfig = {
44
+ argsWarden,
45
+ };
46
+
47
+ module.exports = {
48
+ gorgiasTicketMessageCreate,
49
+ funcApiConfig,
50
+ };
51
+
52
+ /*
53
+ curl -X POST "http://localhost:8000/gorgiasTicketMessageCreate" \
54
+ -H "Content-Type: application/json" \
55
+ -d '{
56
+ "credsPayload": { "credsPath": "gorgias" },
57
+ "ticketId": "399815746",
58
+ "messageBody": {
59
+ "channel": "email",
60
+ "via": "api",
61
+ "from_agent": true,
62
+ "body_text": "Thanks for reaching out — we are looking into this."
63
+ }
64
+ }'
65
+ */
@@ -0,0 +1,66 @@
1
+ // https://developers.gorgias.com/reference/list-messages
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasGet, gorgiasGetter } = require('../gorgias/gorgiasGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['ticketId'],
10
+ ]);
11
+
12
+ const gorgiasTicketMessagesGet = async (
13
+ returnGetter,
14
+
15
+ credsPayload,
16
+ ticketId,
17
+ {
18
+ params,
19
+ ...getterOptions
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ ticketId,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const getterArgs = [
32
+ credsPayload,
33
+ '/messages',
34
+ {
35
+ params: {
36
+ ticket_id: ticketId,
37
+ ...params,
38
+ },
39
+ ...getterOptions,
40
+ },
41
+ ];
42
+
43
+ return returnGetter
44
+ ? gorgiasGetter(...getterArgs)
45
+ : gorgiasGet(...getterArgs);
46
+ };
47
+
48
+ const funcApiConfig = {
49
+ argsWarden,
50
+ };
51
+
52
+ module.exports = {
53
+ gorgiasTicketMessagesGet: (...args) => gorgiasTicketMessagesGet(false, ...args),
54
+ gorgiasTicketMessagesGetter: (...args) => gorgiasTicketMessagesGet(true, ...args),
55
+ funcApiConfig,
56
+ };
57
+
58
+ /*
59
+ curl -X POST "http://localhost:8000/gorgiasTicketMessagesGet" \
60
+ -H "Content-Type: application/json" \
61
+ -d '{
62
+ "credsPayload": { "credsPath": "gorgias" },
63
+ "ticketId": "399815746",
64
+ "options": { "limit": 20 }
65
+ }'
66
+ */
@@ -0,0 +1,62 @@
1
+ // https://developers.gorgias.com/reference/update-ticket
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasClient } = require('../gorgias/gorgias.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['ticketId'],
10
+ ['ticketBody', valueProvided],
11
+ ]);
12
+
13
+ const gorgiasTicketUpdate = async (
14
+ credsPayload,
15
+ ticketId,
16
+ ticketBody,
17
+ {
18
+ inspect = false,
19
+ fetchClient = gorgiasClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ ticketId,
26
+ ticketBody,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ return fetchClient.fetch({
33
+ requestPayload: {
34
+ method: 'put',
35
+ url: `/tickets/${ ticketId }`,
36
+ body: ticketBody,
37
+ },
38
+ context: { credsPayload },
39
+ inspect,
40
+ });
41
+ };
42
+
43
+ const funcApiConfig = {
44
+ argsWarden,
45
+ };
46
+
47
+ module.exports = {
48
+ gorgiasTicketUpdate,
49
+ funcApiConfig,
50
+ };
51
+
52
+ /*
53
+ curl -X POST "http://localhost:8000/gorgiasTicketUpdate" \
54
+ -H "Content-Type: application/json" \
55
+ -d '{
56
+ "credsPayload": { "credsPath": "gorgias" },
57
+ "ticketId": "399815746",
58
+ "ticketBody": {
59
+ "status": "closed"
60
+ }
61
+ }'
62
+ */
@@ -0,0 +1,58 @@
1
+ // https://developers.gorgias.com/reference/list-tickets
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { gorgiasGet, gorgiasGetter } = require('../gorgias/gorgiasGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const gorgiasTicketsGet = async (
12
+ returnGetter,
13
+
14
+ credsPayload,
15
+ getterOptions = {},
16
+ ) => {
17
+
18
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
19
+ credsPayload,
20
+ });
21
+ if (rejectResponse) {
22
+ return rejectResponse;
23
+ }
24
+
25
+ const getterArgs = [
26
+ credsPayload,
27
+ '/tickets',
28
+ getterOptions,
29
+ ];
30
+
31
+ return returnGetter
32
+ ? gorgiasGetter(...getterArgs)
33
+ : gorgiasGet(...getterArgs);
34
+ };
35
+
36
+ const funcApiConfig = {
37
+ argsWarden,
38
+ };
39
+
40
+ module.exports = {
41
+ gorgiasTicketsGet: (...args) => gorgiasTicketsGet(false, ...args),
42
+ gorgiasTicketsGetter: (...args) => gorgiasTicketsGet(true, ...args),
43
+ funcApiConfig,
44
+ };
45
+
46
+ /*
47
+ curl -X POST "http://localhost:8000/gorgiasTicketsGet" \
48
+ -H "Content-Type: application/json" \
49
+ -d '{
50
+ "credsPayload": { "credsPath": "gorgias" },
51
+ "options": {
52
+ "params": {
53
+ "order_by": "created_datetime:desc"
54
+ },
55
+ "limit": 10
56
+ }
57
+ }'
58
+ */