Built motion from commit d9028345.|2.5.43
[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 _0x500c=['catch','CreateSquareMessage','SquareMessage','create','body','options','raw','lodash','util','moment','bluebird','randomstring','../../mysqldb','rpc','jayson/promise','client','http','request','then','info','debug','SquareMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','SquareMessage,\x20%s,\x20%s','message','result'];(function(_0x479ea0,_0x48ddbb){var _0x4a1af7=function(_0x16ab41){while(--_0x16ab41){_0x479ea0['push'](_0x479ea0['shift']());}};_0x4a1af7(++_0x48ddbb);}(_0x500c,0x19d));var _0xc500=function(_0x513e26,_0xfc523){_0x513e26=_0x513e26-0x0;var _0x36bc1a=_0x500c[_0x513e26];return _0x36bc1a;};'use strict';var _=require(_0xc500('0x0'));var util=require(_0xc500('0x1'));var moment=require(_0xc500('0x2'));var BPromise=require(_0xc500('0x3'));var rs=require(_0xc500('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc500('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xc500('0x6'));var config=require('../../config/environment');var jayson=require(_0xc500('0x7'));var client=jayson[_0xc500('0x8')][_0xc500('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x463ab3,_0x1f632f,_0x4ff9a4){return new BPromise(function(_0x4e982a,_0x1437a7){return client[_0xc500('0xa')](_0x463ab3,_0x4ff9a4)[_0xc500('0xb')](function(_0x2927ff){logger[_0xc500('0xc')]('SquareMessage,\x20%s,\x20%s',_0x1f632f,'request\x20sent');logger[_0xc500('0xd')](_0xc500('0xe'),_0x1f632f,_0xc500('0xf'),JSON[_0xc500('0x10')](_0x2927ff));if(_0x2927ff['error']){if(_0x2927ff[_0xc500('0x11')][_0xc500('0x12')]===0x1f4){logger['error']('SquareMessage,\x20%s,\x20%s',_0x1f632f,_0x2927ff['error']['message']);return _0x1437a7(_0x2927ff[_0xc500('0x11')]['message']);}logger[_0xc500('0x11')](_0xc500('0x13'),_0x1f632f,_0x2927ff[_0xc500('0x11')][_0xc500('0x14')]);return _0x4e982a(_0x2927ff[_0xc500('0x11')][_0xc500('0x14')]);}else{logger['info'](_0xc500('0x13'),_0x1f632f,_0xc500('0xf'));_0x4e982a(_0x2927ff[_0xc500('0x15')][_0xc500('0x14')]);}})[_0xc500('0x16')](function(_0x488c49){logger[_0xc500('0x11')](_0xc500('0x13'),_0x1f632f,_0x488c49);_0x1437a7(_0x488c49);});});}exports[_0xc500('0x17')]=function(_0x3e5b1f){var _0x294249=this;return new Promise(function(_0x59bd7b,_0x3d934a){return db[_0xc500('0x18')][_0xc500('0x19')](_0x3e5b1f[_0xc500('0x1a')],{'raw':_0x3e5b1f[_0xc500('0x1b')]?_0x3e5b1f[_0xc500('0x1b')][_0xc500('0x1c')]===undefined?!![]:![]:!![]})['then'](function(_0x1bcbec){logger[_0xc500('0xc')]('CreateSquareMessage',_0x3e5b1f);logger['debug'](_0xc500('0x17'),_0x3e5b1f,JSON[_0xc500('0x10')](_0x1bcbec));_0x59bd7b(_0x1bcbec);})[_0xc500('0x16')](function(_0x2ed06d){logger['error']('CreateSquareMessage',_0x2ed06d[_0xc500('0x14')],_0x3e5b1f);_0x3d934a(_0x294249['error'](0x1f4,_0x2ed06d[_0xc500('0x14')]));});});};