Built motion from commit a679711e.|2.6.15
[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 _0x6cfb=['CreateSquareMessage','SquareMessage','create','body','options','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','debug','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch'];(function(_0x46a9fc,_0x2e0297){var _0x3bc1a7=function(_0x54f6f6){while(--_0x54f6f6){_0x46a9fc['push'](_0x46a9fc['shift']());}};_0x3bc1a7(++_0x2e0297);}(_0x6cfb,0x1aa));var _0xb6cf=function(_0x424a9a,_0x2dd9af){_0x424a9a=_0x424a9a-0x0;var _0xa7831c=_0x6cfb[_0x424a9a];return _0xa7831c;};'use strict';var _=require(_0xb6cf('0x0'));var util=require(_0xb6cf('0x1'));var moment=require(_0xb6cf('0x2'));var BPromise=require(_0xb6cf('0x3'));var rs=require(_0xb6cf('0x4'));var fs=require('fs');var Redis=require(_0xb6cf('0x5'));var db=require(_0xb6cf('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xb6cf('0x7'))(_0xb6cf('0x8'));var config=require(_0xb6cf('0x9'));var jayson=require(_0xb6cf('0xa'));var client=jayson[_0xb6cf('0xb')][_0xb6cf('0xc')]({'port':0x232a});function respondWithRpcPromise(_0xc82d84,_0x2be266,_0xed065a){return new BPromise(function(_0x48ec5e,_0x46c004){return client['request'](_0xc82d84,_0xed065a)[_0xb6cf('0xd')](function(_0x29b074){logger[_0xb6cf('0xe')](_0xb6cf('0xf'),_0x2be266,_0xb6cf('0x10'));logger[_0xb6cf('0x11')](_0xb6cf('0x12'),_0x2be266,'request\x20sent',JSON[_0xb6cf('0x13')](_0x29b074));if(_0x29b074[_0xb6cf('0x14')]){if(_0x29b074['error'][_0xb6cf('0x15')]===0x1f4){logger['error'](_0xb6cf('0xf'),_0x2be266,_0x29b074[_0xb6cf('0x14')]['message']);return _0x46c004(_0x29b074[_0xb6cf('0x14')][_0xb6cf('0x16')]);}logger['error'](_0xb6cf('0xf'),_0x2be266,_0x29b074[_0xb6cf('0x14')][_0xb6cf('0x16')]);return _0x48ec5e(_0x29b074[_0xb6cf('0x14')]['message']);}else{logger[_0xb6cf('0xe')]('SquareMessage,\x20%s,\x20%s',_0x2be266,'request\x20sent');_0x48ec5e(_0x29b074['result'][_0xb6cf('0x16')]);}})[_0xb6cf('0x17')](function(_0x14f906){logger[_0xb6cf('0x14')](_0xb6cf('0xf'),_0x2be266,_0x14f906);_0x46c004(_0x14f906);});});}exports[_0xb6cf('0x18')]=function(_0x1965d4){var _0x2af38c=this;return new Promise(function(_0x434e47,_0x2a5f92){return db[_0xb6cf('0x19')][_0xb6cf('0x1a')](_0x1965d4[_0xb6cf('0x1b')],{'raw':_0x1965d4['options']?_0x1965d4[_0xb6cf('0x1c')][_0xb6cf('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0xfc4109){logger[_0xb6cf('0xe')](_0xb6cf('0x18'),_0x1965d4);logger['debug']('CreateSquareMessage',_0x1965d4,JSON['stringify'](_0xfc4109));_0x434e47(_0xfc4109);})[_0xb6cf('0x17')](function(_0x295e7a){logger[_0xb6cf('0x14')]('CreateSquareMessage',_0x295e7a['message'],_0x1965d4);_0x2a5f92(_0x2af38c[_0xb6cf('0x14')](0x1f4,_0x295e7a[_0xb6cf('0x16')]));});});};