Built motion from commit 52c8a02d.|2.6.29
[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 _0x22d5=['ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','then','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','SquareMessage','create','body','options','raw','CreateSquareMessage','lodash','util','moment','bluebird','randomstring'];(function(_0x25d269,_0x1d8a46){var _0x1016c8=function(_0x2193a3){while(--_0x2193a3){_0x25d269['push'](_0x25d269['shift']());}};_0x1016c8(++_0x1d8a46);}(_0x22d5,0x14b));var _0x522d=function(_0x5d00ae,_0x330a15){_0x5d00ae=_0x5d00ae-0x0;var _0x58f6b9=_0x22d5[_0x5d00ae];return _0x58f6b9;};'use strict';var _=require(_0x522d('0x0'));var util=require(_0x522d('0x1'));var moment=require(_0x522d('0x2'));var BPromise=require(_0x522d('0x3'));var rs=require(_0x522d('0x4'));var fs=require('fs');var Redis=require(_0x522d('0x5'));var db=require(_0x522d('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x522d('0x7'))('rpc');var config=require(_0x522d('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x522d('0x9')][_0x522d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xcdd9b8,_0x67e1d3,_0xbe4bb3){return new BPromise(function(_0x2e18f6,_0x543b53){return client['request'](_0xcdd9b8,_0xbe4bb3)[_0x522d('0xb')](function(_0x19c348){logger['info'](_0x522d('0xc'),_0x67e1d3,_0x522d('0xd'));logger[_0x522d('0xe')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x67e1d3,_0x522d('0xd'),JSON[_0x522d('0xf')](_0x19c348));if(_0x19c348['error']){if(_0x19c348[_0x522d('0x10')][_0x522d('0x11')]===0x1f4){logger[_0x522d('0x10')](_0x522d('0xc'),_0x67e1d3,_0x19c348[_0x522d('0x10')]['message']);return _0x543b53(_0x19c348['error'][_0x522d('0x12')]);}logger[_0x522d('0x10')](_0x522d('0xc'),_0x67e1d3,_0x19c348['error'][_0x522d('0x12')]);return _0x2e18f6(_0x19c348[_0x522d('0x10')][_0x522d('0x12')]);}else{logger[_0x522d('0x13')](_0x522d('0xc'),_0x67e1d3,_0x522d('0xd'));_0x2e18f6(_0x19c348[_0x522d('0x14')][_0x522d('0x12')]);}})[_0x522d('0x15')](function(_0x4b07da){logger[_0x522d('0x10')](_0x522d('0xc'),_0x67e1d3,_0x4b07da);_0x543b53(_0x4b07da);});});}exports['CreateSquareMessage']=function(_0x241478){var _0x9976b9=this;return new Promise(function(_0x8e1327,_0xb27276){return db[_0x522d('0x16')][_0x522d('0x17')](_0x241478[_0x522d('0x18')],{'raw':_0x241478[_0x522d('0x19')]?_0x241478['options'][_0x522d('0x1a')]===undefined?!![]:![]:!![]})[_0x522d('0xb')](function(_0x13a8f4){logger['info'](_0x522d('0x1b'),_0x241478);logger[_0x522d('0xe')](_0x522d('0x1b'),_0x241478,JSON[_0x522d('0xf')](_0x13a8f4));_0x8e1327(_0x13a8f4);})['catch'](function(_0x1c1670){logger[_0x522d('0x10')](_0x522d('0x1b'),_0x1c1670[_0x522d('0x12')],_0x241478);_0xb27276(_0x9976b9[_0x522d('0x10')](0x1f4,_0x1c1670[_0x522d('0x12')]));});});};