Built motion from commit a61a4a20.|2.5.46
[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 _0x314f=['options','raw','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','SquareMessage,\x20%s,\x20%s','CreateSquareMessage','SquareMessage','create','body'];(function(_0x305e24,_0x3164a0){var _0x58f152=function(_0x30a5fb){while(--_0x30a5fb){_0x305e24['push'](_0x305e24['shift']());}};_0x58f152(++_0x3164a0);}(_0x314f,0x14d));var _0xf314=function(_0x4c9b76,_0x1e23e0){_0x4c9b76=_0x4c9b76-0x0;var _0x181598=_0x314f[_0x4c9b76];return _0x181598;};'use strict';var _=require(_0xf314('0x0'));var util=require(_0xf314('0x1'));var moment=require(_0xf314('0x2'));var BPromise=require('bluebird');var rs=require(_0xf314('0x3'));var fs=require('fs');var Redis=require(_0xf314('0x4'));var db=require(_0xf314('0x5'))['db'];var utils=require(_0xf314('0x6'));var logger=require(_0xf314('0x7'))('rpc');var config=require(_0xf314('0x8'));var jayson=require(_0xf314('0x9'));var client=jayson[_0xf314('0xa')][_0xf314('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3214e6,_0x55e628,_0x12cf41){return new BPromise(function(_0x2e75f0,_0x241f42){return client[_0xf314('0xc')](_0x3214e6,_0x12cf41)[_0xf314('0xd')](function(_0x18b16c){logger[_0xf314('0xe')]('SquareMessage,\x20%s,\x20%s',_0x55e628,_0xf314('0xf'));logger[_0xf314('0x10')](_0xf314('0x11'),_0x55e628,_0xf314('0xf'),JSON[_0xf314('0x12')](_0x18b16c));if(_0x18b16c[_0xf314('0x13')]){if(_0x18b16c[_0xf314('0x13')][_0xf314('0x14')]===0x1f4){logger[_0xf314('0x13')]('SquareMessage,\x20%s,\x20%s',_0x55e628,_0x18b16c['error'][_0xf314('0x15')]);return _0x241f42(_0x18b16c['error'][_0xf314('0x15')]);}logger[_0xf314('0x13')](_0xf314('0x16'),_0x55e628,_0x18b16c[_0xf314('0x13')][_0xf314('0x15')]);return _0x2e75f0(_0x18b16c[_0xf314('0x13')][_0xf314('0x15')]);}else{logger[_0xf314('0xe')](_0xf314('0x16'),_0x55e628,'request\x20sent');_0x2e75f0(_0x18b16c['result']['message']);}})['catch'](function(_0x15e442){logger['error'](_0xf314('0x16'),_0x55e628,_0x15e442);_0x241f42(_0x15e442);});});}exports[_0xf314('0x17')]=function(_0x3a459e){var _0x36af3f=this;return new Promise(function(_0x193c97,_0x48b18d){return db[_0xf314('0x18')][_0xf314('0x19')](_0x3a459e[_0xf314('0x1a')],{'raw':_0x3a459e['options']?_0x3a459e[_0xf314('0x1b')][_0xf314('0x1c')]===undefined?!![]:![]:!![]})[_0xf314('0xd')](function(_0x4fa3d4){logger['info'](_0xf314('0x17'),_0x3a459e);logger[_0xf314('0x10')](_0xf314('0x17'),_0x3a459e,JSON[_0xf314('0x12')](_0x4fa3d4));_0x193c97(_0x4fa3d4);})[_0xf314('0x1d')](function(_0x16a9e1){logger[_0xf314('0x13')]('CreateSquareMessage',_0x16a9e1[_0xf314('0x15')],_0x3a459e);_0x48b18d(_0x36af3f[_0xf314('0x13')](0x1f4,_0x16a9e1[_0xf314('0x15')]));});});};