a9c7cf164a21fa66a0ce59d40fcfb63a760e6cd9
[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 _0x336a=['bluebird','randomstring','ioredis','../../config/logger','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','catch','SquareMessage','create','body','raw','CreateSquareMessage','lodash','util'];(function(_0xd95a4f,_0x5b2faf){var _0x913026=function(_0x4e9711){while(--_0x4e9711){_0xd95a4f['push'](_0xd95a4f['shift']());}};_0x913026(++_0x5b2faf);}(_0x336a,0x1ec));var _0xa336=function(_0x7e2eb0,_0x17cd58){_0x7e2eb0=_0x7e2eb0-0x0;var _0xd92de4=_0x336a[_0x7e2eb0];return _0xd92de4;};'use strict';var _=require(_0xa336('0x0'));var util=require(_0xa336('0x1'));var moment=require('moment');var BPromise=require(_0xa336('0x2'));var rs=require(_0xa336('0x3'));var fs=require('fs');var Redis=require(_0xa336('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xa336('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0xa336('0x6'));var client=jayson[_0xa336('0x7')][_0xa336('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x52227c,_0x158174,_0x402bb8){return new BPromise(function(_0xf3c41c,_0x2cdb99){return client[_0xa336('0x9')](_0x52227c,_0x402bb8)[_0xa336('0xa')](function(_0x144ef1){logger[_0xa336('0xb')]('SquareMessage,\x20%s,\x20%s',_0x158174,_0xa336('0xc'));logger[_0xa336('0xd')](_0xa336('0xe'),_0x158174,_0xa336('0xc'),JSON[_0xa336('0xf')](_0x144ef1));if(_0x144ef1[_0xa336('0x10')]){if(_0x144ef1['error'][_0xa336('0x11')]===0x1f4){logger[_0xa336('0x10')]('SquareMessage,\x20%s,\x20%s',_0x158174,_0x144ef1[_0xa336('0x10')][_0xa336('0x12')]);return _0x2cdb99(_0x144ef1[_0xa336('0x10')][_0xa336('0x12')]);}logger[_0xa336('0x10')](_0xa336('0x13'),_0x158174,_0x144ef1[_0xa336('0x10')][_0xa336('0x12')]);return _0xf3c41c(_0x144ef1[_0xa336('0x10')][_0xa336('0x12')]);}else{logger[_0xa336('0xb')]('SquareMessage,\x20%s,\x20%s',_0x158174,_0xa336('0xc'));_0xf3c41c(_0x144ef1['result'][_0xa336('0x12')]);}})[_0xa336('0x14')](function(_0x4dd3a9){logger[_0xa336('0x10')]('SquareMessage,\x20%s,\x20%s',_0x158174,_0x4dd3a9);_0x2cdb99(_0x4dd3a9);});});}exports['CreateSquareMessage']=function(_0x582327){var _0x1f3404=this;return new Promise(function(_0x2c4f73,_0x95c923){return db[_0xa336('0x15')][_0xa336('0x16')](_0x582327[_0xa336('0x17')],{'raw':_0x582327['options']?_0x582327['options'][_0xa336('0x18')]===undefined?!![]:![]:!![]})[_0xa336('0xa')](function(_0x2d348d){logger[_0xa336('0xb')](_0xa336('0x19'),_0x582327);logger[_0xa336('0xd')](_0xa336('0x19'),_0x582327,JSON['stringify'](_0x2d348d));_0x2c4f73(_0x2d348d);})[_0xa336('0x14')](function(_0x103a0b){logger[_0xa336('0x10')](_0xa336('0x19'),_0x103a0b[_0xa336('0x12')],_0x582327);_0x95c923(_0x1f3404[_0xa336('0x10')](0x1f4,_0x103a0b[_0xa336('0x12')]));});});};