Built motion from commit 753c950e.|2.5.42
[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 _0x104d=['info','request\x20sent','debug','stringify','error','code','message','SquareMessage,\x20%s,\x20%s','result','catch','CreateSquareMessage','SquareMessage','create','options','raw','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then'];(function(_0x597c69,_0x19032a){var _0x7aad9b=function(_0x588f52){while(--_0x588f52){_0x597c69['push'](_0x597c69['shift']());}};_0x7aad9b(++_0x19032a);}(_0x104d,0x114));var _0xd104=function(_0x49d0e3,_0x359aed){_0x49d0e3=_0x49d0e3-0x0;var _0x26d388=_0x104d[_0x49d0e3];return _0x26d388;};'use strict';var _=require(_0xd104('0x0'));var util=require(_0xd104('0x1'));var moment=require(_0xd104('0x2'));var BPromise=require('bluebird');var rs=require(_0xd104('0x3'));var fs=require('fs');var Redis=require(_0xd104('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xd104('0x5'));var logger=require(_0xd104('0x6'))(_0xd104('0x7'));var config=require(_0xd104('0x8'));var jayson=require(_0xd104('0x9'));var client=jayson[_0xd104('0xa')][_0xd104('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3afc7f,_0x29bfd7,_0xb62c30){return new BPromise(function(_0x30526e,_0x12d3fb){return client[_0xd104('0xc')](_0x3afc7f,_0xb62c30)[_0xd104('0xd')](function(_0x2caaf6){logger[_0xd104('0xe')]('SquareMessage,\x20%s,\x20%s',_0x29bfd7,_0xd104('0xf'));logger[_0xd104('0x10')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x29bfd7,_0xd104('0xf'),JSON[_0xd104('0x11')](_0x2caaf6));if(_0x2caaf6[_0xd104('0x12')]){if(_0x2caaf6[_0xd104('0x12')][_0xd104('0x13')]===0x1f4){logger[_0xd104('0x12')]('SquareMessage,\x20%s,\x20%s',_0x29bfd7,_0x2caaf6[_0xd104('0x12')][_0xd104('0x14')]);return _0x12d3fb(_0x2caaf6['error'][_0xd104('0x14')]);}logger['error'](_0xd104('0x15'),_0x29bfd7,_0x2caaf6[_0xd104('0x12')]['message']);return _0x30526e(_0x2caaf6['error']['message']);}else{logger[_0xd104('0xe')](_0xd104('0x15'),_0x29bfd7,_0xd104('0xf'));_0x30526e(_0x2caaf6[_0xd104('0x16')]['message']);}})[_0xd104('0x17')](function(_0x5ca11f){logger['error'](_0xd104('0x15'),_0x29bfd7,_0x5ca11f);_0x12d3fb(_0x5ca11f);});});}exports[_0xd104('0x18')]=function(_0x5e7439){var _0x1d0641=this;return new Promise(function(_0x5b28b9,_0x3557a4){return db[_0xd104('0x19')][_0xd104('0x1a')](_0x5e7439['body'],{'raw':_0x5e7439[_0xd104('0x1b')]?_0x5e7439[_0xd104('0x1b')][_0xd104('0x1c')]===undefined?!![]:![]:!![]})[_0xd104('0xd')](function(_0x36417d){logger['info'](_0xd104('0x18'),_0x5e7439);logger['debug'](_0xd104('0x18'),_0x5e7439,JSON[_0xd104('0x11')](_0x36417d));_0x5b28b9(_0x36417d);})[_0xd104('0x17')](function(_0x2bde2d){logger['error'](_0xd104('0x18'),_0x2bde2d[_0xd104('0x14')],_0x5e7439);_0x3557a4(_0x1d0641[_0xd104('0x12')](0x1f4,_0x2bde2d[_0xd104('0x14')]));});});};