@a-tech.jo/atech_payment 1.0.6 → 1.0.8
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/README.md +8 -2
- package/index.js +17 -8
- package/package.json +2 -2
- package/src/hyperpay/hyperpayOrder.js +85 -85
- package/src/paypal/paypalOrder.js +24 -23
- package/src/shared/config.js +17 -9
- package/src/shared/requests/backendConnector.js +16 -16
- package/src/shared/requests/hyperpayConnector.js +8 -10
- package/src/shared/requests/request.js +75 -73
package/README.md
CHANGED
|
@@ -17,10 +17,16 @@ This Package is the frontend interface to integrate with A-Tech payment project,
|
|
|
17
17
|
3. **Publishing**
|
|
18
18
|
When ready to share the package, publish it by running `npm publish`.
|
|
19
19
|
After publishing, it can be installed in any app using:
|
|
20
|
-
`npm run publish`
|
|
20
|
+
`npm run publish:npm`
|
|
21
21
|
|
|
22
22
|
4. **Add to your project**
|
|
23
23
|
1. Open next.config.js
|
|
24
24
|
2. Add the package to transpilePackages key as below:
|
|
25
25
|
transpilePackages: [ "@a-tech.jo/atech_payment"]
|
|
26
|
-
3. use the package
|
|
26
|
+
3. use the package
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
5. **To specify environment it can be detected using.env variable NODE_ENV as below: **
|
|
30
|
+
1. production
|
|
31
|
+
2. staging
|
|
32
|
+
3. development
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import HyperpayOrder from "./src/hyperpay/hyperpayOrder.js";
|
|
2
2
|
import PaypalOrder from "./src/paypal/paypalOrder.js";
|
|
3
|
+
import hyperpayConnector from "./src/shared/requests/hyperpayConnector.js";
|
|
3
4
|
|
|
4
5
|
const PymentOrder = ({
|
|
5
6
|
provider = "hyperpay",
|
|
@@ -7,30 +8,38 @@ const PymentOrder = ({
|
|
|
7
8
|
clientId = "test",
|
|
8
9
|
onChange = () => {},
|
|
9
10
|
onStatusChange = () => {},
|
|
10
|
-
env = "development",
|
|
11
11
|
redirectUrl = "",
|
|
12
12
|
}) => {
|
|
13
13
|
if (provider === "paypal") {
|
|
14
|
-
console.log(process.env.API_URL);
|
|
15
14
|
return (
|
|
16
15
|
<PaypalOrder
|
|
17
16
|
order={order}
|
|
18
17
|
clientId={clientId}
|
|
19
18
|
onChange={onChange}
|
|
20
19
|
onStatusChange={onStatusChange}
|
|
21
|
-
env={env}
|
|
22
20
|
/>
|
|
23
21
|
);
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
if (provider === "hyperpay") {
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<HyperpayOrder order={order} redirectUrl={redirectUrl} env={env} />
|
|
30
|
-
);
|
|
25
|
+
return <HyperpayOrder order={order} redirectUrl={redirectUrl} />;
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
return <div />;
|
|
34
29
|
};
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
const verifyCheckout = async (provider, checkoutId, env, resoucePath) => {
|
|
32
|
+
if (provider === "hyperpay") {
|
|
33
|
+
const response = await hyperpayConnector.getOrderStatus(
|
|
34
|
+
checkoutId,
|
|
35
|
+
env,
|
|
36
|
+
resoucePath
|
|
37
|
+
);
|
|
38
|
+
console.log(response);
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return false;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { PymentOrder, verifyCheckout };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a-tech.jo/atech_payment",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A-Tech Payment React Package",
|
|
6
6
|
"source": "index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"build:prod": "webpack --mode=production --node-env=production",
|
|
20
20
|
"watch": "webpack --watch",
|
|
21
21
|
"serve": "webpack serve",
|
|
22
|
-
"publish": "npm publish --access public"
|
|
22
|
+
"publish:npm": "npm publish --access public"
|
|
23
23
|
},
|
|
24
24
|
"author": "A-Tech",
|
|
25
25
|
"license": "GNU",
|
|
@@ -1,99 +1,99 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import hyperpayConnector from "../shared/requests/hyperpayConnector.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import backendConnector from "../shared/requests/backendConnector.js";
|
|
4
|
+
|
|
5
|
+
const HyperpayOrder = ({ redirectUrl, order }) => {
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
const [checkoutId, setCheckoutId] = useState(null);
|
|
8
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (order) {
|
|
12
|
+
initiateOrder();
|
|
13
|
+
}
|
|
14
|
+
}, [order]);
|
|
15
|
+
|
|
16
|
+
const initiateOrder = async () => {
|
|
17
|
+
try {
|
|
18
|
+
if (!order) {
|
|
19
|
+
setError("Order data must be provided");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
setIsLoading(true);
|
|
23
|
+
const result = await hyperpayConnector.createHyperpayOrder(order);
|
|
24
|
+
setIsLoading(false);
|
|
25
|
+
|
|
26
|
+
if (result?.error) {
|
|
27
|
+
setError(result.error);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (result?.id) return setCheckoutId(result.id);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error("err", err);
|
|
34
|
+
setError("An unexpected error occurred.");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const checkout = async () => {
|
|
39
|
+
try {
|
|
40
|
+
if (!checkoutId) {
|
|
41
|
+
setError("Checkout ID must be provided");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setIsLoading(true);
|
|
45
|
+
const result = await hyperpayConnector.getOrderStatus(checkoutId);
|
|
46
|
+
setIsLoading(false);
|
|
47
|
+
|
|
48
|
+
if (result?.error) {
|
|
49
|
+
setError(result.error);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return result;
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.error("err", err);
|
|
56
|
+
setError("An unexpected error occurred.");
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (checkoutId) {
|
|
62
|
+
const script = document.createElement("script");
|
|
63
|
+
script.src = `https://eu-test.oppwa.com/v1/paymentWidgets.js?checkoutId=${checkoutId}`;
|
|
64
|
+
script.async = true;
|
|
65
|
+
script.crossOrigin = "anonymous";
|
|
66
|
+
document.body.appendChild(script);
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
document.body.removeChild(script);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}, [checkoutId]);
|
|
73
|
+
|
|
74
|
+
if (error) {
|
|
75
|
+
return <p>Error: {error}</p>;
|
|
12
76
|
}
|
|
13
|
-
}, [order]);
|
|
14
|
-
|
|
15
|
-
const initiateOrder = async () => {
|
|
16
|
-
try {
|
|
17
|
-
if (!order) {
|
|
18
|
-
setError("Data must be provided");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
setIsLoading(true);
|
|
22
|
-
const result = await hyperpayConnector.createHyperpayOrder(order, env);
|
|
23
|
-
setIsLoading(false);
|
|
24
|
-
|
|
25
|
-
if (result?.error) {
|
|
26
|
-
setError(result.error);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
77
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
console.error("err", err);
|
|
33
|
-
setError("An unexpected error occurred.");
|
|
78
|
+
if (isLoading) {
|
|
79
|
+
return <p>Loading...</p>;
|
|
34
80
|
}
|
|
35
|
-
};
|
|
36
81
|
|
|
37
|
-
const checkout = async ( ) => {
|
|
38
|
-
try {
|
|
39
|
-
if (!checkoutId) {
|
|
40
|
-
setError("Checkout ID must be provided");
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
setIsLoading(true);
|
|
44
|
-
const result = await hyperpayConnector.getOrderStatus(checkoutId, env);
|
|
45
|
-
setIsLoading(false);
|
|
46
|
-
|
|
47
|
-
if (result?.error) {
|
|
48
|
-
setError(result.error);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return result;
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.error("err", err);
|
|
55
|
-
setError("An unexpected error occurred.");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
82
|
if (checkoutId) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
document.body.removeChild(script);
|
|
69
|
-
};
|
|
83
|
+
return (
|
|
84
|
+
<form
|
|
85
|
+
action={redirectUrl}
|
|
86
|
+
className="paymentWidgets"
|
|
87
|
+
data-brands="VISA MASTER AMEX"
|
|
88
|
+
></form>
|
|
89
|
+
);
|
|
70
90
|
}
|
|
71
|
-
}, [checkoutId]);
|
|
72
|
-
|
|
73
|
-
if (error) {
|
|
74
|
-
return <p>Error: {error}</p>;
|
|
75
|
-
}
|
|
76
91
|
|
|
77
|
-
|
|
78
|
-
if (isLoading) {
|
|
79
|
-
return <p>Loading...</p>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (checkoutId) {
|
|
83
92
|
return (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
data-brands="VISA MASTER AMEX"
|
|
88
|
-
></form>
|
|
93
|
+
<div>
|
|
94
|
+
<p>No order</p>
|
|
95
|
+
</div>
|
|
89
96
|
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<div>
|
|
94
|
-
<p>No order</p>
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
export default HyperpayOrder;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PayPalScriptProvider } from "@paypal/react-paypal-js";
|
|
3
3
|
import ButtonWrapper from "./buttonWrapper.js";
|
|
4
|
+
import config from "../shared/config.js";
|
|
4
5
|
|
|
5
6
|
const PaypalOrder = ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
env,
|
|
7
|
+
currency = "USD",
|
|
8
|
+
clientId = "test",
|
|
9
|
+
order = {},
|
|
10
|
+
onChange = () => {},
|
|
11
|
+
onStatusChange = () => {},
|
|
12
12
|
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
const env = config.NODE_ENV;
|
|
14
|
+
const initialOptions = {
|
|
15
|
+
clientId: clientId,
|
|
16
|
+
currency: currency,
|
|
17
|
+
vault: order.type === "subscription",
|
|
18
|
+
};
|
|
19
|
+
return (
|
|
20
|
+
<div style={{ maxWidth: "750px", minHeight: "200px" }}>
|
|
21
|
+
<PayPalScriptProvider options={initialOptions}>
|
|
22
|
+
<ButtonWrapper
|
|
23
|
+
order={order}
|
|
24
|
+
onChange={onChange}
|
|
25
|
+
onStatusChange={onStatusChange}
|
|
26
|
+
env={env}
|
|
27
|
+
/>
|
|
28
|
+
</PayPalScriptProvider>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
export default PaypalOrder;
|
package/src/shared/config.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
},
|
|
6
|
-
production: {
|
|
7
|
-
BACKEND_BASE_URL: "http://prod:5000/api",
|
|
8
|
-
HYPERPAY_BASE_URL: "https://eu-prod.oppwa.com/",
|
|
9
|
-
},
|
|
1
|
+
let config = {
|
|
2
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
3
|
+
BACKEND_BASE_URL: "http://localhost:5000/api",
|
|
4
|
+
HYPERPAY_BASE_URL: "https://eu-test.oppwa.com/",
|
|
10
5
|
};
|
|
11
6
|
|
|
7
|
+
const production = {
|
|
8
|
+
BACKEND_BASE_URL: "http://prod:5000/api",
|
|
9
|
+
HYPERPAY_BASE_URL: "https://eu-prod.oppwa.com/",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const staging = {
|
|
13
|
+
BACKEND_BASE_URL: "https://stage.payment.atech-workspace.com/api",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
if (process.env.NODE_ENV === "production")
|
|
17
|
+
config = { ...config, ...production };
|
|
18
|
+
if (process.env.NODE_ENV === "staging") config = { ...config, ...staging };
|
|
19
|
+
|
|
12
20
|
export default config;
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
import request from "./request.js";
|
|
3
3
|
|
|
4
4
|
class BackendConnector {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
async createPaypalOrder(data) {
|
|
6
|
+
const requestConfig = {
|
|
7
|
+
url: "/paypal/orders/create-order",
|
|
8
|
+
data,
|
|
9
|
+
};
|
|
10
|
+
const result = await request.post(requestConfig);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
async approveOrder(data) {
|
|
15
|
+
const requestConfig = {
|
|
16
|
+
url: "/paypal/orders/capture-order",
|
|
17
|
+
data,
|
|
18
|
+
};
|
|
19
|
+
const result = await request.post(requestConfig);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export default new BackendConnector();
|
|
@@ -4,8 +4,8 @@ import request from "./request.js";
|
|
|
4
4
|
|
|
5
5
|
class HyperpayConnector {
|
|
6
6
|
constructor() {
|
|
7
|
-
this.BASEURL = config.
|
|
8
|
-
|
|
7
|
+
this.BASEURL = config.BACKEND_BASE_URL;
|
|
8
|
+
axios.defaults.baseURL = config.BACKEND_BASE_URL;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
defaultHeaders = (data) => {
|
|
@@ -16,37 +16,35 @@ class HyperpayConnector {
|
|
|
16
16
|
|
|
17
17
|
return headers;
|
|
18
18
|
};
|
|
19
|
-
async createHyperpayOrder(data
|
|
19
|
+
async createHyperpayOrder(data) {
|
|
20
|
+
// Create an order and return checkoutID
|
|
20
21
|
const headers = this.defaultHeaders();
|
|
21
22
|
const url = "/hyperpay/orders/create-order";
|
|
22
23
|
const requestConfig = {
|
|
23
24
|
url: url,
|
|
24
|
-
// baseUrl: env === "development" ? this.DEV_BASEURL : this.BASEURL,
|
|
25
25
|
data,
|
|
26
26
|
headers: headers,
|
|
27
27
|
};
|
|
28
28
|
console.log("requestConfig", requestConfig);
|
|
29
|
-
const result = await request.post(requestConfig
|
|
29
|
+
const result = await request.post(requestConfig);
|
|
30
30
|
console.log("result", result);
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async getOrderStatus(checkoutId,
|
|
34
|
+
async getOrderStatus(checkoutId, resourcePath) {
|
|
35
35
|
const headers = this.defaultHeaders();
|
|
36
36
|
const requestConfig = {
|
|
37
|
-
url: `/hyperpay/orders/get-order/${checkoutId}`,
|
|
38
|
-
// baseUrl: env === "development" ? this.DEV_BASEURL : this.BASEURL,
|
|
37
|
+
url: `/hyperpay/orders/get-order/${checkoutId}?resoucePath=${resourcePath}`,
|
|
39
38
|
headers,
|
|
40
39
|
};
|
|
41
40
|
const result = await request.get(requestConfig);
|
|
42
41
|
return result;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
async captureOrder(orderId
|
|
44
|
+
async captureOrder(orderId) {
|
|
46
45
|
const headers = this.defaultHeaders();
|
|
47
46
|
const requestConfig = {
|
|
48
47
|
url: `/hyperpay/orders/capture-order/${orderId}`,
|
|
49
|
-
// baseUrl: env === "development" ? this.DEV_BASEURL : this.BASEURL,
|
|
50
48
|
headers,
|
|
51
49
|
};
|
|
52
50
|
const result = await request.post(requestConfig);
|
|
@@ -3,88 +3,90 @@ import axios from "axios";
|
|
|
3
3
|
import config from "../config.js";
|
|
4
4
|
|
|
5
5
|
class Request {
|
|
6
|
-
|
|
6
|
+
constructor() {}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return response.data;
|
|
14
|
-
} catch (err) {
|
|
15
|
-
console.log("err", err);
|
|
16
|
-
if (err.response) {
|
|
17
|
-
if (err.response.status === 401) {
|
|
18
|
-
return (window.location.href = "/login");
|
|
19
|
-
}
|
|
20
|
-
return err.response.data;
|
|
21
|
-
} else if (err.request) {
|
|
22
|
-
return {
|
|
23
|
-
success: false,
|
|
24
|
-
message: "No response received, please try again later.",
|
|
25
|
-
};
|
|
26
|
-
} else {
|
|
8
|
+
async handleRequests(finalConfig) {
|
|
9
|
+
try {
|
|
10
|
+
axios.defaults.baseURL = config.BACKEND_BASE_URL;
|
|
11
|
+
const response = await axios.request(finalConfig);
|
|
27
12
|
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
return response.data;
|
|
14
|
+
} catch (err) {
|
|
15
|
+
console.log("err", err);
|
|
16
|
+
if (err.response) {
|
|
17
|
+
if (err.response.status === 401) {
|
|
18
|
+
return (window.location.href = "/login");
|
|
19
|
+
}
|
|
20
|
+
return err.response.data;
|
|
21
|
+
} else if (err.request) {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
message: "No response received, please try again later.",
|
|
25
|
+
};
|
|
26
|
+
} else {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
message: "An unexpected error occurred.",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
30
33
|
}
|
|
31
|
-
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
async post(config) {
|
|
36
|
+
const defaultConfig = {
|
|
37
|
+
method: "post",
|
|
38
|
+
};
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const finalConfig = {
|
|
41
|
+
...defaultConfig,
|
|
42
|
+
...config,
|
|
43
|
+
};
|
|
44
|
+
return await this.handleRequests(finalConfig);
|
|
45
|
+
}
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
async get(config = {}) {
|
|
48
|
+
const defaultConfig = {
|
|
49
|
+
method: "get",
|
|
50
|
+
};
|
|
51
|
+
const finalConfig = {
|
|
52
|
+
...defaultConfig,
|
|
53
|
+
...config,
|
|
54
|
+
};
|
|
55
|
+
return await this.handleRequests(finalConfig);
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
async put(config) {
|
|
59
|
+
const defaultConfig = {
|
|
60
|
+
method: "put",
|
|
61
|
+
};
|
|
62
|
+
const finalConfig = {
|
|
63
|
+
...defaultConfig,
|
|
64
|
+
...config,
|
|
65
|
+
};
|
|
66
|
+
return await this.handleRequests(finalConfig);
|
|
67
|
+
}
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
async patch(config) {
|
|
70
|
+
const defaultConfig = {
|
|
71
|
+
method: "patch",
|
|
72
|
+
};
|
|
73
|
+
const finalConfig = {
|
|
74
|
+
...defaultConfig,
|
|
75
|
+
...config,
|
|
76
|
+
};
|
|
77
|
+
return await this.handleRequests(finalConfig);
|
|
78
|
+
}
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
async delete(config) {
|
|
81
|
+
const defaultConfig = {
|
|
82
|
+
method: "delete",
|
|
83
|
+
};
|
|
84
|
+
const finalConfig = {
|
|
85
|
+
...defaultConfig,
|
|
86
|
+
...config,
|
|
87
|
+
};
|
|
88
|
+
return await this.handleRequests(finalConfig);
|
|
89
|
+
}
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
export default new Request();
|