Built motion from commit (unavailable).|2.2.6
[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 _0x168e=['then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','CreateSquareMessage','SquareMessage','body','options','raw','catch','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request'];(function(_0x110c3d,_0x12ee06){var _0x226d67=function(_0x1fb6e1){while(--_0x1fb6e1){_0x110c3d['push'](_0x110c3d['shift']());}};_0x226d67(++_0x12ee06);}(_0x168e,0x84));var _0xe168=function(_0x22507f,_0x455c0b){_0x22507f=_0x22507f-0x0;var _0x366094=_0x168e[_0x22507f];return _0x366094;};'use strict';var _=require('lodash');var util=require(_0xe168('0x0'));var moment=require(_0xe168('0x1'));var BPromise=require(_0xe168('0x2'));var rs=require(_0xe168('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xe168('0x4'))['db'];var utils=require(_0xe168('0x5'));var logger=require(_0xe168('0x6'))(_0xe168('0x7'));var config=require(_0xe168('0x8'));var jayson=require(_0xe168('0x9'));var client=jayson[_0xe168('0xa')][_0xe168('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1ba807,_0xed3d2,_0x2d5fb0){return new BPromise(function(_0x2d2842,_0x17e7a6){return client[_0xe168('0xc')](_0x1ba807,_0x2d5fb0)[_0xe168('0xd')](function(_0x147368){logger[_0xe168('0xe')](_0xe168('0xf'),_0xed3d2,_0xe168('0x10'));logger[_0xe168('0x11')](_0xe168('0x12'),_0xed3d2,_0xe168('0x10'),JSON[_0xe168('0x13')](_0x147368));if(_0x147368[_0xe168('0x14')]){if(_0x147368[_0xe168('0x14')]['code']===0x1f4){logger['error']('SquareMessage,\x20%s,\x20%s',_0xed3d2,_0x147368[_0xe168('0x14')][_0xe168('0x15')]);return _0x17e7a6(_0x147368[_0xe168('0x14')][_0xe168('0x15')]);}logger[_0xe168('0x14')]('SquareMessage,\x20%s,\x20%s',_0xed3d2,_0x147368[_0xe168('0x14')][_0xe168('0x15')]);return _0x2d2842(_0x147368[_0xe168('0x14')][_0xe168('0x15')]);}else{logger[_0xe168('0xe')]('SquareMessage,\x20%s,\x20%s',_0xed3d2,_0xe168('0x10'));_0x2d2842(_0x147368[_0xe168('0x16')][_0xe168('0x15')]);}})['catch'](function(_0x50b5ad){logger[_0xe168('0x14')](_0xe168('0xf'),_0xed3d2,_0x50b5ad);_0x17e7a6(_0x50b5ad);});});}exports[_0xe168('0x17')]=function(_0x4686cc){var _0xd263e4=this;return new Promise(function(_0x3c54ef,_0x5c3cb2){return db[_0xe168('0x18')]['create'](_0x4686cc[_0xe168('0x19')],{'raw':_0x4686cc[_0xe168('0x1a')]?_0x4686cc['options'][_0xe168('0x1b')]===undefined?!![]:![]:!![]})[_0xe168('0xd')](function(_0x4d0f7b){logger[_0xe168('0xe')](_0xe168('0x17'),_0x4686cc);logger['debug'](_0xe168('0x17'),_0x4686cc,JSON[_0xe168('0x13')](_0x4d0f7b));_0x3c54ef(_0x4d0f7b);})[_0xe168('0x1c')](function(_0x4fcd3e){logger['error'](_0xe168('0x17'),_0x4fcd3e[_0xe168('0x15')],_0x4686cc);_0x5c3cb2(_0xd263e4[_0xe168('0x14')](0x1f4,_0x4fcd3e[_0xe168('0x15')]));});});};