Built motion from commit 87cd5f02.|2.5.48
[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 _0x94ab=['info','request\x20sent','debug','stringify','code','SquareMessage,\x20%s,\x20%s','error','message','catch','CreateSquareMessage','SquareMessage','options','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then'];(function(_0x45c295,_0x396df0){var _0x3cb68c=function(_0x3e3d70){while(--_0x3e3d70){_0x45c295['push'](_0x45c295['shift']());}};_0x3cb68c(++_0x396df0);}(_0x94ab,0x110));var _0xb94a=function(_0x37ef2e,_0xe11b86){_0x37ef2e=_0x37ef2e-0x0;var _0x33c7c0=_0x94ab[_0x37ef2e];return _0x33c7c0;};'use strict';var _=require(_0xb94a('0x0'));var util=require(_0xb94a('0x1'));var moment=require(_0xb94a('0x2'));var BPromise=require(_0xb94a('0x3'));var rs=require(_0xb94a('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb94a('0x5'))['db'];var utils=require(_0xb94a('0x6'));var logger=require(_0xb94a('0x7'))(_0xb94a('0x8'));var config=require(_0xb94a('0x9'));var jayson=require(_0xb94a('0xa'));var client=jayson[_0xb94a('0xb')][_0xb94a('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1f9598,_0x39f238,_0x256b1a){return new BPromise(function(_0x132e46,_0x134bd0){return client['request'](_0x1f9598,_0x256b1a)[_0xb94a('0xd')](function(_0x2f3299){logger[_0xb94a('0xe')]('SquareMessage,\x20%s,\x20%s',_0x39f238,_0xb94a('0xf'));logger[_0xb94a('0x10')]('SquareMessage,\x20%s,\x20%s,\x20%s',_0x39f238,_0xb94a('0xf'),JSON[_0xb94a('0x11')](_0x2f3299));if(_0x2f3299['error']){if(_0x2f3299['error'][_0xb94a('0x12')]===0x1f4){logger['error'](_0xb94a('0x13'),_0x39f238,_0x2f3299[_0xb94a('0x14')][_0xb94a('0x15')]);return _0x134bd0(_0x2f3299['error']['message']);}logger[_0xb94a('0x14')](_0xb94a('0x13'),_0x39f238,_0x2f3299[_0xb94a('0x14')][_0xb94a('0x15')]);return _0x132e46(_0x2f3299[_0xb94a('0x14')][_0xb94a('0x15')]);}else{logger[_0xb94a('0xe')](_0xb94a('0x13'),_0x39f238,'request\x20sent');_0x132e46(_0x2f3299['result'][_0xb94a('0x15')]);}})[_0xb94a('0x16')](function(_0x32332a){logger['error'](_0xb94a('0x13'),_0x39f238,_0x32332a);_0x134bd0(_0x32332a);});});}exports[_0xb94a('0x17')]=function(_0x45687c){var _0x1c0e77=this;return new Promise(function(_0x4f6f1a,_0xd13066){return db[_0xb94a('0x18')]['create'](_0x45687c['body'],{'raw':_0x45687c[_0xb94a('0x19')]?_0x45687c[_0xb94a('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x5f349a){logger[_0xb94a('0xe')](_0xb94a('0x17'),_0x45687c);logger[_0xb94a('0x10')](_0xb94a('0x17'),_0x45687c,JSON[_0xb94a('0x11')](_0x5f349a));_0x4f6f1a(_0x5f349a);})[_0xb94a('0x16')](function(_0x233893){logger[_0xb94a('0x14')](_0xb94a('0x17'),_0x233893[_0xb94a('0x15')],_0x45687c);_0xd13066(_0x1c0e77[_0xb94a('0x14')](0x1f4,_0x233893[_0xb94a('0x15')]));});});};