0db12e1591e7b9c8858f49afb5d49e5d0d79cb97
[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 _0x0466=['randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','then','info','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','code','SquareRecording,\x20%s,\x20%s','message','result','CreateSquareRecording','SquareRecording','body','options','raw','catch','lodash','util','moment','bluebird'];(function(_0x435253,_0x2e45b4){var _0x4e6431=function(_0x5ad8fa){while(--_0x5ad8fa){_0x435253['push'](_0x435253['shift']());}};_0x4e6431(++_0x2e45b4);}(_0x0466,0x1af));var _0x6046=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x0466[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0x6046('0x0'));var util=require(_0x6046('0x1'));var moment=require(_0x6046('0x2'));var BPromise=require(_0x6046('0x3'));var rs=require(_0x6046('0x4'));var fs=require('fs');var Redis=require(_0x6046('0x5'));var db=require(_0x6046('0x6'))['db'];var utils=require(_0x6046('0x7'));var logger=require(_0x6046('0x8'))(_0x6046('0x9'));var config=require('../../config/environment');var jayson=require(_0x6046('0xa'));var client=jayson[_0x6046('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x103a0e,_0x345d77,_0x5c21b5){return new BPromise(function(_0x51897a,_0x580efc){return client['request'](_0x103a0e,_0x5c21b5)[_0x6046('0xc')](function(_0x1d477c){logger[_0x6046('0xd')]('SquareRecording,\x20%s,\x20%s',_0x345d77,_0x6046('0xe'));logger[_0x6046('0xf')](_0x6046('0x10'),_0x345d77,_0x6046('0xe'),JSON[_0x6046('0x11')](_0x1d477c));if(_0x1d477c[_0x6046('0x12')]){if(_0x1d477c[_0x6046('0x12')][_0x6046('0x13')]===0x1f4){logger['error'](_0x6046('0x14'),_0x345d77,_0x1d477c['error'][_0x6046('0x15')]);return _0x580efc(_0x1d477c[_0x6046('0x12')][_0x6046('0x15')]);}logger['error'](_0x6046('0x14'),_0x345d77,_0x1d477c[_0x6046('0x12')][_0x6046('0x15')]);return _0x51897a(_0x1d477c['error'][_0x6046('0x15')]);}else{logger[_0x6046('0xd')](_0x6046('0x14'),_0x345d77,_0x6046('0xe'));_0x51897a(_0x1d477c[_0x6046('0x16')][_0x6046('0x15')]);}})['catch'](function(_0x4b24e9){logger[_0x6046('0x12')](_0x6046('0x14'),_0x345d77,_0x4b24e9);_0x580efc(_0x4b24e9);});});}exports[_0x6046('0x17')]=function(_0x2398f9){var _0x36c1aa=this;return new Promise(function(_0x4d7ab4,_0x449515){return db[_0x6046('0x18')]['create'](_0x2398f9[_0x6046('0x19')],{'raw':_0x2398f9[_0x6046('0x1a')]?_0x2398f9[_0x6046('0x1a')][_0x6046('0x1b')]===undefined?!![]:![]:!![]})[_0x6046('0xc')](function(_0x4fec65){logger[_0x6046('0xd')](_0x6046('0x17'),_0x2398f9);logger[_0x6046('0xf')](_0x6046('0x17'),_0x2398f9,JSON[_0x6046('0x11')](_0x4fec65));_0x4d7ab4(_0x4fec65);})[_0x6046('0x1c')](function(_0x4c21eb){logger['error'](_0x6046('0x17'),_0x4c21eb['message'],_0x2398f9);_0x449515(_0x36c1aa[_0x6046('0x12')](0x1f4,_0x4c21eb[_0x6046('0x15')]));});});};