Built motion from commit (unavailable).|2.5.1
[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 _0x8ca9=['lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','jayson/promise','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','CreateSquareMessage','SquareMessage','create','body','options'];(function(_0x356538,_0x1087c2){var _0x1a3199=function(_0x54b3d2){while(--_0x54b3d2){_0x356538['push'](_0x356538['shift']());}};_0x1a3199(++_0x1087c2);}(_0x8ca9,0x9c));var _0x98ca=function(_0x4a5635,_0x443b90){_0x4a5635=_0x4a5635-0x0;var _0x18d602=_0x8ca9[_0x4a5635];return _0x18d602;};'use strict';var _=require(_0x98ca('0x0'));var util=require(_0x98ca('0x1'));var moment=require(_0x98ca('0x2'));var BPromise=require(_0x98ca('0x3'));var rs=require(_0x98ca('0x4'));var fs=require('fs');var Redis=require(_0x98ca('0x5'));var db=require(_0x98ca('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x98ca('0x7'));var config=require('../../config/environment');var jayson=require(_0x98ca('0x8'));var client=jayson['client'][_0x98ca('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xca4097,_0x18c349,_0x2852a0){return new BPromise(function(_0x323c95,_0x28a37a){return client[_0x98ca('0xa')](_0xca4097,_0x2852a0)[_0x98ca('0xb')](function(_0x277c29){logger[_0x98ca('0xc')](_0x98ca('0xd'),_0x18c349,_0x98ca('0xe'));logger[_0x98ca('0xf')](_0x98ca('0x10'),_0x18c349,_0x98ca('0xe'),JSON[_0x98ca('0x11')](_0x277c29));if(_0x277c29[_0x98ca('0x12')]){if(_0x277c29[_0x98ca('0x12')]['code']===0x1f4){logger[_0x98ca('0x12')](_0x98ca('0xd'),_0x18c349,_0x277c29[_0x98ca('0x12')][_0x98ca('0x13')]);return _0x28a37a(_0x277c29['error'][_0x98ca('0x13')]);}logger[_0x98ca('0x12')](_0x98ca('0xd'),_0x18c349,_0x277c29[_0x98ca('0x12')][_0x98ca('0x13')]);return _0x323c95(_0x277c29[_0x98ca('0x12')][_0x98ca('0x13')]);}else{logger['info'](_0x98ca('0xd'),_0x18c349,_0x98ca('0xe'));_0x323c95(_0x277c29[_0x98ca('0x14')][_0x98ca('0x13')]);}})['catch'](function(_0x238c1a){logger[_0x98ca('0x12')](_0x98ca('0xd'),_0x18c349,_0x238c1a);_0x28a37a(_0x238c1a);});});}exports[_0x98ca('0x15')]=function(_0x4523bb){var _0x3ca209=this;return new Promise(function(_0x28c8a6,_0x3dc670){return db[_0x98ca('0x16')][_0x98ca('0x17')](_0x4523bb[_0x98ca('0x18')],{'raw':_0x4523bb['options']?_0x4523bb[_0x98ca('0x19')]['raw']===undefined?!![]:![]:!![]})[_0x98ca('0xb')](function(_0x2fe568){logger['info']('CreateSquareMessage',_0x4523bb);logger[_0x98ca('0xf')](_0x98ca('0x15'),_0x4523bb,JSON[_0x98ca('0x11')](_0x2fe568));_0x28c8a6(_0x2fe568);})['catch'](function(_0x2f7742){logger[_0x98ca('0x12')]('CreateSquareMessage',_0x2f7742[_0x98ca('0x13')],_0x4523bb);_0x3dc670(_0x3ca209['error'](0x1f4,_0x2f7742[_0x98ca('0x13')]));});});};