@qite/tide-client 1.0.46 → 1.0.47
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/build/index.js.map +1 -1
- package/build/utils/api.d.ts +5 -0
- package/build/utils/web-file.d.ts +14 -0
- package/package.json +1 -1
- package/src/utils/api.ts +20 -0
- package/src/utils/web-file.ts +24 -0
package/build/utils/api.d.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TideClientConfig } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* api/web/file/feed
|
|
4
|
+
* fetch a xml from blob feed.
|
|
5
|
+
* @param config
|
|
6
|
+
* @param request
|
|
7
|
+
* @param signal
|
|
8
|
+
* @returns OK if succeeded.
|
|
9
|
+
*/
|
|
10
|
+
export declare const contactForm: (
|
|
11
|
+
config: TideClientConfig,
|
|
12
|
+
request: string,
|
|
13
|
+
signal?: AbortSignal | undefined
|
|
14
|
+
) => Promise<Response>;
|
package/package.json
CHANGED
package/src/utils/api.ts
CHANGED
|
@@ -20,3 +20,23 @@ export const post = async (
|
|
|
20
20
|
|
|
21
21
|
return response;
|
|
22
22
|
};
|
|
23
|
+
|
|
24
|
+
export const get = async (
|
|
25
|
+
url: string,
|
|
26
|
+
apiKey: string,
|
|
27
|
+
signal?: AbortSignal
|
|
28
|
+
): Promise<Response> => {
|
|
29
|
+
const response = await fetch(url, {
|
|
30
|
+
method: "GET",
|
|
31
|
+
headers: {
|
|
32
|
+
"Api-Key": apiKey,
|
|
33
|
+
},
|
|
34
|
+
signal,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(response.statusText);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return response;
|
|
42
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TideClientConfig } from "../types";
|
|
2
|
+
import { get } from "./api";
|
|
3
|
+
|
|
4
|
+
const ENDPOINT = "/api/web/file";
|
|
5
|
+
const ENDPOINT_FEED = `${ENDPOINT}/feed`;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* api/web/file/feed
|
|
9
|
+
* fetch a xml from blob feed.
|
|
10
|
+
* @param config
|
|
11
|
+
* @param request
|
|
12
|
+
* @param signal
|
|
13
|
+
* @returns OK if succeeded.
|
|
14
|
+
*/
|
|
15
|
+
export const contactForm = (
|
|
16
|
+
config: TideClientConfig,
|
|
17
|
+
request: string,
|
|
18
|
+
signal?: AbortSignal
|
|
19
|
+
): Promise<Response> => {
|
|
20
|
+
const url = `${config.host}${ENDPOINT_FEED}/${request}`;
|
|
21
|
+
const apiKey = config.apiKey;
|
|
22
|
+
|
|
23
|
+
return get(url, apiKey, signal);
|
|
24
|
+
};
|