@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.
@@ -4,3 +4,8 @@ export declare const post: (
4
4
  body: string,
5
5
  signal?: AbortSignal | undefined
6
6
  ) => Promise<Response>;
7
+ export declare const get: (
8
+ url: string,
9
+ apiKey: string,
10
+ signal?: AbortSignal | undefined
11
+ ) => Promise<Response>;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qite/tide-client",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "Frontend client for Tide",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
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
+ };