e0666ef538180591634b230b691ef3f29feb7df0
[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 _0xd08e=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','SquareMessage','body','options','raw','CreateSquareMessage','lodash','util','moment','randomstring','ioredis'];(function(_0x1e20fc,_0x5da135){var _0x306a71=function(_0x33c657){while(--_0x33c657){_0x1e20fc['push'](_0x1e20fc['shift']());}};_0x306a71(++_0x5da135);}(_0xd08e,0x113));var _0xed08=function(_0x3d4876,_0x366386){_0x3d4876=_0x3d4876-0x0;var _0x58ca9d=_0xd08e[_0x3d4876];return _0x58ca9d;};'use strict';var _=require(_0xed08('0x0'));var util=require(_0xed08('0x1'));var moment=require(_0xed08('0x2'));var BPromise=require('bluebird');var rs=require(_0xed08('0x3'));var fs=require('fs');var Redis=require(_0xed08('0x4'));var db=require(_0xed08('0x5'))['db'];var utils=require(_0xed08('0x6'));var logger=require(_0xed08('0x7'))(_0xed08('0x8'));var config=require(_0xed08('0x9'));var jayson=require(_0xed08('0xa'));var client=jayson['client'][_0xed08('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1e86eb,_0xea44fc,_0xeda38e){return new BPromise(function(_0x50c939,_0x5614cd){return client[_0xed08('0xc')](_0x1e86eb,_0xeda38e)['then'](function(_0x1f945){logger[_0xed08('0xd')](_0xed08('0xe'),_0xea44fc,_0xed08('0xf'));logger[_0xed08('0x10')](_0xed08('0x11'),_0xea44fc,_0xed08('0xf'),JSON[_0xed08('0x12')](_0x1f945));if(_0x1f945['error']){if(_0x1f945[_0xed08('0x13')]['code']===0x1f4){logger[_0xed08('0x13')](_0xed08('0xe'),_0xea44fc,_0x1f945['error'][_0xed08('0x14')]);return _0x5614cd(_0x1f945[_0xed08('0x13')][_0xed08('0x14')]);}logger[_0xed08('0x13')]('SquareMessage,\x20%s,\x20%s',_0xea44fc,_0x1f945[_0xed08('0x13')][_0xed08('0x14')]);return _0x50c939(_0x1f945['error']['message']);}else{logger[_0xed08('0xd')]('SquareMessage,\x20%s,\x20%s',_0xea44fc,'request\x20sent');_0x50c939(_0x1f945[_0xed08('0x15')][_0xed08('0x14')]);}})[_0xed08('0x16')](function(_0x52685e){logger[_0xed08('0x13')](_0xed08('0xe'),_0xea44fc,_0x52685e);_0x5614cd(_0x52685e);});});}exports['CreateSquareMessage']=function(_0x39541f){var _0x153bfd=this;return new Promise(function(_0x15dec8,_0x3b2f9a){return db[_0xed08('0x17')]['create'](_0x39541f[_0xed08('0x18')],{'raw':_0x39541f['options']?_0x39541f[_0xed08('0x19')][_0xed08('0x1a')]===undefined?!![]:![]:!![]})['then'](function(_0x4cc09c){logger[_0xed08('0xd')](_0xed08('0x1b'),_0x39541f);logger[_0xed08('0x10')](_0xed08('0x1b'),_0x39541f,JSON[_0xed08('0x12')](_0x4cc09c));_0x15dec8(_0x4cc09c);})['catch'](function(_0x2842d7){logger[_0xed08('0x13')](_0xed08('0x1b'),_0x2842d7[_0xed08('0x14')],_0x39541f);_0x3b2f9a(_0x153bfd[_0xed08('0x13')](0x1f4,_0x2842d7[_0xed08('0x14')]));});});};