Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / cloudProvider / cloudProvider.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 _0x753e=['debug','error','message','info','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','jayson/promise','client','request','then','CloudProvider,\x20%s,\x20%s','request\x20sent'];(function(_0xb04f6b,_0x1ade6){var _0x571dcb=function(_0x47f9e1){while(--_0x47f9e1){_0xb04f6b['push'](_0xb04f6b['shift']());}};_0x571dcb(++_0x1ade6);}(_0x753e,0x122));var _0xe753=function(_0x16d10f,_0x2ba2d5){_0x16d10f=_0x16d10f-0x0;var _0x50c823=_0x753e[_0x16d10f];return _0x50c823;};'use strict';var _=require(_0xe753('0x0'));var util=require(_0xe753('0x1'));var moment=require(_0xe753('0x2'));var BPromise=require(_0xe753('0x3'));var rs=require(_0xe753('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xe753('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xe753('0x6'))(_0xe753('0x7'));var config=require('../../config/environment');var jayson=require(_0xe753('0x8'));var client=jayson[_0xe753('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x106f15,_0x25aa06,_0x1bcdfa){return new BPromise(function(_0x56c2ac,_0x22c070){return client[_0xe753('0xa')](_0x106f15,_0x1bcdfa)[_0xe753('0xb')](function(_0x2e2228){logger['info'](_0xe753('0xc'),_0x25aa06,_0xe753('0xd'));logger[_0xe753('0xe')]('CloudProvider,\x20%s,\x20%s,\x20%s',_0x25aa06,_0xe753('0xd'),JSON['stringify'](_0x2e2228));if(_0x2e2228[_0xe753('0xf')]){if(_0x2e2228[_0xe753('0xf')]['code']===0x1f4){logger[_0xe753('0xf')](_0xe753('0xc'),_0x25aa06,_0x2e2228['error'][_0xe753('0x10')]);return _0x22c070(_0x2e2228['error']['message']);}logger['error'](_0xe753('0xc'),_0x25aa06,_0x2e2228['error']['message']);return _0x56c2ac(_0x2e2228[_0xe753('0xf')][_0xe753('0x10')]);}else{logger[_0xe753('0x11')](_0xe753('0xc'),_0x25aa06,'request\x20sent');_0x56c2ac(_0x2e2228['result']['message']);}})[_0xe753('0x12')](function(_0x3561da){logger[_0xe753('0xf')](_0xe753('0xc'),_0x25aa06,_0x3561da);_0x22c070(_0x3561da);});});}