Skip to content

Commit

Permalink
feat(smssync): initialize router factory
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Feb 25, 2020
1 parent 2109d4f commit 09219db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { Message, Email, SMS, Push } = require('./lib/message.model');
const messageRouter = require('./lib/message.http.router');
const Campaign = require('./lib/campaign.model');
const campaignRouter = require('./lib/campaign.http.router');
const smssyncRouterFactory = require('./lib/smssync.http.router');

/**
* @module postman
Expand All @@ -31,11 +32,8 @@ function postman(integration) {
Campaign.fetchContacts = (criteria, done) => fetchContacts(criteria, done);
}

// initialize smssync pull sms transport
// TODO: initialize smssync http router
// TODO: resolve passing Message model around
// postman.smssyncRouter = smssyncTransport.init(integration, Message).transport;
postman.smssyncRouter = {};
// initialize smssync http router
postman.smssyncRouter = smssyncRouterFactory(integration);

// return initialized postman
return postman;
Expand Down
17 changes: 17 additions & 0 deletions lib/smssync.http.router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const { mergeObjects } = require('@lykmapipo/common');
const { smssync } = require('smssync');

const transport = require('./transports/smssync');

/* expose smssync integration router */
module.exports = exports = integration => {
// initialize transport to get options
transport.init();

// compile smssync router
const options = mergeObjects(transport.options, integration);
const router = smssync(options);
return router;
};

0 comments on commit 09219db

Please sign in to comment.