@meltwater/conversations-api-services 1.0.27 → 1.0.28

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.
@@ -19,8 +19,6 @@ exports.unlike = unlike;
19
19
  var _superagent = _interopRequireDefault(require("superagent"));
20
20
  var _externalIdHelpers = require("../../lib/externalId.helpers.js");
21
21
  var _loggerHelpers = require("../../lib/logger.helpers.js");
22
- var _httpError = require("../../errors/http-error.js");
23
- var _engageError = require("../../errors/engage-error.js");
24
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
23
  const FACEBOOK_URL = 'https://graph.facebook.com';
26
24
  async function shareCount(token, externalId, logger) {
@@ -306,7 +304,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
306
304
  (0, _loggerHelpers.loggerError)(logger, `Failed to call facebook api`, err);
307
305
  }
308
306
  if (response.status) {
309
- throw new _httpError.EngageHttpError(response.status, response.statusText, response.body, response.headers);
307
+ throw new Error(response.statusText);
310
308
  }
311
309
  throw err;
312
310
  }
@@ -314,7 +312,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
314
312
  logger.error(logger, `Failed to call facebook api`, {
315
313
  responseBody: JSON.stringify(response.body)
316
314
  });
317
- throw new _engageError.EngageError(response.status, `Failed to call facebook api ${response.body}`);
315
+ throw new Error(`Failed to call facebook api ${response.body}`);
318
316
  }
319
317
  return response;
320
318
  }
@@ -1,8 +1,6 @@
1
1
  import superagent from 'superagent';
2
2
  import { removePrefix } from '../../lib/externalId.helpers.js';
3
3
  import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.js';
4
- import { EngageHttpError } from '../../errors/http-error.js';
5
- import { EngageError } from '../../errors/engage-error.js';
6
4
  const FACEBOOK_URL = 'https://graph.facebook.com';
7
5
  export async function shareCount(token, externalId, logger) {
8
6
  try {
@@ -287,7 +285,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
287
285
  loggerError(logger, `Failed to call facebook api`, err);
288
286
  }
289
287
  if (response.status) {
290
- throw new EngageHttpError(response.status, response.statusText, response.body, response.headers);
288
+ throw new Error(response.statusText);
291
289
  }
292
290
  throw err;
293
291
  }
@@ -295,7 +293,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
295
293
  logger.error(logger, `Failed to call facebook api`, {
296
294
  responseBody: JSON.stringify(response.body)
297
295
  });
298
- throw new EngageError(response.status, `Failed to call facebook api ${response.body}`);
296
+ throw new Error(`Failed to call facebook api ${response.body}`);
299
297
  }
300
298
  return response;
301
299
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
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",
@@ -1,8 +1,6 @@
1
1
  import superagent from 'superagent';
2
2
  import { removePrefix } from '../../lib/externalId.helpers.js';
3
3
  import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.js';
4
- import { EngageHttpError } from '../../errors/http-error.js';
5
- import { EngageError } from '../../errors/engage-error.js';
6
4
 
7
5
  const FACEBOOK_URL = 'https://graph.facebook.com';
8
6
 
@@ -477,7 +475,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
477
475
  );
478
476
  }
479
477
  if(response.status){
480
- throw new EngageHttpError(response.status, response.statusText, response.body, response.headers);
478
+ throw new Error(response.statusText);
481
479
  }
482
480
  throw err;
483
481
  }
@@ -487,8 +485,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
487
485
  `Failed to call facebook api`,
488
486
  { responseBody: JSON.stringify(response.body) }
489
487
  );
490
- throw new EngageError(
491
- response.status,
488
+ throw new Error(
492
489
  `Failed to call facebook api ${response.body}`
493
490
  );
494
491
  }
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.EngageError = void 0;
7
- class EngageError extends Error {
8
- code;
9
- constructor(code, message) {
10
- super(message);
11
- Object.setPrototypeOf(this, new.target.prototype);
12
- this.name = this.constructor.name;
13
- this.code = code;
14
- }
15
- }
16
- exports.EngageError = EngageError;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.EngageHttpError = void 0;
7
- var _engageError = require("./engage-error");
8
- class EngageHttpError extends _engageError.EngageError {
9
- status;
10
- statusText;
11
- response;
12
- headers;
13
- constructor(status, statusText, response, headers) {
14
- super(`HTTP ${status}: ${statusText}`, statusText);
15
- Object.setPrototypeOf(this, new.target.prototype);
16
- this.name = this.constructor.name;
17
- this.status = status;
18
- this.statusText = statusText;
19
- this.response = response;
20
- this.headers = headers;
21
- }
22
- }
23
- exports.EngageHttpError = EngageHttpError;
@@ -1,9 +0,0 @@
1
- export class EngageError extends Error {
2
- code;
3
- constructor(code, message) {
4
- super(message);
5
- Object.setPrototypeOf(this, new.target.prototype);
6
- this.name = this.constructor.name;
7
- this.code = code;
8
- }
9
- }
@@ -1,16 +0,0 @@
1
- import { EngageError } from "./engage-error";
2
- export class EngageHttpError extends EngageError {
3
- status;
4
- statusText;
5
- response;
6
- headers;
7
- constructor(status, statusText, response, headers) {
8
- super(`HTTP ${status}: ${statusText}`, statusText);
9
- Object.setPrototypeOf(this, new.target.prototype);
10
- this.name = this.constructor.name;
11
- this.status = status;
12
- this.statusText = statusText;
13
- this.response = response;
14
- this.headers = headers;
15
- }
16
- }
@@ -1,11 +0,0 @@
1
- export class EngageError extends Error {
2
- code;
3
-
4
- constructor(code, message) {
5
- super(message);
6
- Object.setPrototypeOf(this, new.target.prototype);
7
-
8
- this.name = this.constructor.name;
9
- this.code = code;
10
- }
11
- }
@@ -1,19 +0,0 @@
1
- import { EngageError } from "./engage-error";
2
-
3
- export class EngageHttpError extends EngageError {
4
- status;
5
- statusText;
6
- response;
7
- headers;
8
-
9
- constructor(status, statusText, response, headers) {
10
- super(`HTTP ${status}: ${statusText}`, statusText);
11
- Object.setPrototypeOf(this, new.target.prototype);
12
-
13
- this.name = this.constructor.name;
14
- this.status = status;
15
- this.statusText = statusText;
16
- this.response = response;
17
- this.headers = headers;
18
- }
19
- }