85dd9fe9ce850544b4d9cefa24a77b28c68b4490
[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 _0x2f77=['CreateSquareMessage','SquareMessage','create','body','options','raw','lodash','util','moment','bluebird','ioredis','../../config/utils','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','result','catch'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x2f77,0x156));var _0x72f7=function(_0x5194a8,_0x3296ae){_0x5194a8=_0x5194a8-0x0;var _0x1e95b7=_0x2f77[_0x5194a8];return _0x1e95b7;};'use strict';var _=require(_0x72f7('0x0'));var util=require(_0x72f7('0x1'));var moment=require(_0x72f7('0x2'));var BPromise=require(_0x72f7('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x72f7('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x72f7('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x72f7('0x6'));var client=jayson[_0x72f7('0x7')][_0x72f7('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x41c761,_0x4f83de,_0x23eb03){return new BPromise(function(_0x47be2d,_0x19ee46){return client[_0x72f7('0x9')](_0x41c761,_0x23eb03)[_0x72f7('0xa')](function(_0x6beb2c){logger[_0x72f7('0xb')]('SquareMessage,\x20%s,\x20%s',_0x4f83de,_0x72f7('0xc'));logger[_0x72f7('0xd')](_0x72f7('0xe'),_0x4f83de,_0x72f7('0xc'),JSON[_0x72f7('0xf')](_0x6beb2c));if(_0x6beb2c[_0x72f7('0x10')]){if(_0x6beb2c[_0x72f7('0x10')][_0x72f7('0x11')]===0x1f4){logger[_0x72f7('0x10')]('SquareMessage,\x20%s,\x20%s',_0x4f83de,_0x6beb2c[_0x72f7('0x10')][_0x72f7('0x12')]);return _0x19ee46(_0x6beb2c['error'][_0x72f7('0x12')]);}logger[_0x72f7('0x10')](_0x72f7('0x13'),_0x4f83de,_0x6beb2c[_0x72f7('0x10')][_0x72f7('0x12')]);return _0x47be2d(_0x6beb2c[_0x72f7('0x10')][_0x72f7('0x12')]);}else{logger[_0x72f7('0xb')]('SquareMessage,\x20%s,\x20%s',_0x4f83de,_0x72f7('0xc'));_0x47be2d(_0x6beb2c[_0x72f7('0x14')][_0x72f7('0x12')]);}})[_0x72f7('0x15')](function(_0xc81aa9){logger['error'](_0x72f7('0x13'),_0x4f83de,_0xc81aa9);_0x19ee46(_0xc81aa9);});});}exports[_0x72f7('0x16')]=function(_0x4efe39){var _0x18cdeb=this;return new Promise(function(_0x2778ed,_0x188abe){return db[_0x72f7('0x17')][_0x72f7('0x18')](_0x4efe39[_0x72f7('0x19')],{'raw':_0x4efe39['options']?_0x4efe39[_0x72f7('0x1a')][_0x72f7('0x1b')]===undefined?!![]:![]:!![]})['then'](function(_0x2ebca3){logger['info'](_0x72f7('0x16'),_0x4efe39);logger['debug'](_0x72f7('0x16'),_0x4efe39,JSON[_0x72f7('0xf')](_0x2ebca3));_0x2778ed(_0x2ebca3);})[_0x72f7('0x15')](function(_0x17d827){logger['error']('CreateSquareMessage',_0x17d827[_0x72f7('0x12')],_0x4efe39);_0x188abe(_0x18cdeb['error'](0x1f4,_0x17d827[_0x72f7('0x12')]));});});};