Built motion from commit ddca4d0d.|2.5.47
[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 _0x69af=['SquareMessage','create','body','options','then','catch','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','info','SquareMessage,\x20%s,\x20%s','debug','stringify','error','code','message','request\x20sent','result','CreateSquareMessage'];(function(_0x1dda95,_0x585b2f){var _0x91b0d4=function(_0x789b0c){while(--_0x789b0c){_0x1dda95['push'](_0x1dda95['shift']());}};_0x91b0d4(++_0x585b2f);}(_0x69af,0x165));var _0xf69a=function(_0xc99e12,_0x459654){_0xc99e12=_0xc99e12-0x0;var _0x3d9529=_0x69af[_0xc99e12];return _0x3d9529;};'use strict';var _=require(_0xf69a('0x0'));var util=require('util');var moment=require(_0xf69a('0x1'));var BPromise=require(_0xf69a('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf69a('0x3'));var db=require(_0xf69a('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xf69a('0x5'))(_0xf69a('0x6'));var config=require(_0xf69a('0x7'));var jayson=require(_0xf69a('0x8'));var client=jayson['client'][_0xf69a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5593b2,_0x226292,_0x435214){return new BPromise(function(_0x27a7bc,_0x2a69b6){return client[_0xf69a('0xa')](_0x5593b2,_0x435214)['then'](function(_0x1699cb){logger[_0xf69a('0xb')](_0xf69a('0xc'),_0x226292,'request\x20sent');logger[_0xf69a('0xd')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x226292,'request\x20sent',JSON[_0xf69a('0xe')](_0x1699cb));if(_0x1699cb['error']){if(_0x1699cb[_0xf69a('0xf')][_0xf69a('0x10')]===0x1f4){logger['error'](_0xf69a('0xc'),_0x226292,_0x1699cb[_0xf69a('0xf')][_0xf69a('0x11')]);return _0x2a69b6(_0x1699cb['error']['message']);}logger[_0xf69a('0xf')]('SquareMessage,\x20%s,\x20%s',_0x226292,_0x1699cb['error'][_0xf69a('0x11')]);return _0x27a7bc(_0x1699cb['error'][_0xf69a('0x11')]);}else{logger[_0xf69a('0xb')]('SquareMessage,\x20%s,\x20%s',_0x226292,_0xf69a('0x12'));_0x27a7bc(_0x1699cb[_0xf69a('0x13')][_0xf69a('0x11')]);}})['catch'](function(_0x45c05f){logger[_0xf69a('0xf')](_0xf69a('0xc'),_0x226292,_0x45c05f);_0x2a69b6(_0x45c05f);});});}exports[_0xf69a('0x14')]=function(_0x2c3b26){var _0x1feb6b=this;return new Promise(function(_0x4be283,_0x416979){return db[_0xf69a('0x15')][_0xf69a('0x16')](_0x2c3b26[_0xf69a('0x17')],{'raw':_0x2c3b26[_0xf69a('0x18')]?_0x2c3b26[_0xf69a('0x18')]['raw']===undefined?!![]:![]:!![]})[_0xf69a('0x19')](function(_0x3c097c){logger[_0xf69a('0xb')]('CreateSquareMessage',_0x2c3b26);logger[_0xf69a('0xd')](_0xf69a('0x14'),_0x2c3b26,JSON[_0xf69a('0xe')](_0x3c097c));_0x4be283(_0x3c097c);})[_0xf69a('0x1a')](function(_0x2f0fa0){logger[_0xf69a('0xf')](_0xf69a('0x14'),_0x2f0fa0['message'],_0x2c3b26);_0x416979(_0x1feb6b[_0xf69a('0xf')](0x1f4,_0x2f0fa0[_0xf69a('0x11')]));});});};