087b455886a27f02a2c4780a9d4496ea4f76d3cb
[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 _0x5bd5=['request\x20sent','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','CreateSquareRecording','options','raw','debug','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','SquareRecording,\x20%s,\x20%s'];(function(_0x345c95,_0x321e26){var _0x4814f1=function(_0x4e0b2c){while(--_0x4e0b2c){_0x345c95['push'](_0x345c95['shift']());}};_0x4814f1(++_0x321e26);}(_0x5bd5,0x16b));var _0x55bd=function(_0x2e2681,_0x4089c1){_0x2e2681=_0x2e2681-0x0;var _0x368a64=_0x5bd5[_0x2e2681];return _0x368a64;};'use strict';var _=require(_0x55bd('0x0'));var util=require(_0x55bd('0x1'));var moment=require(_0x55bd('0x2'));var BPromise=require('bluebird');var rs=require(_0x55bd('0x3'));var fs=require('fs');var Redis=require(_0x55bd('0x4'));var db=require(_0x55bd('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x55bd('0x6'))(_0x55bd('0x7'));var config=require(_0x55bd('0x8'));var jayson=require(_0x55bd('0x9'));var client=jayson[_0x55bd('0xa')][_0x55bd('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x367280,_0x55e181,_0x17f0d9){return new BPromise(function(_0xc48987,_0x5ad5f3){return client[_0x55bd('0xc')](_0x367280,_0x17f0d9)[_0x55bd('0xd')](function(_0x35dcfa){logger['info'](_0x55bd('0xe'),_0x55e181,_0x55bd('0xf'));logger['debug'](_0x55bd('0x10'),_0x55e181,_0x55bd('0xf'),JSON[_0x55bd('0x11')](_0x35dcfa));if(_0x35dcfa['error']){if(_0x35dcfa[_0x55bd('0x12')]['code']===0x1f4){logger[_0x55bd('0x12')](_0x55bd('0xe'),_0x55e181,_0x35dcfa[_0x55bd('0x12')][_0x55bd('0x13')]);return _0x5ad5f3(_0x35dcfa[_0x55bd('0x12')][_0x55bd('0x13')]);}logger['error'](_0x55bd('0xe'),_0x55e181,_0x35dcfa['error']['message']);return _0xc48987(_0x35dcfa['error'][_0x55bd('0x13')]);}else{logger[_0x55bd('0x14')](_0x55bd('0xe'),_0x55e181,_0x55bd('0xf'));_0xc48987(_0x35dcfa[_0x55bd('0x15')][_0x55bd('0x13')]);}})[_0x55bd('0x16')](function(_0x4ffff1){logger['error'](_0x55bd('0xe'),_0x55e181,_0x4ffff1);_0x5ad5f3(_0x4ffff1);});});}exports[_0x55bd('0x17')]=function(_0x3cf244){var _0x47253e=this;return new Promise(function(_0x5bd8e3,_0x3a5ded){return db['SquareRecording']['create'](_0x3cf244['body'],{'raw':_0x3cf244[_0x55bd('0x18')]?_0x3cf244[_0x55bd('0x18')][_0x55bd('0x19')]===undefined?!![]:![]:!![]})[_0x55bd('0xd')](function(_0x24fa60){logger[_0x55bd('0x14')](_0x55bd('0x17'),_0x3cf244);logger[_0x55bd('0x1a')](_0x55bd('0x17'),_0x3cf244,JSON['stringify'](_0x24fa60));_0x5bd8e3(_0x24fa60);})['catch'](function(_0x50f525){logger[_0x55bd('0x12')]('CreateSquareRecording',_0x50f525[_0x55bd('0x13')],_0x3cf244);_0x3a5ded(_0x47253e[_0x55bd('0x12')](0x1f4,_0x50f525[_0x55bd('0x13')]));});});};