Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / squareMessage / squareMessage.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xd111=['create','options','raw','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','SquareMessage,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','info','result','CreateSquareMessage','SquareMessage'];(function(_0x4283be,_0x5a8bde){var _0x494293=function(_0x4344e0){while(--_0x4344e0){_0x4283be['push'](_0x4283be['shift']());}};_0x494293(++_0x5a8bde);}(_0xd111,0xe4));var _0x1d11=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xd111[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x1d11('0x0'));var util=require('util');var moment=require(_0x1d11('0x1'));var BPromise=require(_0x1d11('0x2'));var rs=require(_0x1d11('0x3'));var fs=require('fs');var Redis=require(_0x1d11('0x4'));var db=require(_0x1d11('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x1d11('0x6'))(_0x1d11('0x7'));var config=require(_0x1d11('0x8'));var jayson=require(_0x1d11('0x9'));var client=jayson[_0x1d11('0xa')][_0x1d11('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x572ffa,_0x234b19,_0x1f3387){return new BPromise(function(_0x16c3a3,_0x3bcbb8){return client['request'](_0x572ffa,_0x1f3387)[_0x1d11('0xc')](function(_0x333dc5){logger['info'](_0x1d11('0xd'),_0x234b19,'request\x20sent');logger[_0x1d11('0xe')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x234b19,_0x1d11('0xf'),JSON[_0x1d11('0x10')](_0x333dc5));if(_0x333dc5['error']){if(_0x333dc5[_0x1d11('0x11')][_0x1d11('0x12')]===0x1f4){logger['error'](_0x1d11('0xd'),_0x234b19,_0x333dc5[_0x1d11('0x11')][_0x1d11('0x13')]);return _0x3bcbb8(_0x333dc5[_0x1d11('0x11')][_0x1d11('0x13')]);}logger[_0x1d11('0x11')](_0x1d11('0xd'),_0x234b19,_0x333dc5[_0x1d11('0x11')]['message']);return _0x16c3a3(_0x333dc5[_0x1d11('0x11')][_0x1d11('0x13')]);}else{logger[_0x1d11('0x14')]('SquareMessage,\x20%s,\x20%s',_0x234b19,_0x1d11('0xf'));_0x16c3a3(_0x333dc5[_0x1d11('0x15')][_0x1d11('0x13')]);}})['catch'](function(_0x34fd9c){logger[_0x1d11('0x11')](_0x1d11('0xd'),_0x234b19,_0x34fd9c);_0x3bcbb8(_0x34fd9c);});});}exports[_0x1d11('0x16')]=function(_0x38af14){var _0x28ae2c=this;return new Promise(function(_0x24d0f4,_0x3a1695){return db[_0x1d11('0x17')][_0x1d11('0x18')](_0x38af14['body'],{'raw':_0x38af14[_0x1d11('0x19')]?_0x38af14[_0x1d11('0x19')][_0x1d11('0x1a')]===undefined?!![]:![]:!![]})[_0x1d11('0xc')](function(_0x3164a0){logger['info'](_0x1d11('0x16'),_0x38af14);logger[_0x1d11('0xe')]('CreateSquareMessage',_0x38af14,JSON['stringify'](_0x3164a0));_0x24d0f4(_0x3164a0);})[_0x1d11('0x1b')](function(_0x4674b1){logger[_0x1d11('0x11')](_0x1d11('0x16'),_0x4674b1[_0x1d11('0x13')],_0x38af14);_0x3a1695(_0x28ae2c[_0x1d11('0x11')](0x1f4,_0x4674b1[_0x1d11('0x13')]));});});};