e741d162e6ffbc9e998b5c1f882c10be02b962f1
[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 _0x14f5=['bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateSquareMessage','SquareMessage','options','raw','util'];(function(_0x386525,_0xefae6){var _0x14d015=function(_0x4a45c1){while(--_0x4a45c1){_0x386525['push'](_0x386525['shift']());}};_0x14d015(++_0xefae6);}(_0x14f5,0xae));var _0x514f=function(_0x89c06a,_0x3d95ed){_0x89c06a=_0x89c06a-0x0;var _0x524261=_0x14f5[_0x89c06a];return _0x524261;};'use strict';var _=require('lodash');var util=require(_0x514f('0x0'));var moment=require('moment');var BPromise=require(_0x514f('0x1'));var rs=require(_0x514f('0x2'));var fs=require('fs');var Redis=require(_0x514f('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x514f('0x4'));var logger=require(_0x514f('0x5'))('rpc');var config=require(_0x514f('0x6'));var jayson=require(_0x514f('0x7'));var client=jayson[_0x514f('0x8')][_0x514f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x463985,_0x43ec42,_0xdb9614){return new BPromise(function(_0x4a5497,_0x203b02){return client['request'](_0x463985,_0xdb9614)[_0x514f('0xa')](function(_0x1e3fa7){logger[_0x514f('0xb')](_0x514f('0xc'),_0x43ec42,_0x514f('0xd'));logger[_0x514f('0xe')](_0x514f('0xf'),_0x43ec42,'request\x20sent',JSON['stringify'](_0x1e3fa7));if(_0x1e3fa7['error']){if(_0x1e3fa7[_0x514f('0x10')][_0x514f('0x11')]===0x1f4){logger[_0x514f('0x10')](_0x514f('0xc'),_0x43ec42,_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);return _0x203b02(_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);}logger[_0x514f('0x10')](_0x514f('0xc'),_0x43ec42,_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);return _0x4a5497(_0x1e3fa7[_0x514f('0x10')][_0x514f('0x12')]);}else{logger[_0x514f('0xb')]('SquareMessage,\x20%s,\x20%s',_0x43ec42,_0x514f('0xd'));_0x4a5497(_0x1e3fa7[_0x514f('0x13')]['message']);}})[_0x514f('0x14')](function(_0x53851d){logger[_0x514f('0x10')](_0x514f('0xc'),_0x43ec42,_0x53851d);_0x203b02(_0x53851d);});});}exports[_0x514f('0x15')]=function(_0x5a5641){var _0x28e99a=this;return new Promise(function(_0x3673a4,_0x2cdd0d){return db[_0x514f('0x16')]['create'](_0x5a5641['body'],{'raw':_0x5a5641[_0x514f('0x17')]?_0x5a5641[_0x514f('0x17')][_0x514f('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x43fcf9){logger[_0x514f('0xb')]('CreateSquareMessage',_0x5a5641);logger[_0x514f('0xe')](_0x514f('0x15'),_0x5a5641,JSON['stringify'](_0x43fcf9));_0x3673a4(_0x43fcf9);})[_0x514f('0x14')](function(_0x18a430){logger[_0x514f('0x10')](_0x514f('0x15'),_0x18a430['message'],_0x5a5641);_0x2cdd0d(_0x28e99a['error'](0x1f4,_0x18a430['message']));});});};