204e978a107118af27ff803eff19eed0ad860011
[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 _0x37c5=['CreateSquareMessage','SquareMessage','options','then','catch','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','info','SquareMessage,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','result'];(function(_0x45a099,_0x20ea5c){var _0x557e01=function(_0x548418){while(--_0x548418){_0x45a099['push'](_0x45a099['shift']());}};_0x557e01(++_0x20ea5c);}(_0x37c5,0xa7));var _0x537c=function(_0x5c5a5a,_0x3a1857){_0x5c5a5a=_0x5c5a5a-0x0;var _0x3db11e=_0x37c5[_0x5c5a5a];return _0x3db11e;};'use strict';var _=require('lodash');var util=require(_0x537c('0x0'));var moment=require(_0x537c('0x1'));var BPromise=require(_0x537c('0x2'));var rs=require(_0x537c('0x3'));var fs=require('fs');var Redis=require(_0x537c('0x4'));var db=require(_0x537c('0x5'))['db'];var utils=require(_0x537c('0x6'));var logger=require(_0x537c('0x7'))(_0x537c('0x8'));var config=require(_0x537c('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x537c('0xa')][_0x537c('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x336920,_0x57666f,_0x36bf4a){return new BPromise(function(_0x67f986,_0x32b9c7){return client[_0x537c('0xc')](_0x336920,_0x36bf4a)['then'](function(_0x2c2f06){logger[_0x537c('0xd')](_0x537c('0xe'),_0x57666f,'request\x20sent');logger[_0x537c('0xf')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x57666f,'request\x20sent',JSON[_0x537c('0x10')](_0x2c2f06));if(_0x2c2f06['error']){if(_0x2c2f06[_0x537c('0x11')][_0x537c('0x12')]===0x1f4){logger[_0x537c('0x11')](_0x537c('0xe'),_0x57666f,_0x2c2f06[_0x537c('0x11')][_0x537c('0x13')]);return _0x32b9c7(_0x2c2f06[_0x537c('0x11')][_0x537c('0x13')]);}logger[_0x537c('0x11')]('SquareMessage,\x20%s,\x20%s',_0x57666f,_0x2c2f06[_0x537c('0x11')][_0x537c('0x13')]);return _0x67f986(_0x2c2f06[_0x537c('0x11')][_0x537c('0x13')]);}else{logger[_0x537c('0xd')](_0x537c('0xe'),_0x57666f,_0x537c('0x14'));_0x67f986(_0x2c2f06[_0x537c('0x15')][_0x537c('0x13')]);}})['catch'](function(_0x3ae729){logger['error']('SquareMessage,\x20%s,\x20%s',_0x57666f,_0x3ae729);_0x32b9c7(_0x3ae729);});});}exports[_0x537c('0x16')]=function(_0x237be8){var _0x2a890e=this;return new Promise(function(_0x5f3776,_0x28b410){return db[_0x537c('0x17')]['create'](_0x237be8['body'],{'raw':_0x237be8[_0x537c('0x18')]?_0x237be8['options']['raw']===undefined?!![]:![]:!![]})[_0x537c('0x19')](function(_0x32be40){logger['info'](_0x537c('0x16'),_0x237be8);logger[_0x537c('0xf')]('CreateSquareMessage',_0x237be8,JSON['stringify'](_0x32be40));_0x5f3776(_0x32be40);})[_0x537c('0x1a')](function(_0x47bece){logger['error'](_0x537c('0x16'),_0x47bece[_0x537c('0x13')],_0x237be8);_0x28b410(_0x2a890e[_0x537c('0x11')](0x1f4,_0x47bece[_0x537c('0x13')]));});});};