Built motion from commit efa66e19.|2.6.22
[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 _0x0e9a=['SquareMessage','create','body','options','raw','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','request','then','info','SquareMessage,\x20%s,\x20%s','debug','SquareMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','CreateSquareMessage'];(function(_0x187ee1,_0x3fd1e6){var _0x388160=function(_0x542dd2){while(--_0x542dd2){_0x187ee1['push'](_0x187ee1['shift']());}};_0x388160(++_0x3fd1e6);}(_0x0e9a,0x18d));var _0xa0e9=function(_0x44b0ad,_0x2a34c7){_0x44b0ad=_0x44b0ad-0x0;var _0x4fbe13=_0x0e9a[_0x44b0ad];return _0x4fbe13;};'use strict';var _=require(_0xa0e9('0x0'));var util=require('util');var moment=require(_0xa0e9('0x1'));var BPromise=require(_0xa0e9('0x2'));var rs=require(_0xa0e9('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa0e9('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa0e9('0x5'))('rpc');var config=require(_0xa0e9('0x6'));var jayson=require(_0xa0e9('0x7'));var client=jayson[_0xa0e9('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1d4015,_0xb593e9,_0x2b0689){return new BPromise(function(_0x4930f5,_0xd1d3fe){return client[_0xa0e9('0x9')](_0x1d4015,_0x2b0689)[_0xa0e9('0xa')](function(_0x28e841){logger[_0xa0e9('0xb')](_0xa0e9('0xc'),_0xb593e9,'request\x20sent');logger[_0xa0e9('0xd')](_0xa0e9('0xe'),_0xb593e9,_0xa0e9('0xf'),JSON[_0xa0e9('0x10')](_0x28e841));if(_0x28e841['error']){if(_0x28e841[_0xa0e9('0x11')][_0xa0e9('0x12')]===0x1f4){logger[_0xa0e9('0x11')](_0xa0e9('0xc'),_0xb593e9,_0x28e841['error']['message']);return _0xd1d3fe(_0x28e841[_0xa0e9('0x11')][_0xa0e9('0x13')]);}logger[_0xa0e9('0x11')](_0xa0e9('0xc'),_0xb593e9,_0x28e841['error'][_0xa0e9('0x13')]);return _0x4930f5(_0x28e841[_0xa0e9('0x11')]['message']);}else{logger[_0xa0e9('0xb')](_0xa0e9('0xc'),_0xb593e9,_0xa0e9('0xf'));_0x4930f5(_0x28e841[_0xa0e9('0x14')][_0xa0e9('0x13')]);}})[_0xa0e9('0x15')](function(_0x15e07c){logger['error'](_0xa0e9('0xc'),_0xb593e9,_0x15e07c);_0xd1d3fe(_0x15e07c);});});}exports[_0xa0e9('0x16')]=function(_0xb3cbd8){var _0x5bfb67=this;return new Promise(function(_0x3b099b,_0x19dc4e){return db[_0xa0e9('0x17')][_0xa0e9('0x18')](_0xb3cbd8[_0xa0e9('0x19')],{'raw':_0xb3cbd8[_0xa0e9('0x1a')]?_0xb3cbd8[_0xa0e9('0x1a')][_0xa0e9('0x1b')]===undefined?!![]:![]:!![]})[_0xa0e9('0xa')](function(_0x2dc1b7){logger[_0xa0e9('0xb')](_0xa0e9('0x16'),_0xb3cbd8);logger[_0xa0e9('0xd')](_0xa0e9('0x16'),_0xb3cbd8,JSON[_0xa0e9('0x10')](_0x2dc1b7));_0x3b099b(_0x2dc1b7);})['catch'](function(_0x2f1431){logger[_0xa0e9('0x11')]('CreateSquareMessage',_0x2f1431[_0xa0e9('0x13')],_0xb3cbd8);_0x19dc4e(_0x5bfb67['error'](0x1f4,_0x2f1431[_0xa0e9('0x13')]));});});};