e467c1c74dbd4220946c747fccf5317d012d0216
[motion2.git] / server / api / squareRecording / squareRecording.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 _0x7675=['SquareRecording','create','body','raw','stringify','lodash','moment','bluebird','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','error','SquareRecording,\x20%s,\x20%s','message','info','catch','CreateSquareRecording'];(function(_0x330591,_0x8d930c){var _0x431cf5=function(_0x52b61d){while(--_0x52b61d){_0x330591['push'](_0x330591['shift']());}};_0x431cf5(++_0x8d930c);}(_0x7675,0x131));var _0x5767=function(_0x16337d,_0xabb12a){_0x16337d=_0x16337d-0x0;var _0x3a0bfe=_0x7675[_0x16337d];return _0x3a0bfe;};'use strict';var _=require(_0x5767('0x0'));var util=require('util');var moment=require(_0x5767('0x1'));var BPromise=require(_0x5767('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5767('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x5767('0x4'))(_0x5767('0x5'));var config=require(_0x5767('0x6'));var jayson=require(_0x5767('0x7'));var client=jayson[_0x5767('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x55ffe0,_0x31598e,_0x1931b1){return new BPromise(function(_0x389ba0,_0x2ee1b5){return client[_0x5767('0x9')](_0x55ffe0,_0x1931b1)[_0x5767('0xa')](function(_0xe93450){logger['info']('SquareRecording,\x20%s,\x20%s',_0x31598e,_0x5767('0xb'));logger[_0x5767('0xc')](_0x5767('0xd'),_0x31598e,_0x5767('0xb'),JSON['stringify'](_0xe93450));if(_0xe93450[_0x5767('0xe')]){if(_0xe93450[_0x5767('0xe')]['code']===0x1f4){logger[_0x5767('0xe')](_0x5767('0xf'),_0x31598e,_0xe93450[_0x5767('0xe')][_0x5767('0x10')]);return _0x2ee1b5(_0xe93450['error']['message']);}logger[_0x5767('0xe')](_0x5767('0xf'),_0x31598e,_0xe93450[_0x5767('0xe')]['message']);return _0x389ba0(_0xe93450['error'][_0x5767('0x10')]);}else{logger[_0x5767('0x11')](_0x5767('0xf'),_0x31598e,_0x5767('0xb'));_0x389ba0(_0xe93450['result'][_0x5767('0x10')]);}})[_0x5767('0x12')](function(_0x5b7a13){logger[_0x5767('0xe')](_0x5767('0xf'),_0x31598e,_0x5b7a13);_0x2ee1b5(_0x5b7a13);});});}exports[_0x5767('0x13')]=function(_0x32ff68){var _0x1504b8=this;return new Promise(function(_0x3440c5,_0x12316e){return db[_0x5767('0x14')][_0x5767('0x15')](_0x32ff68[_0x5767('0x16')],{'raw':_0x32ff68['options']?_0x32ff68['options'][_0x5767('0x17')]===undefined?!![]:![]:!![]})[_0x5767('0xa')](function(_0x109aac){logger['info'](_0x5767('0x13'),_0x32ff68);logger[_0x5767('0xc')](_0x5767('0x13'),_0x32ff68,JSON[_0x5767('0x18')](_0x109aac));_0x3440c5(_0x109aac);})[_0x5767('0x12')](function(_0x1da7bd){logger['error']('CreateSquareRecording',_0x1da7bd['message'],_0x32ff68);_0x12316e(_0x1504b8[_0x5767('0xe')](0x1f4,_0x1da7bd[_0x5767('0x10')]));});});};