Built motion from commit da617fac.|2.6.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 _0x509a=['debug','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','then','info','SquareMessage,\x20%s,\x20%s','request\x20sent','SquareMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateSquareMessage','SquareMessage','create','body','options'];(function(_0xd0c182,_0x527c8a){var _0x5a70eb=function(_0x5b210c){while(--_0x5b210c){_0xd0c182['push'](_0xd0c182['shift']());}};_0x5a70eb(++_0x527c8a);}(_0x509a,0x10f));var _0xa509=function(_0x2306de,_0x5b9304){_0x2306de=_0x2306de-0x0;var _0x3143e9=_0x509a[_0x2306de];return _0x3143e9;};'use strict';var _=require('lodash');var util=require(_0xa509('0x0'));var moment=require(_0xa509('0x1'));var BPromise=require(_0xa509('0x2'));var rs=require(_0xa509('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa509('0x4'))['db'];var utils=require(_0xa509('0x5'));var logger=require('../../config/logger')(_0xa509('0x6'));var config=require(_0xa509('0x7'));var jayson=require(_0xa509('0x8'));var client=jayson[_0xa509('0x9')][_0xa509('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x633422,_0xffa3fc,_0x25d7f6){return new BPromise(function(_0x1d428e,_0x129f09){return client['request'](_0x633422,_0x25d7f6)[_0xa509('0xb')](function(_0x473415){logger[_0xa509('0xc')](_0xa509('0xd'),_0xffa3fc,_0xa509('0xe'));logger['debug'](_0xa509('0xf'),_0xffa3fc,_0xa509('0xe'),JSON[_0xa509('0x10')](_0x473415));if(_0x473415[_0xa509('0x11')]){if(_0x473415[_0xa509('0x11')]['code']===0x1f4){logger[_0xa509('0x11')](_0xa509('0xd'),_0xffa3fc,_0x473415['error'][_0xa509('0x12')]);return _0x129f09(_0x473415[_0xa509('0x11')][_0xa509('0x12')]);}logger[_0xa509('0x11')](_0xa509('0xd'),_0xffa3fc,_0x473415[_0xa509('0x11')][_0xa509('0x12')]);return _0x1d428e(_0x473415[_0xa509('0x11')][_0xa509('0x12')]);}else{logger[_0xa509('0xc')](_0xa509('0xd'),_0xffa3fc,_0xa509('0xe'));_0x1d428e(_0x473415[_0xa509('0x13')][_0xa509('0x12')]);}})[_0xa509('0x14')](function(_0x35c492){logger['error'](_0xa509('0xd'),_0xffa3fc,_0x35c492);_0x129f09(_0x35c492);});});}exports[_0xa509('0x15')]=function(_0x1a6e75){var _0x3b267c=this;return new Promise(function(_0x5dd8af,_0x3a113a){return db[_0xa509('0x16')][_0xa509('0x17')](_0x1a6e75[_0xa509('0x18')],{'raw':_0x1a6e75['options']?_0x1a6e75[_0xa509('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x4c83b9){logger[_0xa509('0xc')](_0xa509('0x15'),_0x1a6e75);logger[_0xa509('0x1a')](_0xa509('0x15'),_0x1a6e75,JSON['stringify'](_0x4c83b9));_0x5dd8af(_0x4c83b9);})[_0xa509('0x14')](function(_0x469193){logger['error'](_0xa509('0x15'),_0x469193['message'],_0x1a6e75);_0x3a113a(_0x3b267c[_0xa509('0x11')](0x1f4,_0x469193['message']));});});};