@meltwater/conversations-api-services 1.1.23 → 1.1.24

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.
@@ -14,6 +14,7 @@ var _logger = _interopRequireDefault(require("../../lib/logger.js"));
14
14
  var _loggerHelpers = require("../../lib/logger.helpers.js");
15
15
  var _linkedinNative = require("./linkedin.native.js");
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ const LINKEDIN_VERSION = '202511';
17
18
  class LinkedInApiClient {
18
19
  constructor() {
19
20
  this.credentialsAPI = new _credentialsApiClient.CredentialsApiClient();
@@ -63,7 +64,7 @@ class LinkedInApiClient {
63
64
  response = await _superagent.default.delete(query).timeout(5000).set({
64
65
  Authorization: `Bearer ${credential.token}`,
65
66
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
66
- 'LinkedIn-Version': '202311'
67
+ 'LinkedIn-Version': LINKEDIN_VERSION
67
68
  });
68
69
  } else {
69
70
  loggerChild.debug(`${documentId} - sending to linkedin `, {
@@ -74,7 +75,7 @@ class LinkedInApiClient {
74
75
  .set({
75
76
  Authorization: `Bearer ${credential.token}`,
76
77
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
77
- 'LinkedIn-Version': '202311'
78
+ 'LinkedIn-Version': LINKEDIN_VERSION
78
79
  }).send(payload);
79
80
  }
80
81
  loggerChild.info(`Native Linkedin API Like Comment Response for documentId ${documentId}`, {
@@ -184,7 +185,7 @@ class LinkedInApiClient {
184
185
  Authorization: `Bearer ${credential.token}`,
185
186
  'Content-Type': 'application/json',
186
187
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
187
- 'LinkedIn-Version': '202311'
188
+ 'LinkedIn-Version': LINKEDIN_VERSION
188
189
  }).send(body);
189
190
  response = {
190
191
  status: 200,
@@ -213,7 +214,7 @@ class LinkedInApiClient {
213
214
  Authorization: `Bearer ${credential.token}`,
214
215
  'Content-type': 'application/json',
215
216
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
216
- 'LinkedIn-Version': '202311'
217
+ 'LinkedIn-Version': LINKEDIN_VERSION
217
218
  }).send(body);
218
219
  response = {
219
220
  status: 200,
@@ -238,7 +239,7 @@ class LinkedInApiClient {
238
239
  .set({
239
240
  Authorization: `Bearer ${token}`,
240
241
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
241
- 'LinkedIn-Version': '202311'
242
+ 'LinkedIn-Version': LINKEDIN_VERSION
242
243
  });
243
244
  } catch (error) {
244
245
  loggerChild.error('Error in getAllStats', error);
@@ -292,7 +293,7 @@ class LinkedInApiClient {
292
293
  .set({
293
294
  Authorization: `Bearer ${credential.token}`,
294
295
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
295
- 'LinkedIn-Version': '202311'
296
+ 'LinkedIn-Version': LINKEDIN_VERSION
296
297
  });
297
298
  } catch (error) {
298
299
  loggerChild.error('Error in getImageMedia', error);
@@ -332,7 +333,7 @@ class LinkedInApiClient {
332
333
  .set({
333
334
  Authorization: `Bearer ${credential.token}`,
334
335
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
335
- 'LinkedIn-Version': '202311'
336
+ 'LinkedIn-Version': LINKEDIN_VERSION
336
337
  });
337
338
  } catch (error) {
338
339
  loggerChild.error('Error in getVideoMedia', error);
@@ -399,7 +400,7 @@ class LinkedInApiClient {
399
400
  'Content-Type': 'application/octet-stream',
400
401
  Authorization: `Bearer ${token}`,
401
402
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
402
- 'LinkedIn-Version': '202311'
403
+ 'LinkedIn-Version': LINKEDIN_VERSION
403
404
  }).send(data).catch(err => {
404
405
  _logger.default.error(err);
405
406
  throw err;
@@ -416,7 +417,7 @@ async function getProfile(urn, token) {
416
417
  }).timeout(5000).set({
417
418
  Authorization: `Bearer ${token}`,
418
419
  'X-RestLi-Protocol-Version': _configuration.default.get('LINKEDIN_API_VERSION'),
419
- 'LinkedIn-Version': '202311'
420
+ 'LinkedIn-Version': LINKEDIN_VERSION
420
421
  }).then(result => result.body);
421
422
  } catch (error) {
422
423
  _logger.default.error(`Failed requesting LinkedIn API for profileId ${urn}`, error);
@@ -25,7 +25,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
25
25
  const LINKEDIN_API = "https://api.linkedin.com/v2";
26
26
  const LINKEDIN_API_REST = "https://api.linkedin.com/rest";
27
27
  const LINKEDIN_API_VERSION = "2.0.0";
28
- const LINKEDIN_VERSION = "202411";
28
+ const LINKEDIN_VERSION = "202511";
29
29
  async function like(token, externalId, socialAccountId, logger) {
30
30
  let response;
31
31
  let payload = {
@@ -374,16 +374,18 @@ async function getOrganization(urn, token, logger) {
374
374
  let [,,, id] = urn.split(':');
375
375
  let organization;
376
376
  try {
377
- organization = await _superagent.default.get(`${LINKEDIN_API}/organizations/${fixedEncodeURIComponent(id)}`).query({
378
- projection: '(id,localizedName,vanityName,logoV2(original~:playableStreams))'
379
- }).timeout(5000) // 5 seconds
377
+ // Use the newer REST API endpoint instead of deprecated v2/organizations
378
+ organization = await _superagent.default.get(`${LINKEDIN_API_REST}/organizationsLookup?ids=List(${fixedEncodeURIComponent(id)})`).timeout(5000) // 5 seconds
380
379
  .set({
381
380
  Authorization: `Bearer ${token}`,
382
381
  'X-RestLi-Protocol-Version': LINKEDIN_API_VERSION,
383
382
  'LinkedIn-Version': LINKEDIN_VERSION
384
- }).then(result => result.body);
383
+ }).then(result => {
384
+ const res = result.body;
385
+ return res.results[id];
386
+ });
385
387
  } catch (error) {
386
- if (error.response.body.message.includes('ADMIN_ONLY')) {
388
+ if (error.response && error.response.body && error.response.body.message && error.response.body.message.includes('ADMIN_ONLY')) {
387
389
  return {
388
390
  id: 'private'
389
391
  };
@@ -4,6 +4,7 @@ import { CredentialsApiClient } from '../http/credentialsApi.client.js';
4
4
  import logger from '../../lib/logger.js';
5
5
  import { MeltwaterAttributes } from '../../lib/logger.helpers.js';
6
6
  import { getOrganization as getOrganizationNative, getOrganizations as getOrganizationsNative, deleteMessage as deleteMessageNative } from './linkedin.native.js';
7
+ const LINKEDIN_VERSION = '202511';
7
8
  export class LinkedInApiClient {
8
9
  constructor() {
9
10
  this.credentialsAPI = new CredentialsApiClient();
@@ -53,7 +54,7 @@ export class LinkedInApiClient {
53
54
  response = await superagent.delete(query).timeout(5000).set({
54
55
  Authorization: `Bearer ${credential.token}`,
55
56
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
56
- 'LinkedIn-Version': '202311'
57
+ 'LinkedIn-Version': LINKEDIN_VERSION
57
58
  });
58
59
  } else {
59
60
  loggerChild.debug(`${documentId} - sending to linkedin `, {
@@ -64,7 +65,7 @@ export class LinkedInApiClient {
64
65
  .set({
65
66
  Authorization: `Bearer ${credential.token}`,
66
67
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
67
- 'LinkedIn-Version': '202311'
68
+ 'LinkedIn-Version': LINKEDIN_VERSION
68
69
  }).send(payload);
69
70
  }
70
71
  loggerChild.info(`Native Linkedin API Like Comment Response for documentId ${documentId}`, {
@@ -174,7 +175,7 @@ export class LinkedInApiClient {
174
175
  Authorization: `Bearer ${credential.token}`,
175
176
  'Content-Type': 'application/json',
176
177
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
177
- 'LinkedIn-Version': '202311'
178
+ 'LinkedIn-Version': LINKEDIN_VERSION
178
179
  }).send(body);
179
180
  response = {
180
181
  status: 200,
@@ -203,7 +204,7 @@ export class LinkedInApiClient {
203
204
  Authorization: `Bearer ${credential.token}`,
204
205
  'Content-type': 'application/json',
205
206
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
206
- 'LinkedIn-Version': '202311'
207
+ 'LinkedIn-Version': LINKEDIN_VERSION
207
208
  }).send(body);
208
209
  response = {
209
210
  status: 200,
@@ -228,7 +229,7 @@ export class LinkedInApiClient {
228
229
  .set({
229
230
  Authorization: `Bearer ${token}`,
230
231
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
231
- 'LinkedIn-Version': '202311'
232
+ 'LinkedIn-Version': LINKEDIN_VERSION
232
233
  });
233
234
  } catch (error) {
234
235
  loggerChild.error('Error in getAllStats', error);
@@ -282,7 +283,7 @@ export class LinkedInApiClient {
282
283
  .set({
283
284
  Authorization: `Bearer ${credential.token}`,
284
285
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
285
- 'LinkedIn-Version': '202311'
286
+ 'LinkedIn-Version': LINKEDIN_VERSION
286
287
  });
287
288
  } catch (error) {
288
289
  loggerChild.error('Error in getImageMedia', error);
@@ -322,7 +323,7 @@ export class LinkedInApiClient {
322
323
  .set({
323
324
  Authorization: `Bearer ${credential.token}`,
324
325
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
325
- 'LinkedIn-Version': '202311'
326
+ 'LinkedIn-Version': LINKEDIN_VERSION
326
327
  });
327
328
  } catch (error) {
328
329
  loggerChild.error('Error in getVideoMedia', error);
@@ -389,7 +390,7 @@ export class LinkedInApiClient {
389
390
  'Content-Type': 'application/octet-stream',
390
391
  Authorization: `Bearer ${token}`,
391
392
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
392
- 'LinkedIn-Version': '202311'
393
+ 'LinkedIn-Version': LINKEDIN_VERSION
393
394
  }).send(data).catch(err => {
394
395
  logger.error(err);
395
396
  throw err;
@@ -405,7 +406,7 @@ export async function getProfile(urn, token) {
405
406
  }).timeout(5000).set({
406
407
  Authorization: `Bearer ${token}`,
407
408
  'X-RestLi-Protocol-Version': configuration.get('LINKEDIN_API_VERSION'),
408
- 'LinkedIn-Version': '202311'
409
+ 'LinkedIn-Version': LINKEDIN_VERSION
409
410
  }).then(result => result.body);
410
411
  } catch (error) {
411
412
  logger.error(`Failed requesting LinkedIn API for profileId ${urn}`, error);
@@ -3,7 +3,7 @@ import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.j
3
3
  const LINKEDIN_API = "https://api.linkedin.com/v2";
4
4
  const LINKEDIN_API_REST = "https://api.linkedin.com/rest";
5
5
  const LINKEDIN_API_VERSION = "2.0.0";
6
- const LINKEDIN_VERSION = "202411";
6
+ const LINKEDIN_VERSION = "202511";
7
7
  export async function like(token, externalId, socialAccountId, logger) {
8
8
  let response;
9
9
  let payload = {
@@ -352,16 +352,18 @@ export async function getOrganization(urn, token, logger) {
352
352
  let [,,, id] = urn.split(':');
353
353
  let organization;
354
354
  try {
355
- organization = await superagent.get(`${LINKEDIN_API}/organizations/${fixedEncodeURIComponent(id)}`).query({
356
- projection: '(id,localizedName,vanityName,logoV2(original~:playableStreams))'
357
- }).timeout(5000) // 5 seconds
355
+ // Use the newer REST API endpoint instead of deprecated v2/organizations
356
+ organization = await superagent.get(`${LINKEDIN_API_REST}/organizationsLookup?ids=List(${fixedEncodeURIComponent(id)})`).timeout(5000) // 5 seconds
358
357
  .set({
359
358
  Authorization: `Bearer ${token}`,
360
359
  'X-RestLi-Protocol-Version': LINKEDIN_API_VERSION,
361
360
  'LinkedIn-Version': LINKEDIN_VERSION
362
- }).then(result => result.body);
361
+ }).then(result => {
362
+ const res = result.body;
363
+ return res.results[id];
364
+ });
363
365
  } catch (error) {
364
- if (error.response.body.message.includes('ADMIN_ONLY')) {
366
+ if (error.response && error.response.body && error.response.body.message && error.response.body.message.includes('ADMIN_ONLY')) {
365
367
  return {
366
368
  id: 'private'
367
369
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "Repository to contain all conversations api services shared across our services",
5
5
  "main": "dist/cjs/data-access/index.js",
6
6
  "module": "dist/esm/data-access/index.js",
@@ -9,6 +9,8 @@ import {
9
9
  deleteMessage as deleteMessageNative,
10
10
  } from './linkedin.native.js'
11
11
 
12
+ const LINKEDIN_VERSION = '202511';
13
+
12
14
  export class LinkedInApiClient {
13
15
  constructor() {
14
16
  this.credentialsAPI = new CredentialsApiClient();
@@ -71,7 +73,7 @@ export class LinkedInApiClient {
71
73
  'X-RestLi-Protocol-Version': configuration.get(
72
74
  'LINKEDIN_API_VERSION'
73
75
  ),
74
- 'LinkedIn-Version': '202311',
76
+ 'LinkedIn-Version': LINKEDIN_VERSION,
75
77
  });
76
78
  } else {
77
79
  loggerChild.debug(`${documentId} - sending to linkedin `, {
@@ -86,7 +88,7 @@ export class LinkedInApiClient {
86
88
  'X-RestLi-Protocol-Version': configuration.get(
87
89
  'LINKEDIN_API_VERSION'
88
90
  ),
89
- 'LinkedIn-Version': '202311',
91
+ 'LinkedIn-Version': LINKEDIN_VERSION,
90
92
  })
91
93
  .send(payload);
92
94
  }
@@ -221,7 +223,7 @@ export class LinkedInApiClient {
221
223
  'X-RestLi-Protocol-Version': configuration.get(
222
224
  'LINKEDIN_API_VERSION'
223
225
  ),
224
- 'LinkedIn-Version': '202311',
226
+ 'LinkedIn-Version': LINKEDIN_VERSION,
225
227
  })
226
228
  .send(body);
227
229
 
@@ -272,7 +274,7 @@ export class LinkedInApiClient {
272
274
  'X-RestLi-Protocol-Version': configuration.get(
273
275
  'LINKEDIN_API_VERSION'
274
276
  ),
275
- 'LinkedIn-Version': '202311',
277
+ 'LinkedIn-Version': LINKEDIN_VERSION,
276
278
  })
277
279
  .send(body);
278
280
 
@@ -312,7 +314,7 @@ export class LinkedInApiClient {
312
314
  'X-RestLi-Protocol-Version': configuration.get(
313
315
  'LINKEDIN_API_VERSION'
314
316
  ),
315
- 'LinkedIn-Version': '202311',
317
+ 'LinkedIn-Version': LINKEDIN_VERSION,
316
318
  });
317
319
  } catch (error) {
318
320
  loggerChild.error('Error in getAllStats', error);
@@ -380,7 +382,7 @@ export class LinkedInApiClient {
380
382
  'X-RestLi-Protocol-Version': configuration.get(
381
383
  'LINKEDIN_API_VERSION'
382
384
  ),
383
- 'LinkedIn-Version': '202311',
385
+ 'LinkedIn-Version': LINKEDIN_VERSION,
384
386
  });
385
387
  } catch (error) {
386
388
  loggerChild.error('Error in getImageMedia', error);
@@ -439,7 +441,7 @@ export class LinkedInApiClient {
439
441
  'X-RestLi-Protocol-Version': configuration.get(
440
442
  'LINKEDIN_API_VERSION'
441
443
  ),
442
- 'LinkedIn-Version': '202311',
444
+ 'LinkedIn-Version': LINKEDIN_VERSION,
443
445
  });
444
446
  } catch (error) {
445
447
  loggerChild.error('Error in getVideoMedia', error);
@@ -513,7 +515,7 @@ export class LinkedInApiClient {
513
515
  'X-RestLi-Protocol-Version': configuration.get(
514
516
  'LINKEDIN_API_VERSION'
515
517
  ),
516
- 'LinkedIn-Version': '202311',
518
+ 'LinkedIn-Version': LINKEDIN_VERSION,
517
519
  })
518
520
  .send(data)
519
521
  .catch((err) => {
@@ -540,7 +542,7 @@ export async function getProfile(urn, token) {
540
542
  'X-RestLi-Protocol-Version': configuration.get(
541
543
  'LINKEDIN_API_VERSION'
542
544
  ),
543
- 'LinkedIn-Version': '202311',
545
+ 'LinkedIn-Version': LINKEDIN_VERSION,
544
546
  })
545
547
  .then((result) => result.body);
546
548
  } catch (error) {
@@ -5,7 +5,7 @@ import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.j
5
5
  const LINKEDIN_API = "https://api.linkedin.com/v2";
6
6
  const LINKEDIN_API_REST = "https://api.linkedin.com/rest";
7
7
  const LINKEDIN_API_VERSION = "2.0.0";
8
- const LINKEDIN_VERSION = "202411";
8
+ const LINKEDIN_VERSION = "202511";
9
9
 
10
10
  export async function like(token, externalId, socialAccountId, logger) {
11
11
  let response;
@@ -474,21 +474,21 @@ export async function getOrganization(urn, token, logger) {
474
474
 
475
475
  let organization;
476
476
  try {
477
+ // Use the newer REST API endpoint instead of deprecated v2/organizations
477
478
  organization = await superagent
478
- .get(`${LINKEDIN_API}/organizations/${fixedEncodeURIComponent(id)}`)
479
- .query({
480
- projection:
481
- '(id,localizedName,vanityName,logoV2(original~:playableStreams))',
482
- })
479
+ .get(`${LINKEDIN_API_REST}/organizationsLookup?ids=List(${fixedEncodeURIComponent(id)})`)
483
480
  .timeout(5000) // 5 seconds
484
481
  .set({
485
482
  Authorization: `Bearer ${token}`,
486
483
  'X-RestLi-Protocol-Version': LINKEDIN_API_VERSION,
487
484
  'LinkedIn-Version': LINKEDIN_VERSION,
488
485
  })
489
- .then((result) => result.body);
486
+ .then((result) => {
487
+ const res = result.body;
488
+ return res.results[id];
489
+ });
490
490
  } catch (error) {
491
- if (error.response.body.message.includes('ADMIN_ONLY')) {
491
+ if (error.response && error.response.body && error.response.body.message && error.response.body.message.includes('ADMIN_ONLY')) {
492
492
  return { id: 'private' };
493
493
  }
494
494