9b05fc9472236f9d221ca781ec00c21cf3ce38ea
[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 _0x94a0=['message','result','catch','create','body','options','CreateSquareMessage','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x94a0,0x1c7));var _0x094a=function(_0x46efd7,_0x43f84d){_0x46efd7=_0x46efd7-0x0;var _0x5637e4=_0x94a0[_0x46efd7];return _0x5637e4;};'use strict';var _=require(_0x094a('0x0'));var util=require('util');var moment=require(_0x094a('0x1'));var BPromise=require(_0x094a('0x2'));var rs=require(_0x094a('0x3'));var fs=require('fs');var Redis=require(_0x094a('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x094a('0x5'));var logger=require(_0x094a('0x6'))(_0x094a('0x7'));var config=require(_0x094a('0x8'));var jayson=require(_0x094a('0x9'));var client=jayson[_0x094a('0xa')][_0x094a('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x426300,_0xd6393d,_0x7a0cbf){return new BPromise(function(_0x197f72,_0x35f758){return client[_0x094a('0xc')](_0x426300,_0x7a0cbf)[_0x094a('0xd')](function(_0x4c7443){logger[_0x094a('0xe')](_0x094a('0xf'),_0xd6393d,_0x094a('0x10'));logger[_0x094a('0x11')](_0x094a('0x12'),_0xd6393d,_0x094a('0x10'),JSON[_0x094a('0x13')](_0x4c7443));if(_0x4c7443[_0x094a('0x14')]){if(_0x4c7443[_0x094a('0x14')]['code']===0x1f4){logger[_0x094a('0x14')]('SquareMessage,\x20%s,\x20%s',_0xd6393d,_0x4c7443['error'][_0x094a('0x15')]);return _0x35f758(_0x4c7443[_0x094a('0x14')][_0x094a('0x15')]);}logger[_0x094a('0x14')]('SquareMessage,\x20%s,\x20%s',_0xd6393d,_0x4c7443[_0x094a('0x14')][_0x094a('0x15')]);return _0x197f72(_0x4c7443['error'][_0x094a('0x15')]);}else{logger[_0x094a('0xe')]('SquareMessage,\x20%s,\x20%s',_0xd6393d,_0x094a('0x10'));_0x197f72(_0x4c7443[_0x094a('0x16')][_0x094a('0x15')]);}})[_0x094a('0x17')](function(_0x28b8c8){logger[_0x094a('0x14')](_0x094a('0xf'),_0xd6393d,_0x28b8c8);_0x35f758(_0x28b8c8);});});}exports['CreateSquareMessage']=function(_0x54a040){var _0x38126f=this;return new Promise(function(_0x188074,_0x544f07){return db['SquareMessage'][_0x094a('0x18')](_0x54a040[_0x094a('0x19')],{'raw':_0x54a040[_0x094a('0x1a')]?_0x54a040[_0x094a('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x094a('0xd')](function(_0x27e378){logger['info'](_0x094a('0x1b'),_0x54a040);logger[_0x094a('0x11')](_0x094a('0x1b'),_0x54a040,JSON[_0x094a('0x13')](_0x27e378));_0x188074(_0x27e378);})[_0x094a('0x17')](function(_0x509d61){logger['error']('CreateSquareMessage',_0x509d61[_0x094a('0x15')],_0x54a040);_0x544f07(_0x38126f[_0x094a('0x14')](0x1f4,_0x509d61[_0x094a('0x15')]));});});};