c86c387b2a492632454c66aee358428d1327154d
[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 _0xb6fd=['../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','CreateSquareMessage','SquareMessage','create','body','options','util','bluebird','randomstring','ioredis'];(function(_0x899e57,_0x33bfea){var _0x53cbf2=function(_0x515b04){while(--_0x515b04){_0x899e57['push'](_0x899e57['shift']());}};_0x53cbf2(++_0x33bfea);}(_0xb6fd,0x9e));var _0xdb6f=function(_0x32c95a,_0x286956){_0x32c95a=_0x32c95a-0x0;var _0x435c3a=_0xb6fd[_0x32c95a];return _0x435c3a;};'use strict';var _=require('lodash');var util=require(_0xdb6f('0x0'));var moment=require('moment');var BPromise=require(_0xdb6f('0x1'));var rs=require(_0xdb6f('0x2'));var fs=require('fs');var Redis=require(_0xdb6f('0x3'));var db=require(_0xdb6f('0x4'))['db'];var utils=require(_0xdb6f('0x5'));var logger=require(_0xdb6f('0x6'))('rpc');var config=require(_0xdb6f('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xdb6f('0x8')][_0xdb6f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3218d7,_0x3a737b,_0x466ab6){return new BPromise(function(_0x560d6d,_0x52ccc2){return client[_0xdb6f('0xa')](_0x3218d7,_0x466ab6)[_0xdb6f('0xb')](function(_0x1431bd){logger[_0xdb6f('0xc')](_0xdb6f('0xd'),_0x3a737b,_0xdb6f('0xe'));logger[_0xdb6f('0xf')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x3a737b,_0xdb6f('0xe'),JSON[_0xdb6f('0x10')](_0x1431bd));if(_0x1431bd['error']){if(_0x1431bd[_0xdb6f('0x11')][_0xdb6f('0x12')]===0x1f4){logger['error']('SquareMessage,\x20%s,\x20%s',_0x3a737b,_0x1431bd[_0xdb6f('0x11')][_0xdb6f('0x13')]);return _0x52ccc2(_0x1431bd['error'][_0xdb6f('0x13')]);}logger[_0xdb6f('0x11')](_0xdb6f('0xd'),_0x3a737b,_0x1431bd['error'][_0xdb6f('0x13')]);return _0x560d6d(_0x1431bd['error'][_0xdb6f('0x13')]);}else{logger[_0xdb6f('0xc')](_0xdb6f('0xd'),_0x3a737b,_0xdb6f('0xe'));_0x560d6d(_0x1431bd[_0xdb6f('0x14')]['message']);}})[_0xdb6f('0x15')](function(_0x5768c2){logger[_0xdb6f('0x11')]('SquareMessage,\x20%s,\x20%s',_0x3a737b,_0x5768c2);_0x52ccc2(_0x5768c2);});});}exports[_0xdb6f('0x16')]=function(_0x303b6b){var _0xf06da0=this;return new Promise(function(_0x8ff9c3,_0x18547b){return db[_0xdb6f('0x17')][_0xdb6f('0x18')](_0x303b6b[_0xdb6f('0x19')],{'raw':_0x303b6b[_0xdb6f('0x1a')]?_0x303b6b[_0xdb6f('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0xdb6f('0xb')](function(_0x615178){logger[_0xdb6f('0xc')](_0xdb6f('0x16'),_0x303b6b);logger[_0xdb6f('0xf')](_0xdb6f('0x16'),_0x303b6b,JSON[_0xdb6f('0x10')](_0x615178));_0x8ff9c3(_0x615178);})[_0xdb6f('0x15')](function(_0x2530e3){logger['error']('CreateSquareMessage',_0x2530e3[_0xdb6f('0x13')],_0x303b6b);_0x18547b(_0xf06da0[_0xdb6f('0x11')](0x1f4,_0x2530e3[_0xdb6f('0x13')]));});});};