@traund/orquezta-widget-calculator 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -70
- package/dist/index.js.map +1 -1
- package/dist/module.js +38 -74
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/src/calculatorV2.js +6 -6
- package/src/core/endpoints.js +20 -16
- package/src/simulator.js +4 -4
- package/src/utils/calculateHelper.js +3 -2
- package/src/utils/operationsHelper.js +4 -3
- package/src/utils/rateHelper.js +3 -3
- package/src/core/endpointsv2.js +0 -44
package/package.json
CHANGED
package/src/calculatorV2.js
CHANGED
|
@@ -292,12 +292,12 @@ class Calculator extends Component {
|
|
|
292
292
|
_convertAmount = async (currency) => {
|
|
293
293
|
try {
|
|
294
294
|
if (currency == "ARS") {
|
|
295
|
-
const { data } = await axios.get(`${this.ENDPOINTS.
|
|
295
|
+
const { data } = await axios.get(`${this.ENDPOINTS.EXCHANGE.getUSDBlueRate}`);
|
|
296
296
|
let blueRate = await JSON.parse(JSON.stringify(data));
|
|
297
297
|
blueRate = { result: blueRate.blue.value_sell };
|
|
298
298
|
return blueRate;
|
|
299
299
|
} else {
|
|
300
|
-
const { data } = await axios.get(`${this.ENDPOINTS.
|
|
300
|
+
const { data } = await axios.get(`${this.ENDPOINTS.EXCHANGE.getRate_v2(currency)}`);
|
|
301
301
|
return { result: parseFloat(data['usd'][currency.toLowerCase()].toFixed(2)) };
|
|
302
302
|
}
|
|
303
303
|
} catch (e) {
|
|
@@ -720,7 +720,7 @@ class Calculator extends Component {
|
|
|
720
720
|
};
|
|
721
721
|
|
|
722
722
|
if (source == "initial" || source == "end") {
|
|
723
|
-
const url = this.ENDPOINTS.
|
|
723
|
+
const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId || sessionStorage.getItem('storeId'), "from");
|
|
724
724
|
|
|
725
725
|
const res = await axios.post(
|
|
726
726
|
url,
|
|
@@ -779,7 +779,7 @@ class Calculator extends Component {
|
|
|
779
779
|
this.setState({
|
|
780
780
|
sendValue: "",
|
|
781
781
|
});
|
|
782
|
-
const url = this.ENDPOINTS.
|
|
782
|
+
const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId, source)
|
|
783
783
|
|
|
784
784
|
const res = await axios.post(
|
|
785
785
|
url,
|
|
@@ -982,7 +982,7 @@ class Calculator extends Component {
|
|
|
982
982
|
}
|
|
983
983
|
|
|
984
984
|
//if (db) db.clearPersistence();
|
|
985
|
-
const firebase = await loadFirebaseDB(this.state.testMode);
|
|
985
|
+
const firebase = await loadFirebaseDB(this.state.testMode,this.state.config);
|
|
986
986
|
const db = firebase.firestore();
|
|
987
987
|
|
|
988
988
|
if (this.state.couponRedeemed && this.state.couponValue != "") {
|
|
@@ -1060,7 +1060,7 @@ class Calculator extends Component {
|
|
|
1060
1060
|
};
|
|
1061
1061
|
|
|
1062
1062
|
validateCoupon = async (cupon) => {
|
|
1063
|
-
const url = `${this.ENDPOINTS.
|
|
1063
|
+
const url = `${this.ENDPOINTS.OPERATIONS.validateCoupon}/${cupon}`
|
|
1064
1064
|
|
|
1065
1065
|
try {
|
|
1066
1066
|
const response = await axios.get(
|
package/src/core/endpoints.js
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
import { BACKEND_SETTINGS } from "./backend-settings";
|
|
2
|
+
|
|
2
3
|
class EndPoints {
|
|
3
4
|
constructor(testMode = 'production', externalConfig = null) {
|
|
4
5
|
this._testMode = testMode;
|
|
5
|
-
this.baseUrl = externalConfig
|
|
6
|
+
this.baseUrl = externalConfig?.backendUrl;
|
|
6
7
|
this.path_managment_operations = `${this.baseUrl}/handle-operations`;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
/*get HEADERS() {
|
|
10
|
-
return this.baseUrl = BACKEND_SETTINGS[this._testMode].HEADERS;
|
|
11
|
-
};*/
|
|
12
10
|
|
|
13
|
-
get
|
|
11
|
+
get CALLBACK() {
|
|
14
12
|
return {
|
|
15
|
-
|
|
13
|
+
landing_transfer: (baseUrl, locale) => `${baseUrl}/${locale}/send`,
|
|
14
|
+
landing_receive: (baseUrl, locale) => `${baseUrl}/${locale}/receive`,
|
|
15
|
+
landing_wallet: (baseUrl, locale) => `${baseUrl}/${locale}/wallet`,
|
|
16
|
+
referral_transfer: (baseUrl, locale, storeId) => `${baseUrl}/${locale}/login?referral=operation&type=transfer&reference=${storeId}`,
|
|
17
|
+
referral_receive: (baseUrl, locale, storeId) => `${baseUrl}/${locale}/login?referral=operation&type=pay&reference=${storeId}`,
|
|
18
|
+
referral_recharge: (baseUrl, locale, storeId) => `${baseUrl}/${locale}/login?referral=operation&type=recharge&reference=${storeId}`,
|
|
16
19
|
}
|
|
17
20
|
};
|
|
18
21
|
|
|
19
|
-
get
|
|
22
|
+
get OPERATIONS() {
|
|
20
23
|
return {
|
|
21
|
-
calculate: `${this.path_managment_operations}/
|
|
22
|
-
|
|
23
|
-
`${this.path_managment_operations}/calculate/v1/update/${storeId}/${source}`,
|
|
24
|
+
calculate: (storeId, source) => `${this.path_managment_operations}/calculate/v1/update/${storeId}/${source}`,
|
|
25
|
+
validateCoupon: `${this.path_managment_operations}/coupon/v1/validate`
|
|
24
26
|
}
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
get
|
|
29
|
+
get EXCHANGE() {
|
|
28
30
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
getRate: (currencyFrom, currencyTo) => `https://api.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
|
|
32
|
+
getRate_bk_1: (currencyFrom, currencyTo) => `https://api-us.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
|
|
33
|
+
getRate_bk_2: (currencyFrom, currencyTo) => `https://api-eu.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
|
|
34
|
+
getRate_v2: (currencyFrom) => `https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/${currencyFrom.toLowerCase()}.json`,
|
|
35
|
+
getRate_v3: (currencyFrom, currencyTo) => `https://cdnhlp-staging.traund.xyz/rates/v1/${currencyFrom}/${currencyTo}`,
|
|
36
|
+
getUSDBlueRate: `https://api.bluelytics.com.ar/v2/latest`
|
|
33
37
|
}
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
export default EndPoints;
|
package/src/simulator.js
CHANGED
|
@@ -7,7 +7,7 @@ import Button from "@material-ui/core/Button";
|
|
|
7
7
|
import en from "./locale/en";
|
|
8
8
|
import es from "./locale/es";
|
|
9
9
|
import loadFirebaseDB from "./firebase.config";
|
|
10
|
-
import Endpoints from "./core/
|
|
10
|
+
import Endpoints from "./core/endpoints";
|
|
11
11
|
import TransferUser from "./model/transferUser";
|
|
12
12
|
import { TransferType, UserType, SimulatorMode } from "./model/enums";
|
|
13
13
|
import CalculateHelper from "./utils/calculateHelper";
|
|
@@ -33,9 +33,9 @@ function Simulator(props) {
|
|
|
33
33
|
const content = locale === "es" ? es : en;
|
|
34
34
|
const classes = useStyles();
|
|
35
35
|
|
|
36
|
-
const __ENDPOINTS = new Endpoints(props.testMode);
|
|
37
|
-
const __calculateHelper = new CalculateHelper(props.testMode);
|
|
38
|
-
const __operationsHelper = new OperationsHelper(props.testMode, props.reference);
|
|
36
|
+
const __ENDPOINTS = new Endpoints(props.testMode, props.config);
|
|
37
|
+
const __calculateHelper = new CalculateHelper(props.testMode, props.config);
|
|
38
|
+
const __operationsHelper = new OperationsHelper(props.testMode, props.reference,props.config);
|
|
39
39
|
|
|
40
40
|
const __firebase = loadFirebaseDB(props.testMode, props.config);
|
|
41
41
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import RateHelper from "./rateHelper";
|
|
2
2
|
|
|
3
3
|
class CalculateHelper {
|
|
4
|
-
constructor(testMode = 'production') {
|
|
4
|
+
constructor(testMode = 'production',config=null) {
|
|
5
5
|
this._testMode = testMode;
|
|
6
|
+
this.config = config;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
async getCaculateRates(countriesData) {
|
|
9
|
-
const rateHelper = new RateHelper(this._testMode);
|
|
10
|
+
const rateHelper = new RateHelper(this._testMode, this.config);
|
|
10
11
|
const middleCurrency = "USD";
|
|
11
12
|
|
|
12
13
|
for (var key in countriesData) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import moment from "moment";
|
|
3
|
-
import EndPoints from "../core/
|
|
3
|
+
import EndPoints from "../core/endpoints";
|
|
4
4
|
import { TRANSACTION_TIMES } from "../core/transaction-settings";
|
|
5
5
|
import { getExpirationDate } from "../core/working-setup";
|
|
6
6
|
import { getSignatureHeader } from "../../src/core/signature";
|
|
7
|
+
import { config } from "aws-sdk";
|
|
7
8
|
|
|
8
9
|
class OperationsHelper {
|
|
9
|
-
constructor(testMode = 'production', secretKey = null) {
|
|
10
|
-
this.endpoints = new EndPoints(testMode);
|
|
10
|
+
constructor(testMode = 'production', secretKey = null, config=null) {
|
|
11
|
+
this.endpoints = new EndPoints(testMode, config);
|
|
11
12
|
this.reference = secretKey;
|
|
12
13
|
this.FEES = {
|
|
13
14
|
"ach": { type: "A", value: 0 },
|
package/src/utils/rateHelper.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import EndPoints from "../core/
|
|
2
|
+
import EndPoints from "../core/endpoints";
|
|
3
3
|
|
|
4
4
|
class RateHelper {
|
|
5
|
-
constructor(testMode = 'production') {
|
|
6
|
-
this.endpoints = new EndPoints(testMode);
|
|
5
|
+
constructor(testMode = 'production',externalConfig = null) {
|
|
6
|
+
this.endpoints = new EndPoints(testMode, externalConfig);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async getExchangeRate(currencyFrom, currencyTo) {
|
package/src/core/endpointsv2.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { BACKEND_SETTINGS } from "./backend-settings";
|
|
2
|
-
|
|
3
|
-
class EndPoints {
|
|
4
|
-
constructor(testMode = 'production') {
|
|
5
|
-
this._testMode = testMode;
|
|
6
|
-
this.baseUrl = BACKEND_SETTINGS[this._testMode].URL;
|
|
7
|
-
this.path_managment_operations = `${this.baseUrl}/handle-operations`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
get HEADERS() {
|
|
11
|
-
return this.baseUrl = BACKEND_SETTINGS[this._testMode].HEADERS;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
get CALLBACK() {
|
|
15
|
-
return {
|
|
16
|
-
landing_transfer: (baseUrl, locale) => `${baseUrl}/${locale}/send`,
|
|
17
|
-
landing_receive: (baseUrl, locale) => `${baseUrl}/${locale}/receive`,
|
|
18
|
-
landing_wallet: (baseUrl, locale) => `${baseUrl}/${locale}/wallet`,
|
|
19
|
-
referral_transfer: (baseUrl, locale, storeId) => `${baseUrl}/${locale}/login?referral=operation&type=transfer&reference=${storeId}`,
|
|
20
|
-
referral_receive: (baseUrl, locale, storeId) => `${baseUrl}/${locale}/login?referral=operation&type=pay&reference=${storeId}`,
|
|
21
|
-
referral_recharge: (baseUrl, locale, storeId) => `${baseUrl}/${locale}/login?referral=operation&type=recharge&reference=${storeId}`,
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
get OPERATIONS() {
|
|
26
|
-
return {
|
|
27
|
-
calculate: (storeId, source) => `${this.path_managment_operations}/calculate/v1/update/${storeId}/${source}`,
|
|
28
|
-
validateCoupon: `${this.path_managment_operations}/coupon/v1/validate`
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
get EXCHANGE() {
|
|
33
|
-
return {
|
|
34
|
-
getRate: (currencyFrom, currencyTo) => `https://api.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
|
|
35
|
-
getRate_bk_1: (currencyFrom, currencyTo) => `https://api-us.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
|
|
36
|
-
getRate_bk_2: (currencyFrom, currencyTo) => `https://api-eu.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
|
|
37
|
-
getRate_v2: (currencyFrom) => `https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/${currencyFrom.toLowerCase()}.json`,
|
|
38
|
-
getRate_v3: (currencyFrom, currencyTo) => `https://cdnhlp-staging.traund.xyz/rates/v1/${currencyFrom}/${currencyTo}`,
|
|
39
|
-
getUSDBlueRate: `https://api.bluelytics.com.ar/v2/latest`
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default EndPoints;
|