Built motion from commit b5413ace.|2.6.9
[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 _0xdfc7=['client','http','request','then','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','CreateSquareMessage','SquareMessage','create','body','options','raw','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise'];(function(_0x2f1846,_0x436713){var _0x39a0f5=function(_0x9eb021){while(--_0x9eb021){_0x2f1846['push'](_0x2f1846['shift']());}};_0x39a0f5(++_0x436713);}(_0xdfc7,0x6e));var _0x7dfc=function(_0x6ca7f4,_0x51a5df){_0x6ca7f4=_0x6ca7f4-0x0;var _0x494fa6=_0xdfc7[_0x6ca7f4];return _0x494fa6;};'use strict';var _=require('lodash');var util=require(_0x7dfc('0x0'));var moment=require(_0x7dfc('0x1'));var BPromise=require(_0x7dfc('0x2'));var rs=require(_0x7dfc('0x3'));var fs=require('fs');var Redis=require(_0x7dfc('0x4'));var db=require(_0x7dfc('0x5'))['db'];var utils=require(_0x7dfc('0x6'));var logger=require(_0x7dfc('0x7'))('rpc');var config=require(_0x7dfc('0x8'));var jayson=require(_0x7dfc('0x9'));var client=jayson[_0x7dfc('0xa')][_0x7dfc('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x12449d,_0x540d74,_0xf0f66e){return new BPromise(function(_0x2ab04a,_0x204032){return client[_0x7dfc('0xc')](_0x12449d,_0xf0f66e)[_0x7dfc('0xd')](function(_0x1eb40e){logger['info'](_0x7dfc('0xe'),_0x540d74,_0x7dfc('0xf'));logger[_0x7dfc('0x10')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x540d74,_0x7dfc('0xf'),JSON[_0x7dfc('0x11')](_0x1eb40e));if(_0x1eb40e[_0x7dfc('0x12')]){if(_0x1eb40e['error'][_0x7dfc('0x13')]===0x1f4){logger[_0x7dfc('0x12')](_0x7dfc('0xe'),_0x540d74,_0x1eb40e['error'][_0x7dfc('0x14')]);return _0x204032(_0x1eb40e[_0x7dfc('0x12')][_0x7dfc('0x14')]);}logger['error'](_0x7dfc('0xe'),_0x540d74,_0x1eb40e[_0x7dfc('0x12')][_0x7dfc('0x14')]);return _0x2ab04a(_0x1eb40e[_0x7dfc('0x12')][_0x7dfc('0x14')]);}else{logger[_0x7dfc('0x15')](_0x7dfc('0xe'),_0x540d74,_0x7dfc('0xf'));_0x2ab04a(_0x1eb40e[_0x7dfc('0x16')][_0x7dfc('0x14')]);}})[_0x7dfc('0x17')](function(_0x404982){logger[_0x7dfc('0x12')]('SquareMessage,\x20%s,\x20%s',_0x540d74,_0x404982);_0x204032(_0x404982);});});}exports[_0x7dfc('0x18')]=function(_0x5988c4){var _0x32fede=this;return new Promise(function(_0x376d14,_0x323443){return db[_0x7dfc('0x19')][_0x7dfc('0x1a')](_0x5988c4[_0x7dfc('0x1b')],{'raw':_0x5988c4['options']?_0x5988c4[_0x7dfc('0x1c')][_0x7dfc('0x1d')]===undefined?!![]:![]:!![]})[_0x7dfc('0xd')](function(_0x16a67d){logger[_0x7dfc('0x15')](_0x7dfc('0x18'),_0x5988c4);logger[_0x7dfc('0x10')](_0x7dfc('0x18'),_0x5988c4,JSON[_0x7dfc('0x11')](_0x16a67d));_0x376d14(_0x16a67d);})[_0x7dfc('0x17')](function(_0x318e98){logger[_0x7dfc('0x12')](_0x7dfc('0x18'),_0x318e98[_0x7dfc('0x14')],_0x5988c4);_0x323443(_0x32fede['error'](0x1f4,_0x318e98['message']));});});};