Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / squareMessage / squareMessage.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 _0x19e0=['raw','then','CreateSquareMessage','catch','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','SquareMessage','create','body','options'];(function(_0x166fc3,_0xdded0f){var _0x49064a=function(_0x59ca76){while(--_0x59ca76){_0x166fc3['push'](_0x166fc3['shift']());}};_0x49064a(++_0xdded0f);}(_0x19e0,0x9f));var _0x019e=function(_0x5b1ec7,_0x4904ba){_0x5b1ec7=_0x5b1ec7-0x0;var _0x11d210=_0x19e0[_0x5b1ec7];return _0x11d210;};'use strict';var _=require(_0x019e('0x0'));var util=require(_0x019e('0x1'));var moment=require(_0x019e('0x2'));var BPromise=require(_0x019e('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x019e('0x4'));var db=require(_0x019e('0x5'))['db'];var utils=require(_0x019e('0x6'));var logger=require(_0x019e('0x7'))(_0x019e('0x8'));var config=require(_0x019e('0x9'));var jayson=require(_0x019e('0xa'));var client=jayson[_0x019e('0xb')][_0x019e('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x35680e,_0x4a49c3,_0x47533d){return new BPromise(function(_0x17c16a,_0x2785c8){return client['request'](_0x35680e,_0x47533d)['then'](function(_0x4079b7){logger[_0x019e('0xd')](_0x019e('0xe'),_0x4a49c3,_0x019e('0xf'));logger[_0x019e('0x10')](_0x019e('0x11'),_0x4a49c3,_0x019e('0xf'),JSON[_0x019e('0x12')](_0x4079b7));if(_0x4079b7[_0x019e('0x13')]){if(_0x4079b7['error'][_0x019e('0x14')]===0x1f4){logger['error'](_0x019e('0xe'),_0x4a49c3,_0x4079b7[_0x019e('0x13')][_0x019e('0x15')]);return _0x2785c8(_0x4079b7[_0x019e('0x13')][_0x019e('0x15')]);}logger[_0x019e('0x13')]('SquareMessage,\x20%s,\x20%s',_0x4a49c3,_0x4079b7[_0x019e('0x13')]['message']);return _0x17c16a(_0x4079b7['error']['message']);}else{logger[_0x019e('0xd')]('SquareMessage,\x20%s,\x20%s',_0x4a49c3,'request\x20sent');_0x17c16a(_0x4079b7[_0x019e('0x16')][_0x019e('0x15')]);}})['catch'](function(_0x453ca1){logger[_0x019e('0x13')]('SquareMessage,\x20%s,\x20%s',_0x4a49c3,_0x453ca1);_0x2785c8(_0x453ca1);});});}exports['CreateSquareMessage']=function(_0x34d1d7){var _0x3e65a9=this;return new Promise(function(_0x27acd4,_0x5b0ef9){return db[_0x019e('0x17')][_0x019e('0x18')](_0x34d1d7[_0x019e('0x19')],{'raw':_0x34d1d7[_0x019e('0x1a')]?_0x34d1d7['options'][_0x019e('0x1b')]===undefined?!![]:![]:!![]})[_0x019e('0x1c')](function(_0x2bc034){logger['info'](_0x019e('0x1d'),_0x34d1d7);logger['debug']('CreateSquareMessage',_0x34d1d7,JSON['stringify'](_0x2bc034));_0x27acd4(_0x2bc034);})[_0x019e('0x1e')](function(_0x3f7232){logger['error'](_0x019e('0x1d'),_0x3f7232['message'],_0x34d1d7);_0x5b0ef9(_0x3e65a9['error'](0x1f4,_0x3f7232[_0x019e('0x15')]));});});};