abaa2faf29624e1342ab406d2d400cfdc33225d9
[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 _0x82f6=['info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSquareMessage','SquareMessage','create','body','options','raw','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','request','then'];(function(_0x49789d,_0x5f248e){var _0x31a0e8=function(_0x4203e3){while(--_0x4203e3){_0x49789d['push'](_0x49789d['shift']());}};_0x31a0e8(++_0x5f248e);}(_0x82f6,0x116));var _0x682f=function(_0xc0fc19,_0x45ac9c){_0xc0fc19=_0xc0fc19-0x0;var _0x30e33f=_0x82f6[_0xc0fc19];return _0x30e33f;};'use strict';var _=require(_0x682f('0x0'));var util=require(_0x682f('0x1'));var moment=require(_0x682f('0x2'));var BPromise=require(_0x682f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x682f('0x4'));var db=require(_0x682f('0x5'))['db'];var utils=require(_0x682f('0x6'));var logger=require(_0x682f('0x7'))('rpc');var config=require(_0x682f('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x682f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2f7a2e,_0x14fe1f,_0x1cd504){return new BPromise(function(_0xdc5eb5,_0x50e166){return client[_0x682f('0xa')](_0x2f7a2e,_0x1cd504)[_0x682f('0xb')](function(_0x530afa){logger[_0x682f('0xc')](_0x682f('0xd'),_0x14fe1f,_0x682f('0xe'));logger[_0x682f('0xf')](_0x682f('0x10'),_0x14fe1f,_0x682f('0xe'),JSON[_0x682f('0x11')](_0x530afa));if(_0x530afa[_0x682f('0x12')]){if(_0x530afa[_0x682f('0x12')][_0x682f('0x13')]===0x1f4){logger['error'](_0x682f('0xd'),_0x14fe1f,_0x530afa[_0x682f('0x12')][_0x682f('0x14')]);return _0x50e166(_0x530afa[_0x682f('0x12')][_0x682f('0x14')]);}logger[_0x682f('0x12')](_0x682f('0xd'),_0x14fe1f,_0x530afa[_0x682f('0x12')]['message']);return _0xdc5eb5(_0x530afa['error'][_0x682f('0x14')]);}else{logger[_0x682f('0xc')](_0x682f('0xd'),_0x14fe1f,'request\x20sent');_0xdc5eb5(_0x530afa[_0x682f('0x15')][_0x682f('0x14')]);}})[_0x682f('0x16')](function(_0x144031){logger[_0x682f('0x12')](_0x682f('0xd'),_0x14fe1f,_0x144031);_0x50e166(_0x144031);});});}exports[_0x682f('0x17')]=function(_0xc5299a){var _0x9cfa44=this;return new Promise(function(_0x18c298,_0x912613){return db[_0x682f('0x18')][_0x682f('0x19')](_0xc5299a[_0x682f('0x1a')],{'raw':_0xc5299a[_0x682f('0x1b')]?_0xc5299a[_0x682f('0x1b')][_0x682f('0x1c')]===undefined?!![]:![]:!![]})['then'](function(_0x3631d0){logger[_0x682f('0xc')](_0x682f('0x17'),_0xc5299a);logger['debug']('CreateSquareMessage',_0xc5299a,JSON['stringify'](_0x3631d0));_0x18c298(_0x3631d0);})[_0x682f('0x16')](function(_0x8722c8){logger[_0x682f('0x12')](_0x682f('0x17'),_0x8722c8[_0x682f('0x14')],_0xc5299a);_0x912613(_0x9cfa44[_0x682f('0x12')](0x1f4,_0x8722c8['message']));});});};