Built motion from commit 639a1a7f.|2.6.19
[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 _0x392f=['code','error','message','result','catch','CreateSquareMessage','SquareMessage','create','body','options','raw','util','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','jayson/promise','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','stringify'];(function(_0x29eeb1,_0x40ee55){var _0xe62f34=function(_0x3768ea){while(--_0x3768ea){_0x29eeb1['push'](_0x29eeb1['shift']());}};_0xe62f34(++_0x40ee55);}(_0x392f,0x143));var _0xf392=function(_0x14f5a3,_0x268d64){_0x14f5a3=_0x14f5a3-0x0;var _0xc84d0e=_0x392f[_0x14f5a3];return _0xc84d0e;};'use strict';var _=require('lodash');var util=require(_0xf392('0x0'));var moment=require('moment');var BPromise=require(_0xf392('0x1'));var rs=require(_0xf392('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf392('0x3'))['db'];var utils=require(_0xf392('0x4'));var logger=require('../../config/logger')(_0xf392('0x5'));var config=require('../../config/environment');var jayson=require(_0xf392('0x6'));var client=jayson['client'][_0xf392('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x48cc02,_0x4b1e16,_0x27ca0d){return new BPromise(function(_0x261c50,_0x1defce){return client[_0xf392('0x8')](_0x48cc02,_0x27ca0d)[_0xf392('0x9')](function(_0x28d595){logger[_0xf392('0xa')](_0xf392('0xb'),_0x4b1e16,_0xf392('0xc'));logger[_0xf392('0xd')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x4b1e16,'request\x20sent',JSON[_0xf392('0xe')](_0x28d595));if(_0x28d595['error']){if(_0x28d595['error'][_0xf392('0xf')]===0x1f4){logger[_0xf392('0x10')](_0xf392('0xb'),_0x4b1e16,_0x28d595[_0xf392('0x10')][_0xf392('0x11')]);return _0x1defce(_0x28d595[_0xf392('0x10')][_0xf392('0x11')]);}logger[_0xf392('0x10')]('SquareMessage,\x20%s,\x20%s',_0x4b1e16,_0x28d595[_0xf392('0x10')][_0xf392('0x11')]);return _0x261c50(_0x28d595[_0xf392('0x10')][_0xf392('0x11')]);}else{logger[_0xf392('0xa')](_0xf392('0xb'),_0x4b1e16,_0xf392('0xc'));_0x261c50(_0x28d595[_0xf392('0x12')][_0xf392('0x11')]);}})[_0xf392('0x13')](function(_0x115d5e){logger[_0xf392('0x10')]('SquareMessage,\x20%s,\x20%s',_0x4b1e16,_0x115d5e);_0x1defce(_0x115d5e);});});}exports[_0xf392('0x14')]=function(_0x3f4bb4){var _0x2ade56=this;return new Promise(function(_0x31b10e,_0x21244){return db[_0xf392('0x15')][_0xf392('0x16')](_0x3f4bb4[_0xf392('0x17')],{'raw':_0x3f4bb4[_0xf392('0x18')]?_0x3f4bb4[_0xf392('0x18')][_0xf392('0x19')]===undefined?!![]:![]:!![]})[_0xf392('0x9')](function(_0x1b4d08){logger['info'](_0xf392('0x14'),_0x3f4bb4);logger['debug']('CreateSquareMessage',_0x3f4bb4,JSON[_0xf392('0xe')](_0x1b4d08));_0x31b10e(_0x1b4d08);})['catch'](function(_0x23c93c){logger['error'](_0xf392('0x14'),_0x23c93c['message'],_0x3f4bb4);_0x21244(_0x2ade56[_0xf392('0x10')](0x1f4,_0x23c93c[_0xf392('0x11')]));});});};