@8ms/helpers 1.35.3 → 1.36.2

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/api/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare enum State {
2
+ CANCELLED = "CANCELLED",
2
3
  ERROR = "ERROR",
3
4
  IDLE = "IDLE",
4
5
  PENDING = "PENDING",
package/api/index.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.unexpectedError = exports.State = void 0;
4
4
  var State;
5
5
  (function (State) {
6
+ State["CANCELLED"] = "CANCELLED";
6
7
  State["ERROR"] = "ERROR";
7
8
  State["IDLE"] = "IDLE";
8
9
  State["PENDING"] = "PENDING";
@@ -0,0 +1,11 @@
1
+ import ApiResponse from '../api/ApiResponse';
2
+ export type Delete = {
3
+ config?: object;
4
+ url: string;
5
+ };
6
+ /**
7
+ * Make a DELETE request.
8
+ * Cant use the function name delete as its reserved
9
+ */
10
+ declare const deleteRequest: (props: Delete) => Promise<ApiResponse>;
11
+ export default deleteRequest;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const ApiResponse_1 = __importDefault(require("../api/ApiResponse"));
8
+ /**
9
+ * Make a DELETE request.
10
+ * Cant use the function name delete as its reserved
11
+ */
12
+ const deleteRequest = async (props) => {
13
+ const response = await axios_1.default.delete(props.url, props?.config ?? {})
14
+ .then(async (response) => {
15
+ // Is API response
16
+ if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
17
+ return new ApiResponse_1.default(response.data);
18
+ }
19
+ // General success - some APIs report 201
20
+ else if (response.status >= 200 && response.status <= 299) {
21
+ return (new ApiResponse_1.default()).setToSuccess({
22
+ body: response.data,
23
+ });
24
+ }
25
+ // Error
26
+ return (new ApiResponse_1.default()).setToError({
27
+ body: response.data,
28
+ error: response.statusText,
29
+ });
30
+ })
31
+ .catch(error => {
32
+ // Error
33
+ return (new ApiResponse_1.default()).setToError({
34
+ error: error.message,
35
+ });
36
+ });
37
+ return response;
38
+ };
39
+ exports.default = deleteRequest;
@@ -222,7 +222,6 @@ var Country;
222
222
  Country[Country["YEMEN"] = 2887] = "YEMEN";
223
223
  Country[Country["ZAMBIA"] = 2894] = "ZAMBIA";
224
224
  })(Country || (exports.Country = Country = {}));
225
- ;
226
225
  var Month;
227
226
  (function (Month) {
228
227
  Month["JANUARY"] = "JANUARY";
@@ -1,17 +1,18 @@
1
1
  import { Country, Month, Network } from "./";
2
2
  export type Request = {
3
- customerId: string;
4
- geoTargetConstants?: Country[];
3
+ countries?: Country[] | null;
4
+ customerId?: string;
5
5
  historicalMetricsOptions?: {
6
- start_month: Month;
7
- start_year: number;
8
- end_month: Month;
9
- end_year: number;
6
+ startMonth: Month;
7
+ startYear: number;
8
+ endMonth: Month;
9
+ endYear: number;
10
10
  };
11
11
  includeAdultKeywords?: boolean;
12
12
  keywordPlanNetwork?: Network;
13
- keywords: string[];
14
- language?: null;
13
+ queries?: string[];
14
+ language?: number | null;
15
+ url?: string;
15
16
  };
16
17
  declare const request: Request;
17
18
  export default request;
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const _1 = require("./");
4
4
  const request = {
5
- customerId: '',
6
- geoTargetConstants: [],
5
+ countries: [],
6
+ customerId: "",
7
7
  historicalMetricsOptions: null,
8
8
  includeAdultKeywords: false,
9
9
  keywordPlanNetwork: _1.Network.GOOGLE_SEARCH_ONLY,
10
- keywords: [],
10
+ queries: [],
11
11
  language: null,
12
12
  };
13
13
  exports.default = request;
@@ -6,6 +6,7 @@ type Month = {
6
6
  year: number;
7
7
  };
8
8
  type Keyword = {
9
+ payload: object;
9
10
  keyword: string;
10
11
  avgCpc: number;
11
12
  avgSearchVolume: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.35.3",
4
+ "version": "1.36.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"