010a939ab79ef9f704698ea215a7086770d6650d
[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 _0xf072=['../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','CreateSquareMessage','create','body','options','raw','lodash','util','moment','randomstring','../../mysqldb'];(function(_0x8bca3f,_0x158cf8){var _0x448ab5=function(_0x5b5537){while(--_0x5b5537){_0x8bca3f['push'](_0x8bca3f['shift']());}};_0x448ab5(++_0x158cf8);}(_0xf072,0x1cf));var _0x2f07=function(_0x3b6e1f,_0x4b3d74){_0x3b6e1f=_0x3b6e1f-0x0;var _0x400bee=_0xf072[_0x3b6e1f];return _0x400bee;};'use strict';var _=require(_0x2f07('0x0'));var util=require(_0x2f07('0x1'));var moment=require(_0x2f07('0x2'));var BPromise=require('bluebird');var rs=require(_0x2f07('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2f07('0x4'))['db'];var utils=require(_0x2f07('0x5'));var logger=require(_0x2f07('0x6'))('rpc');var config=require(_0x2f07('0x7'));var jayson=require(_0x2f07('0x8'));var client=jayson[_0x2f07('0x9')][_0x2f07('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x235418,_0xf73d1a,_0x33b99c){return new BPromise(function(_0x379b2e,_0x4746c2){return client[_0x2f07('0xb')](_0x235418,_0x33b99c)[_0x2f07('0xc')](function(_0x2e372c){logger[_0x2f07('0xd')](_0x2f07('0xe'),_0xf73d1a,_0x2f07('0xf'));logger['debug'](_0x2f07('0x10'),_0xf73d1a,_0x2f07('0xf'),JSON[_0x2f07('0x11')](_0x2e372c));if(_0x2e372c[_0x2f07('0x12')]){if(_0x2e372c['error']['code']===0x1f4){logger[_0x2f07('0x12')](_0x2f07('0xe'),_0xf73d1a,_0x2e372c['error'][_0x2f07('0x13')]);return _0x4746c2(_0x2e372c[_0x2f07('0x12')][_0x2f07('0x13')]);}logger['error'](_0x2f07('0xe'),_0xf73d1a,_0x2e372c[_0x2f07('0x12')][_0x2f07('0x13')]);return _0x379b2e(_0x2e372c[_0x2f07('0x12')][_0x2f07('0x13')]);}else{logger[_0x2f07('0xd')]('SquareMessage,\x20%s,\x20%s',_0xf73d1a,_0x2f07('0xf'));_0x379b2e(_0x2e372c['result'][_0x2f07('0x13')]);}})[_0x2f07('0x14')](function(_0x1dace4){logger[_0x2f07('0x12')](_0x2f07('0xe'),_0xf73d1a,_0x1dace4);_0x4746c2(_0x1dace4);});});}exports[_0x2f07('0x15')]=function(_0x1a6135){var _0xe3ed0=this;return new Promise(function(_0x55bd60,_0x15c3dd){return db['SquareMessage'][_0x2f07('0x16')](_0x1a6135[_0x2f07('0x17')],{'raw':_0x1a6135[_0x2f07('0x18')]?_0x1a6135[_0x2f07('0x18')][_0x2f07('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x45df73){logger['info']('CreateSquareMessage',_0x1a6135);logger['debug'](_0x2f07('0x15'),_0x1a6135,JSON['stringify'](_0x45df73));_0x55bd60(_0x45df73);})[_0x2f07('0x14')](function(_0x5e6ac6){logger[_0x2f07('0x12')](_0x2f07('0x15'),_0x5e6ac6[_0x2f07('0x13')],_0x1a6135);_0x15c3dd(_0xe3ed0[_0x2f07('0x12')](0x1f4,_0x5e6ac6['message']));});});};