sr-npm 1.7.17 → 1.7.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.
package/backend/data.js CHANGED
@@ -337,9 +337,10 @@ async function createApiKeyCollectionAndFillIt() {
337
337
  await createCollectionIfMissing(COLLECTIONS.API_KEY, COLLECTIONS_FIELDS.API_KEY);
338
338
  console.log("Getting the smart token");
339
339
  const token = await getSmartToken();
340
+ console.log("token is : ", token);
340
341
  console.log("Inserting the smart token into the ApiKey collection");
341
342
  await wixData.insert("ApiKey", {
342
- token: token
343
+ token: token.value
343
344
  });
344
345
 
345
346
  console.log("Smart token inserted into the ApiKey collection");
@@ -1,9 +1,12 @@
1
1
  const { fetch } = require('wix-fetch');
2
+ const { items: wixData } = require('@wix/data');
2
3
 
3
4
  async function makeSmartRecruitersRequest(path) {
4
5
  // const baseUrl = 'https://api.smartrecruiters.com'; // PROD
5
6
  const baseUrl = 'https://aoxley54.wixstudio.com/external-template/_functions'; // TEST
6
7
  const fullUrl = `${baseUrl}${path}`;
8
+ const token = await getSmartTokenFromCMS();
9
+ console.log("token is : ", token);
7
10
  //console.log(`Making request to: ${fullUrl}`);
8
11
  try {
9
12
  const response = await fetch(fullUrl, {
@@ -11,7 +14,7 @@ async function makeSmartRecruitersRequest(path) {
11
14
  headers: {
12
15
  'Accept-Language': 'en',
13
16
  'accept': 'application/json',
14
- 'x-smarttoken': 'DCRA1-1d30ea5fe9be42d9b9ae94ff933ebef5',
17
+ 'x-smarttoken': token,
15
18
  'Cookie': 'AWSALB=GYltFw3fLKortMxHR5vIOT1CuUROyhWNIX/qL8ZnPl1/8mhOcnIsBKYslzmNJPEzSy/jvNbO+6tXpH8yqcpQJagYt57MhbKlLqTSzoNq1G/w7TjOxPGR3UTdXW0d; AWSALBCORS=GYltFw3fLKortMxHR5vIOT1CuUROyhWNIX/qL8ZnPl1/8mhOcnIsBKYslzmNJPEzSy/jvNbO+6tXpH8yqcpQJagYt57MhbKlLqTSzoNq1G/w7TjOxPGR3UTdXW0d'
16
19
  }
17
20
  });
@@ -108,6 +111,15 @@ async function fetchJobDescription(jobId) {
108
111
  return await makeSmartRecruitersRequest(`/jobs/${jobId}`);
109
112
  }
110
113
 
114
+ async function getSmartTokenFromCMS() {
115
+ const result = await wixData.query("ApiKey").limit(1).find();
116
+ if (result.items.length > 0) {
117
+ return result.items[0].token; // This is your string token
118
+ } else {
119
+ return null; // No token found
120
+ }
121
+ }
122
+
111
123
 
112
124
  module.exports = {
113
125
  fetchPositionsFromSRAPI,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.17",
3
+ "version": "1.7.19",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {