cb39baf39c7cdcdd4f49f2edb2496ff7b8ff1dab
[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 _0x45cf=['SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSquareMessage','SquareMessage','create','options','raw','debug','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent'];(function(_0x1fafa5,_0x1aa281){var _0xcf08c9=function(_0x3af1b4){while(--_0x3af1b4){_0x1fafa5['push'](_0x1fafa5['shift']());}};_0xcf08c9(++_0x1aa281);}(_0x45cf,0x1cf));var _0xf45c=function(_0xd750a7,_0x268c57){_0xd750a7=_0xd750a7-0x0;var _0x562cdc=_0x45cf[_0xd750a7];return _0x562cdc;};'use strict';var _=require(_0xf45c('0x0'));var util=require(_0xf45c('0x1'));var moment=require(_0xf45c('0x2'));var BPromise=require(_0xf45c('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf45c('0x4'));var db=require(_0xf45c('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xf45c('0x6'))(_0xf45c('0x7'));var config=require(_0xf45c('0x8'));var jayson=require(_0xf45c('0x9'));var client=jayson[_0xf45c('0xa')][_0xf45c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2d6ee9,_0x2af355,_0x583163){return new BPromise(function(_0x42de16,_0x50ef48){return client[_0xf45c('0xc')](_0x2d6ee9,_0x583163)[_0xf45c('0xd')](function(_0x28db0a){logger[_0xf45c('0xe')](_0xf45c('0xf'),_0x2af355,_0xf45c('0x10'));logger['debug'](_0xf45c('0x11'),_0x2af355,'request\x20sent',JSON[_0xf45c('0x12')](_0x28db0a));if(_0x28db0a[_0xf45c('0x13')]){if(_0x28db0a['error'][_0xf45c('0x14')]===0x1f4){logger[_0xf45c('0x13')](_0xf45c('0xf'),_0x2af355,_0x28db0a[_0xf45c('0x13')][_0xf45c('0x15')]);return _0x50ef48(_0x28db0a[_0xf45c('0x13')]['message']);}logger[_0xf45c('0x13')](_0xf45c('0xf'),_0x2af355,_0x28db0a[_0xf45c('0x13')]['message']);return _0x42de16(_0x28db0a[_0xf45c('0x13')]['message']);}else{logger[_0xf45c('0xe')](_0xf45c('0xf'),_0x2af355,'request\x20sent');_0x42de16(_0x28db0a[_0xf45c('0x16')][_0xf45c('0x15')]);}})[_0xf45c('0x17')](function(_0x280c4b){logger[_0xf45c('0x13')](_0xf45c('0xf'),_0x2af355,_0x280c4b);_0x50ef48(_0x280c4b);});});}exports[_0xf45c('0x18')]=function(_0x123137){var _0x587eac=this;return new Promise(function(_0x1908f6,_0xc54ddb){return db[_0xf45c('0x19')][_0xf45c('0x1a')](_0x123137['body'],{'raw':_0x123137[_0xf45c('0x1b')]?_0x123137[_0xf45c('0x1b')][_0xf45c('0x1c')]===undefined?!![]:![]:!![]})[_0xf45c('0xd')](function(_0xa2c1){logger[_0xf45c('0xe')]('CreateSquareMessage',_0x123137);logger[_0xf45c('0x1d')](_0xf45c('0x18'),_0x123137,JSON['stringify'](_0xa2c1));_0x1908f6(_0xa2c1);})[_0xf45c('0x17')](function(_0x3432a8){logger[_0xf45c('0x13')](_0xf45c('0x18'),_0x3432a8['message'],_0x123137);_0xc54ddb(_0x587eac[_0xf45c('0x13')](0x1f4,_0x3432a8[_0xf45c('0x15')]));});});};