@vasrefil/api-toolkit 1.12.5 → 1.12.6

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/dist/env.d.ts CHANGED
@@ -32,6 +32,10 @@ declare const env: {
32
32
  BASEURL: string;
33
33
  API_KEY: string;
34
34
  };
35
+ NOTIFICATION: {
36
+ BASEURL: string;
37
+ API_KEY: string;
38
+ };
35
39
  AIRBRAKE: {
36
40
  PROJECT_ID: number;
37
41
  PROJECT_KEY: string;
package/dist/env.js CHANGED
@@ -34,13 +34,17 @@ const env = {
34
34
  API_KEY: process.env.VASREFIL_EDUCATION_API_KEY
35
35
  },
36
36
  LOG: {
37
- BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://log-api.vasrefil.com' : 'https://log-api-dev.vasrefil.com',
37
+ BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://log-api.vasrefil.com' : 'https://log-api.dev.vasrefil.com',
38
38
  API_KEY: process.env.VASREFIL_LOG_API_KEY
39
39
  },
40
40
  LOYALTY: {
41
41
  BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://loyalty-api.vasrefil.com' : 'https://loyalty-api-dev.vasrefil.com',
42
42
  API_KEY: process.env.VASREFIL_LOYALTY_API_KEY
43
43
  },
44
+ NOTIFICATION: {
45
+ BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://notification-api.vasrefil.com' : 'https://notification-api-dev.vasrefil.com',
46
+ API_KEY: process.env.VASREFIL_NOTIFICATION_API_KEY
47
+ },
44
48
  AIRBRAKE: {
45
49
  PROJECT_ID: process.env.AIRBRAKE_PROJECT_ID,
46
50
  PROJECT_KEY: process.env.AIRBRAKE_PROJECT_KEY
@@ -16,3 +16,7 @@ export interface ISendPushPayload {
16
16
  external_ids: string[];
17
17
  job_options?: BulkJobOptions;
18
18
  }
19
+ export interface ILinkExternalIdPushPayload {
20
+ subscription_id: string;
21
+ external_id: string;
22
+ }
@@ -9,6 +9,7 @@ declare class AdminAuthMidWare_ extends RootService {
9
9
  edu_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
10
10
  log_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
11
11
  loyalty_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
12
+ notification_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
12
13
  }
13
14
  declare const AdminAuthMidWare: AdminAuthMidWare_;
14
15
  export { AdminAuthMidWare };
@@ -55,6 +55,7 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
55
55
  this.edu_auth = this.validate_auth(env_1.default.EDUCATION.API_KEY, 'EDU_ADMIN_AUTH_MIDWARE');
56
56
  this.log_auth = this.validate_auth(env_1.default.LOG.API_KEY, 'LOG_ADMIN_AUTH_MIDWARE');
57
57
  this.loyalty_auth = this.validate_auth(env_1.default.LOYALTY.API_KEY, 'LOYALTY_ADMIN_AUTH_MIDWARE');
58
+ this.notification_auth = this.validate_auth(env_1.default.NOTIFICATION.API_KEY, 'NOTIFICATION_ADMIN_AUTH_MIDWARE');
58
59
  }
59
60
  }
60
61
  const AdminAuthMidWare = new AdminAuthMidWare_;
@@ -6,4 +6,3 @@ export * from './interfaces';
6
6
  export * from './middlewares';
7
7
  export * from './services';
8
8
  export * from './redis';
9
- export * from './background-jobs';
@@ -22,4 +22,3 @@ __exportStar(require("./interfaces"), exports);
22
22
  __exportStar(require("./middlewares"), exports);
23
23
  __exportStar(require("./services"), exports);
24
24
  __exportStar(require("./redis"), exports);
25
- __exportStar(require("./background-jobs"), exports);
@@ -4,5 +4,5 @@ export * from './logger.util';
4
4
  export * from './log.util';
5
5
  export * from './go-mailer.util';
6
6
  export * from './report.util';
7
- export * from './email.util';
7
+ export * from './notification.util';
8
8
  export * from './ip.util';
@@ -20,5 +20,5 @@ __exportStar(require("./logger.util"), exports);
20
20
  __exportStar(require("./log.util"), exports);
21
21
  __exportStar(require("./go-mailer.util"), exports);
22
22
  __exportStar(require("./report.util"), exports);
23
- __exportStar(require("./email.util"), exports);
23
+ __exportStar(require("./notification.util"), exports);
24
24
  __exportStar(require("./ip.util"), exports);
@@ -0,0 +1,8 @@
1
+ import { ISendEmailPayload, ISendPushPayload } from '../interfaces/notification.interface';
2
+ declare class NotificationUtil_ {
3
+ send_email: (payload: ISendEmailPayload[]) => Promise<any>;
4
+ send_push: (payload: ISendPushPayload[]) => Promise<any>;
5
+ private api_request;
6
+ }
7
+ export declare const NotificationUtil: NotificationUtil_;
8
+ export {};
@@ -0,0 +1,56 @@
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
+ exports.NotificationUtil = void 0;
7
+ const helpers_1 = require("../helpers");
8
+ const api_request_util_1 = require("./api-request.util");
9
+ const env_1 = __importDefault(require("../env"));
10
+ class NotificationUtil_ {
11
+ constructor() {
12
+ this.send_email = async (payload) => {
13
+ try {
14
+ const resp = await this.api_request({
15
+ method: 'POST',
16
+ endpoint: 'emails/send',
17
+ body: payload
18
+ });
19
+ return resp;
20
+ }
21
+ catch (error) {
22
+ const err = helpers_1.RequestHelper.get_error(error);
23
+ throw err;
24
+ }
25
+ };
26
+ this.send_push = async (payload) => {
27
+ try {
28
+ const resp = await this.api_request({
29
+ method: 'POST',
30
+ endpoint: 'push/send',
31
+ body: payload
32
+ });
33
+ return resp;
34
+ }
35
+ catch (error) {
36
+ const err = helpers_1.RequestHelper.get_error(error);
37
+ throw err;
38
+ }
39
+ };
40
+ this.api_request = async (request) => {
41
+ try {
42
+ const resp = await (0, api_request_util_1.ApiRequest)({
43
+ baseurl: env_1.default.NOTIFICATION.BASEURL,
44
+ apiKey: env_1.default.NOTIFICATION.API_KEY,
45
+ ...request,
46
+ });
47
+ return resp;
48
+ }
49
+ catch (error) {
50
+ const err = helpers_1.RequestHelper.get_error(error);
51
+ console.log(`Send Email error: ${err?.message}`);
52
+ }
53
+ };
54
+ }
55
+ }
56
+ exports.NotificationUtil = new NotificationUtil_();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vasrefil/api-toolkit",
3
3
  "description": "This is Vasrefil API toolkit",
4
- "version": "1.12.5",
4
+ "version": "1.12.6",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",