e1938fabc4101b8845a462394ea5b113f46c924f
[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 _0x367b=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','request','then','info','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','code','error','message','result','catch','create','options','raw','CreateSquareRecording','stringify','lodash','util','moment'];(function(_0x1c1e47,_0x2902c3){var _0x498fb0=function(_0x34b927){while(--_0x34b927){_0x1c1e47['push'](_0x1c1e47['shift']());}};_0x498fb0(++_0x2902c3);}(_0x367b,0x1ea));var _0xb367=function(_0x27b715,_0x5ef620){_0x27b715=_0x27b715-0x0;var _0x58b407=_0x367b[_0x27b715];return _0x58b407;};'use strict';var _=require(_0xb367('0x0'));var util=require(_0xb367('0x1'));var moment=require(_0xb367('0x2'));var BPromise=require(_0xb367('0x3'));var rs=require(_0xb367('0x4'));var fs=require('fs');var Redis=require(_0xb367('0x5'));var db=require(_0xb367('0x6'))['db'];var utils=require(_0xb367('0x7'));var logger=require('../../config/logger')(_0xb367('0x8'));var config=require(_0xb367('0x9'));var jayson=require(_0xb367('0xa'));var client=jayson[_0xb367('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2c6cb9,_0x401bbd,_0x1e47f0){return new BPromise(function(_0x5f2513,_0xea9ac3){return client[_0xb367('0xc')](_0x2c6cb9,_0x1e47f0)[_0xb367('0xd')](function(_0x55453c){logger[_0xb367('0xe')](_0xb367('0xf'),_0x401bbd,_0xb367('0x10'));logger[_0xb367('0x11')](_0xb367('0x12'),_0x401bbd,_0xb367('0x10'),JSON['stringify'](_0x55453c));if(_0x55453c['error']){if(_0x55453c['error'][_0xb367('0x13')]===0x1f4){logger[_0xb367('0x14')](_0xb367('0xf'),_0x401bbd,_0x55453c[_0xb367('0x14')][_0xb367('0x15')]);return _0xea9ac3(_0x55453c[_0xb367('0x14')][_0xb367('0x15')]);}logger[_0xb367('0x14')](_0xb367('0xf'),_0x401bbd,_0x55453c['error'][_0xb367('0x15')]);return _0x5f2513(_0x55453c['error'][_0xb367('0x15')]);}else{logger[_0xb367('0xe')](_0xb367('0xf'),_0x401bbd,_0xb367('0x10'));_0x5f2513(_0x55453c[_0xb367('0x16')][_0xb367('0x15')]);}})[_0xb367('0x17')](function(_0x42140e){logger[_0xb367('0x14')](_0xb367('0xf'),_0x401bbd,_0x42140e);_0xea9ac3(_0x42140e);});});}exports['CreateSquareRecording']=function(_0x5a8cad){var _0x1bf752=this;return new Promise(function(_0x55b72a,_0x174e42){return db['SquareRecording'][_0xb367('0x18')](_0x5a8cad['body'],{'raw':_0x5a8cad['options']?_0x5a8cad[_0xb367('0x19')][_0xb367('0x1a')]===undefined?!![]:![]:!![]})[_0xb367('0xd')](function(_0x39d747){logger[_0xb367('0xe')](_0xb367('0x1b'),_0x5a8cad);logger[_0xb367('0x11')](_0xb367('0x1b'),_0x5a8cad,JSON[_0xb367('0x1c')](_0x39d747));_0x55b72a(_0x39d747);})[_0xb367('0x17')](function(_0x4bd0fb){logger[_0xb367('0x14')](_0xb367('0x1b'),_0x4bd0fb['message'],_0x5a8cad);_0x174e42(_0x1bf752[_0xb367('0x14')](0x1f4,_0x4bd0fb[_0xb367('0x15')]));});});};