@qite/tide-client 1.0.46 → 1.0.49
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 +60 -0
- package/build/index.js.map +1 -1
- package/build/types/offer/affiliates.d.ts +5 -0
- package/build/utils/api.d.ts +5 -0
- package/build/utils/common-client.d.ts +6 -0
- package/build/utils/web-client.d.ts +12 -0
- package/build/utils/web-file.d.ts +14 -0
- package/package.json +1 -1
- package/src/types/offer/affiliates.ts +5 -0
- package/src/utils/api.ts +20 -0
- package/src/utils/common-client.ts +16 -1
- package/src/utils/web-client.ts +20 -0
- package/src/utils/web-file.ts +24 -0
package/build/utils/api.d.ts
CHANGED
|
@@ -5,3 +5,9 @@ export declare const post: <T>(
|
|
|
5
5
|
signal?: AbortSignal | undefined,
|
|
6
6
|
skipReviver?: boolean | undefined
|
|
7
7
|
) => Promise<T>;
|
|
8
|
+
export declare const get: <T>(
|
|
9
|
+
url: string,
|
|
10
|
+
apiKey: string,
|
|
11
|
+
signal?: AbortSignal | undefined,
|
|
12
|
+
skipReviver?: boolean | undefined
|
|
13
|
+
) => Promise<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CrmContactRequest, TideClientConfig } from "../types";
|
|
2
|
+
import { Affiliates } from "../types/offer/affiliates";
|
|
2
3
|
/**
|
|
3
4
|
* api/web/crmcontact
|
|
4
5
|
* Creates a CRM contact.
|
|
@@ -12,3 +13,14 @@ export declare const createCrmContact: (
|
|
|
12
13
|
request: CrmContactRequest,
|
|
13
14
|
signal?: AbortSignal | undefined
|
|
14
15
|
) => Promise<Response>;
|
|
16
|
+
/**
|
|
17
|
+
* api/web/affiliates
|
|
18
|
+
* Gets all Affiliates
|
|
19
|
+
* @param config
|
|
20
|
+
* @param signal
|
|
21
|
+
* @returns OK if succeeded.
|
|
22
|
+
*/
|
|
23
|
+
export declare const getAffiliates: (
|
|
24
|
+
config: TideClientConfig,
|
|
25
|
+
signal?: AbortSignal | undefined
|
|
26
|
+
) => Promise<[Affiliates]>;
|
|
@@ -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 feedXml: (
|
|
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
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { post as apiPost } from "./api";
|
|
1
|
+
import { post as apiPost, get as apiGet } from "./api";
|
|
2
2
|
import { reviver } from "./json";
|
|
3
3
|
|
|
4
4
|
export const post = async <T>(
|
|
@@ -16,3 +16,18 @@ export const post = async <T>(
|
|
|
16
16
|
: JSON.parse(responseBody, reviver);
|
|
17
17
|
return result;
|
|
18
18
|
};
|
|
19
|
+
|
|
20
|
+
export const get = async <T>(
|
|
21
|
+
url: string,
|
|
22
|
+
apiKey: string,
|
|
23
|
+
signal?: AbortSignal,
|
|
24
|
+
skipReviver?: boolean
|
|
25
|
+
): Promise<T> => {
|
|
26
|
+
const response = await apiGet(url, apiKey, signal);
|
|
27
|
+
const responseBody = await response.text();
|
|
28
|
+
|
|
29
|
+
const result: T = skipReviver
|
|
30
|
+
? JSON.parse(responseBody)
|
|
31
|
+
: JSON.parse(responseBody, reviver);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
package/src/utils/web-client.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { CrmContactRequest, TideClientConfig } from "../types";
|
|
2
|
+
import { Affiliates } from "../types/offer/affiliates";
|
|
2
3
|
|
|
3
4
|
import { post } from "./api";
|
|
5
|
+
import { get } from "./common-client";
|
|
4
6
|
|
|
5
7
|
const ENDPOINT = "/api/web";
|
|
6
8
|
const ENDPOINT_CREATE_CRM_CONTACT = `${ENDPOINT}/crmcontact`;
|
|
9
|
+
const ENDPOINT_CREATE_AFFILIATES = `${ENDPOINT}/affiliates`;
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* api/web/crmcontact
|
|
@@ -24,3 +27,20 @@ export const createCrmContact = (
|
|
|
24
27
|
|
|
25
28
|
return post(url, apiKey, body, signal);
|
|
26
29
|
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* api/web/affiliates
|
|
33
|
+
* Gets all Affiliates
|
|
34
|
+
* @param config
|
|
35
|
+
* @param signal
|
|
36
|
+
* @returns OK if succeeded.
|
|
37
|
+
*/
|
|
38
|
+
export const getAffiliates = (
|
|
39
|
+
config: TideClientConfig,
|
|
40
|
+
signal?: AbortSignal
|
|
41
|
+
): Promise<[Affiliates]> => {
|
|
42
|
+
const url = `${config.host}${ENDPOINT_CREATE_AFFILIATES}`;
|
|
43
|
+
const apiKey = config.apiKey;
|
|
44
|
+
|
|
45
|
+
return get(url, apiKey, signal);
|
|
46
|
+
};
|
|
@@ -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 feedXml = (
|
|
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
|
+
};
|