@meltwater/conversations-api-services 1.0.16 → 1.0.18

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": "@meltwater/conversations-api-services",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Repository to contain all conversations api services shared across our services",
5
5
  "type": "module",
6
6
  "main": "src/data-access/index.js",
@@ -316,72 +316,7 @@ export class LinkedInApiClient {
316
316
  }
317
317
  }
318
318
 
319
- async getProfile(urn, token) {
320
- let [, , , id] = urn.split(':');
321
319
 
322
- let profile;
323
- try {
324
- profile = await superagent
325
- .get(`${configuration.get('LINKEDIN_API')}/people/(id:${id})`)
326
- .query({
327
- projection:
328
- '(id,localizedFirstName,localizedLastName,vanityName,profilePicture(displayImage~:playableStreams))',
329
- })
330
- .timeout(5000)
331
- .set({
332
- Authorization: `Bearer ${token}`,
333
- 'X-RestLi-Protocol-Version': configuration.get(
334
- 'LINKEDIN_API_VERSION'
335
- ),
336
- 'LinkedIn-Version': '202311',
337
- })
338
- .then((result) => result.body);
339
- } catch (error) {
340
- logger.error(
341
- `Failed requesting LinkedIn API for profileId ${urn}`,
342
- error
343
- );
344
- return;
345
- }
346
-
347
- logger.info(`Finished requesting LinkedIn API for profileId ${urn}`);
348
-
349
- return profile;
350
- }
351
-
352
- async getOrganization(urn, token) {
353
- let [, , , id] = urn.split(':');
354
-
355
- let organization;
356
- try {
357
- organization = await superagent
358
- .get(`${configuration.get('LINKEDIN_API')}/organizations/${id}`)
359
- .query({
360
- projection:
361
- '(id,localizedName,vanityName,logoV2(original~:playableStreams))',
362
- })
363
- .timeout(5000) // 5 seconds
364
- .set({
365
- Authorization: `Bearer ${token}`,
366
- 'X-RestLi-Protocol-Version': configuration.get(
367
- 'LINKEDIN_API_VERSION'
368
- ),
369
- 'LinkedIn-Version': '202311',
370
- })
371
- .then((result) => result.body);
372
- } catch (error) {
373
- logger.error(
374
- `Failed requesting LinkedIn API for organizationId ${urn}`,
375
- error
376
- );
377
- }
378
-
379
- logger.info(
380
- `Finished requesting LinkedIn API for organizationId ${urn}`
381
- );
382
-
383
- return organization;
384
- }
385
320
 
386
321
  async getAllStats(externalId, token) {
387
322
  let response = {};
@@ -653,6 +588,72 @@ export class LinkedInApiClient {
653
588
  }
654
589
  }
655
590
 
591
+ export async function getProfile(urn, token) {
592
+ let [, , , id] = urn.split(':');
593
+
594
+ let profile;
595
+ try {
596
+ profile = await superagent
597
+ .get(`${configuration.get('LINKEDIN_API')}/people/(id:${id})`)
598
+ .query({
599
+ projection:
600
+ '(id,localizedFirstName,localizedLastName,vanityName,profilePicture(displayImage~:playableStreams))',
601
+ })
602
+ .timeout(5000)
603
+ .set({
604
+ Authorization: `Bearer ${token}`,
605
+ 'X-RestLi-Protocol-Version': configuration.get(
606
+ 'LINKEDIN_API_VERSION'
607
+ ),
608
+ 'LinkedIn-Version': '202311',
609
+ })
610
+ .then((result) => result.body);
611
+ } catch (error) {
612
+ logger.error(
613
+ `Failed requesting LinkedIn API for profileId ${urn}`,
614
+ error
615
+ );
616
+ return;
617
+ }
618
+
619
+ logger.info(`Finished requesting LinkedIn API for profileId ${urn}`);
620
+
621
+ return profile;
622
+ }
623
+
624
+ export async function getOrganization(urn, token) {
625
+ let [, , , id] = urn.split(':');
626
+
627
+ let organization;
628
+ try {
629
+ organization = await superagent
630
+ .get(`${configuration.get('LINKEDIN_API')}/organizations/${id}`)
631
+ .query({
632
+ projection:
633
+ '(id,localizedName,vanityName,logoV2(original~:playableStreams))',
634
+ })
635
+ .timeout(5000) // 5 seconds
636
+ .set({
637
+ Authorization: `Bearer ${token}`,
638
+ 'X-RestLi-Protocol-Version': configuration.get(
639
+ 'LINKEDIN_API_VERSION'
640
+ ),
641
+ 'LinkedIn-Version': '202311',
642
+ })
643
+ .then((result) => result.body);
644
+ } catch (error) {
645
+ logger.error(
646
+ `Failed requesting LinkedIn API for organizationId ${urn}`,
647
+ error
648
+ );
649
+ }
650
+
651
+ logger.info(
652
+ `Finished requesting LinkedIn API for organizationId ${urn}`
653
+ );
654
+
655
+ return organization;
656
+ }
656
657
  function fixedEncodeURIComponent(str) {
657
658
  return encodeURIComponent(str).replace('(', '%28').replace(')', '%29');
658
659
  }
@@ -9,7 +9,7 @@ import { IdentityServicesClient } from './http/identityServices.client.js';
9
9
  import { InstagramApiClient } from './http/instagramApi.client.js';
10
10
  import { InstagramVideoClient } from './http/InstagramVideoClient.js';
11
11
  import { IRClient } from './http/ir.client.js';
12
- import { LinkedInApiClient } from './http/linkedInApi.client.js';
12
+ import { LinkedInApiClient, getOrganization, getProfile } from './http/linkedInApi.client.js';
13
13
  import { TikTokApiClient } from './http/tiktokApi.client.js';
14
14
  import { MasfClient } from './http/masf.client.js';
15
15
  import { WarpZoneApiClient } from './http/WarpZoneApi.client.js';
@@ -22,6 +22,10 @@ const DocumentHelperFunctions = {
22
22
  ...applicationTagFunctions,
23
23
  ...hiddenHelpers,
24
24
  }
25
+ const LinkedInHelpers = {
26
+ getOrganization,
27
+ getProfile,
28
+ }
25
29
 
26
30
  export {
27
31
  awsS3Client,
@@ -40,4 +44,5 @@ export {
40
44
  MasfClient,
41
45
  WarpZoneApiClient,
42
46
  DocumentHelperFunctions,
47
+ LinkedInHelpers,
43
48
  };
@@ -78,6 +78,5 @@ export function isMention({
78
78
  retIsMention = true;
79
79
  }
80
80
  }
81
- console.log('isMention '+retIsMention);
82
81
  return retIsMention;
83
82
  }