Skip to content

Commit

Permalink
feat: expose Push message factory
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed May 27, 2019
1 parent 24499a7 commit 649e5f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ MONGODB_URI=
DEFAULT_TRANSPORT_NAME=echo
DEFAULT_SMTP_TRANSPORT_NAME=smtp
DEFAULT_SMS_TRANSPORT_NAME=tz-ega-sms
DEFAULT_PUSH_TRANSPORT_NAME=fcm-push


# TZ EGA SMS TRANSPORT
Expand Down
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const Message = require(path.join(libPath, 'message.model'));


/* constants */
const { TYPE_EMAIL, TYPE_SMS } = Message;
const { TYPE_EMAIL, TYPE_SMS, TYPE_PUSH } = Message;
const DEFAULT_SMTP_TRANSPORT_NAME = getString('DEFAULT_SMTP_TRANSPORT_NAME');
const DEFAULT_SMS_TRANSPORT_NAME = getString('DEFAULT_SMS_TRANSPORT_NAME');
const DEFAULT_PUSH_TRANSPORT_NAME = getString('DEFAULT_PUSH_TRANSPORT_NAME');


/**
Expand Down Expand Up @@ -52,6 +53,14 @@ postman.SMS = function SMS(payload) {
};


/* export postman push message factory */
postman.Push = function Push(payload) {
const _payload =
_.merge({}, { transport: DEFAULT_PUSH_TRANSPORT_NAME }, payload, { type: TYPE_PUSH });
return new Message(_payload);
};


/* export postman utils */
postman.utils = require(path.join(libPath, 'utils'));

Expand Down

0 comments on commit 649e5f4

Please sign in to comment.