Built motion from commit 97153652.|2.6.26
[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 _0x7a55=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','SquareRecording,\x20%s,\x20%s','request\x20sent','debug','SquareRecording,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateSquareRecording','SquareRecording','body','options','lodash','util','bluebird'];(function(_0x4207f4,_0x1f778b){var _0x29a621=function(_0xa6f5b7){while(--_0xa6f5b7){_0x4207f4['push'](_0x4207f4['shift']());}};_0x29a621(++_0x1f778b);}(_0x7a55,0x183));var _0x57a5=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x7a55[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0x57a5('0x0'));var util=require(_0x57a5('0x1'));var moment=require('moment');var BPromise=require(_0x57a5('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x57a5('0x3'))['db'];var utils=require(_0x57a5('0x4'));var logger=require(_0x57a5('0x5'))(_0x57a5('0x6'));var config=require(_0x57a5('0x7'));var jayson=require(_0x57a5('0x8'));var client=jayson['client'][_0x57a5('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xc7dc65,_0x4bf392,_0x393524){return new BPromise(function(_0x3121f9,_0x5eb15b){return client[_0x57a5('0xa')](_0xc7dc65,_0x393524)[_0x57a5('0xb')](function(_0x3bcc41){logger[_0x57a5('0xc')](_0x57a5('0xd'),_0x4bf392,_0x57a5('0xe'));logger[_0x57a5('0xf')](_0x57a5('0x10'),_0x4bf392,_0x57a5('0xe'),JSON[_0x57a5('0x11')](_0x3bcc41));if(_0x3bcc41['error']){if(_0x3bcc41[_0x57a5('0x12')]['code']===0x1f4){logger[_0x57a5('0x12')](_0x57a5('0xd'),_0x4bf392,_0x3bcc41[_0x57a5('0x12')]['message']);return _0x5eb15b(_0x3bcc41[_0x57a5('0x12')][_0x57a5('0x13')]);}logger['error']('SquareRecording,\x20%s,\x20%s',_0x4bf392,_0x3bcc41[_0x57a5('0x12')][_0x57a5('0x13')]);return _0x3121f9(_0x3bcc41[_0x57a5('0x12')][_0x57a5('0x13')]);}else{logger[_0x57a5('0xc')](_0x57a5('0xd'),_0x4bf392,_0x57a5('0xe'));_0x3121f9(_0x3bcc41[_0x57a5('0x14')][_0x57a5('0x13')]);}})[_0x57a5('0x15')](function(_0x43fbdf){logger['error'](_0x57a5('0xd'),_0x4bf392,_0x43fbdf);_0x5eb15b(_0x43fbdf);});});}exports[_0x57a5('0x16')]=function(_0x4c9ffb){var _0x1fcebf=this;return new Promise(function(_0x2e472a,_0x1f3a18){return db[_0x57a5('0x17')]['create'](_0x4c9ffb[_0x57a5('0x18')],{'raw':_0x4c9ffb['options']?_0x4c9ffb[_0x57a5('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x787cc4){logger['info'](_0x57a5('0x16'),_0x4c9ffb);logger[_0x57a5('0xf')](_0x57a5('0x16'),_0x4c9ffb,JSON[_0x57a5('0x11')](_0x787cc4));_0x2e472a(_0x787cc4);})[_0x57a5('0x15')](function(_0x558014){logger[_0x57a5('0x12')](_0x57a5('0x16'),_0x558014[_0x57a5('0x13')],_0x4c9ffb);_0x1f3a18(_0x1fcebf[_0x57a5('0x12')](0x1f4,_0x558014[_0x57a5('0x13')]));});});};