podcast-api 2.0.4 → 3.0.0
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 +481 -12699
- package/package.json +11 -12
- package/src/PodcastApiClientForNode.js +13 -12
- package/src/PodcastApiClientForWorkers.js +27 -71
- package/src/PodcastApiMethods.js +94 -80
- package/src/Request.js +24 -0
- package/src/api-contract.json +911 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podcast-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "JavaScript bindings for the Listen Notes Podcast API",
|
|
5
5
|
"main": "src/PodcastApiClient.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"clean": "rm -rf ./.nyc_output ./node_modules/.cache",
|
|
8
|
-
"lint": "eslint
|
|
8
|
+
"lint": "eslint .",
|
|
9
9
|
"test": "jest --config jest.config.node.json && jest --config jest.config.minifare.json",
|
|
10
10
|
"test-node": "jest --config jest.config.node.json",
|
|
11
11
|
"test-workers": "jest --config jest.config.minifare.json"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"Node.js"
|
|
25
25
|
],
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=22"
|
|
28
28
|
},
|
|
29
29
|
"author": "Listen Notes, Inc. <hello@listennotes.com> (https://www.listennotes.com/)",
|
|
30
30
|
"license": "MIT",
|
|
@@ -33,15 +33,14 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://www.listennotes.com/api/",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"axios": "
|
|
36
|
+
"axios": "1.19.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"eslint": "
|
|
40
|
-
"eslint
|
|
41
|
-
"
|
|
42
|
-
"jest": "
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
39
|
+
"@eslint/js": "10.0.1",
|
|
40
|
+
"eslint": "10.10.0",
|
|
41
|
+
"jest": "30.5.1",
|
|
42
|
+
"jest-environment-miniflare": "2.14.3",
|
|
43
|
+
"prettier": "3.9.8"
|
|
44
|
+
},
|
|
45
|
+
"packageManager": "yarn@3.3.1"
|
|
47
46
|
}
|
|
@@ -3,24 +3,25 @@ const { addApiMethodsToClient } = require('./PodcastApiMethods');
|
|
|
3
3
|
|
|
4
4
|
const ClientForNode = (config = {}) => {
|
|
5
5
|
const axios = require('axios');
|
|
6
|
-
|
|
7
|
-
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
8
|
-
this.httpClient = axios.create({
|
|
6
|
+
const httpClient = axios.create({
|
|
9
7
|
baseURL: config.apiKey ? API_BASE_PROD : API_BASE_TEST,
|
|
10
8
|
timeout: 30000,
|
|
11
9
|
headers: {
|
|
12
10
|
'X-ListenAPI-Key': config.apiKey || '',
|
|
13
11
|
'User-Agent': config.userAgent || defaultUserAgent,
|
|
14
12
|
},
|
|
13
|
+
// Use the same standard encoding as the Workers transport.
|
|
14
|
+
paramsSerializer: (params) => new URLSearchParams(params).toString(),
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const formConfig = (params) => ({
|
|
17
|
+
params,
|
|
18
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
19
|
+
});
|
|
20
|
+
httpClient._get = (path, params) => httpClient.get(path, { params });
|
|
21
|
+
httpClient._post = (path, params, query) => httpClient.post(path, new URLSearchParams(params).toString(), formConfig(query));
|
|
22
|
+
httpClient._put = (path, params, query) => httpClient.put(path, new URLSearchParams(params).toString(), formConfig(query));
|
|
23
|
+
httpClient._delete = (path, params) => httpClient.delete(path, { params });
|
|
24
|
+
return addApiMethodsToClient({ httpClient });
|
|
22
25
|
};
|
|
23
26
|
|
|
24
|
-
module.exports = {
|
|
25
|
-
ClientForNode,
|
|
26
|
-
};
|
|
27
|
+
module.exports = { ClientForNode };
|
|
@@ -1,85 +1,41 @@
|
|
|
1
|
-
const {API_BASE_PROD, API_BASE_TEST, defaultUserAgent} = require('./Constants');
|
|
2
|
-
const {addApiMethodsToClient} = require('./PodcastApiMethods');
|
|
1
|
+
const { API_BASE_PROD, API_BASE_TEST, defaultUserAgent } = require('./Constants');
|
|
2
|
+
const { addApiMethodsToClient } = require('./PodcastApiMethods');
|
|
3
3
|
|
|
4
|
-
const _fetch = (path, config, method
|
|
4
|
+
const _fetch = async (path, config, method, queryParams = {}, formParams = null) => {
|
|
5
5
|
let url = `${config.apiKey ? API_BASE_PROD : API_BASE_TEST}${path}`;
|
|
6
6
|
const headers = {
|
|
7
7
|
'X-ListenAPI-Key': config.apiKey || '',
|
|
8
8
|
'User-Agent': config.userAgent || defaultUserAgent,
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
formParamsString = [...formParams.entries()].map(
|
|
18
|
-
x => `${encodeURIComponent(x[0])}=${encodeURIComponent(x[1])}`).join('&');
|
|
10
|
+
const query = new URLSearchParams(queryParams).toString();
|
|
11
|
+
if (query) url += `?${query}`;
|
|
12
|
+
const body = formParams === null ? null : new URLSearchParams(formParams).toString();
|
|
13
|
+
const fetchConfig = { method, headers };
|
|
14
|
+
if (body !== null) {
|
|
15
|
+
fetchConfig.body = body;
|
|
16
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const responseConfig = { params: queryParams, data: body, url: path, method: method.toLowerCase() };
|
|
19
|
+
const response = await fetch(url, fetchConfig);
|
|
20
|
+
const responseHeaders = Object.fromEntries(response.headers.entries());
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
const error = new Error(`HTTP ${response.status}`);
|
|
23
|
+
error.response = { status: response.status, config: responseConfig, headers: responseHeaders };
|
|
24
|
+
throw error;
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
params: queryParams,
|
|
25
|
-
data: formParamsString,
|
|
26
|
-
url: path,
|
|
27
|
-
method: method.toLowerCase(),
|
|
28
|
-
};
|
|
29
|
-
const responseHeaders = {};
|
|
30
|
-
return fetch(url, fetchConfig).then((response) => {
|
|
31
|
-
if (response.headers) {
|
|
32
|
-
for (const pair of response.headers.entries()) {
|
|
33
|
-
responseHeaders[pair[0]] = pair[1];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (response.ok) {
|
|
38
|
-
return response;
|
|
39
|
-
} else {
|
|
40
|
-
const err = new Error(`HTTP ${response.status}`);
|
|
41
|
-
err.response = {
|
|
42
|
-
status: response.status,
|
|
43
|
-
config: responseConfig,
|
|
44
|
-
headers: responseHeaders,
|
|
45
|
-
};
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
}).then((response) => {
|
|
49
|
-
return response.json();
|
|
50
|
-
}).then((data) => {
|
|
51
|
-
return {
|
|
52
|
-
config: responseConfig,
|
|
53
|
-
headers: responseHeaders,
|
|
54
|
-
data,
|
|
55
|
-
}
|
|
56
|
-
});
|
|
26
|
+
return { config: responseConfig, headers: responseHeaders, data: await response.json() };
|
|
57
27
|
};
|
|
58
28
|
|
|
59
29
|
const ClientForWorkers = (config = {}) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (params && Object.keys(params).length > 0) {
|
|
68
|
-
formData = new FormData();
|
|
69
|
-
Object.keys(params).forEach(function (key) {
|
|
70
|
-
formData.append(key, params[key]);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return _fetch(path, config, 'POST', {}, formData)
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
_delete: (path) => {
|
|
77
|
-
return _fetch(path, config, 'DELETE')
|
|
78
|
-
},
|
|
30
|
+
// Snapshot configuration so later clients or caller mutations cannot change it.
|
|
31
|
+
const settings = { ...config };
|
|
32
|
+
const httpClient = {
|
|
33
|
+
_get: (path, params) => _fetch(path, settings, 'GET', params),
|
|
34
|
+
_post: (path, params, query) => _fetch(path, settings, 'POST', query, params),
|
|
35
|
+
_put: (path, params, query) => _fetch(path, settings, 'PUT', query, params),
|
|
36
|
+
_delete: (path, params) => _fetch(path, settings, 'DELETE', params),
|
|
79
37
|
};
|
|
80
|
-
return addApiMethodsToClient(
|
|
38
|
+
return addApiMethodsToClient({ httpClient });
|
|
81
39
|
};
|
|
82
40
|
|
|
83
|
-
module.exports = {
|
|
84
|
-
ClientForWorkers,
|
|
85
|
-
};
|
|
41
|
+
module.exports = { ClientForWorkers };
|
package/src/PodcastApiMethods.js
CHANGED
|
@@ -1,84 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
client.searchEpisodeTitles = (params) => client.httpClient._get('/search_episode_titles', params);
|
|
5
|
-
|
|
6
|
-
client.typeahead = (params) => client.httpClient._get('/typeahead', params);
|
|
7
|
-
|
|
8
|
-
client.spellcheck = (params) => client.httpClient._get('/spellcheck', params);
|
|
9
|
-
|
|
10
|
-
client.fetchRelatedSearches = (params) => client.httpClient._get('/related_searches', params);
|
|
11
|
-
|
|
12
|
-
client.fetchTrendingSearches = (params) => client.httpClient._get('/trending_searches', params);
|
|
13
|
-
|
|
14
|
-
client.fetchBestPodcasts = (params) => client.httpClient._get('/best_podcasts', params);
|
|
15
|
-
|
|
16
|
-
client.fetchPodcastById = (params) => {
|
|
17
|
-
const { id, ...otherParams } = params;
|
|
18
|
-
return client.httpClient._get(`/podcasts/${id}`, otherParams);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
client.fetchEpisodeById = (params) => {
|
|
22
|
-
const { id, ...otherParams } = params;
|
|
23
|
-
return client.httpClient._get(`/episodes/${id}`, otherParams);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
client.batchFetchPodcasts = (params) => client.httpClient._post('/podcasts', params);
|
|
27
|
-
|
|
28
|
-
client.batchFetchEpisodes = (params) => client.httpClient._post('/episodes', params);
|
|
29
|
-
|
|
30
|
-
client.fetchCuratedPodcastsListById = (params) => {
|
|
31
|
-
const { id, ...otherParams } = params;
|
|
32
|
-
return client.httpClient._get(`/curated_podcasts/${id}`, otherParams);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
client.fetchCuratedPodcastsLists = (params) => client.httpClient._get('/curated_podcasts', params);
|
|
36
|
-
|
|
37
|
-
client.fetchPodcastGenres = (params) => client.httpClient._get('/genres', params);
|
|
38
|
-
|
|
39
|
-
client.fetchPodcastRegions = (params) => client.httpClient._get('/regions', params);
|
|
40
|
-
|
|
41
|
-
client.fetchPodcastLanguages = (params) => client.httpClient._get('/languages', params);
|
|
42
|
-
|
|
43
|
-
client.justListen = (params) => client.httpClient._get('/just_listen', params);
|
|
44
|
-
|
|
45
|
-
client.fetchRecommendationsForPodcast = (params) => {
|
|
46
|
-
const { id, ...otherParams } = params;
|
|
47
|
-
return client.httpClient._get(`/podcasts/${id}/recommendations`, otherParams);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
client.fetchRecommendationsForEpisode = (params) => {
|
|
51
|
-
const { id, ...otherParams } = params;
|
|
52
|
-
return client.httpClient._get(`/episodes/${id}/recommendations`, otherParams);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
client.fetchPlaylistById = (params) => {
|
|
56
|
-
const { id, ...otherParams } = params;
|
|
57
|
-
return client.httpClient._get(`/playlists/${id}`, otherParams);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
client.fetchMyPlaylists = (params) => client.httpClient._get('/playlists', params);
|
|
61
|
-
|
|
62
|
-
client.submitPodcast = (params) => client.httpClient._post('/podcasts/submit', params);
|
|
63
|
-
|
|
64
|
-
client.deletePodcast = (params) => {
|
|
65
|
-
const { id, reason } = params;
|
|
66
|
-
return client.httpClient._delete(`/podcasts/${id}?reason=${reason || ''}`);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
client.fetchAudienceForPodcast = (params) => {
|
|
70
|
-
const { id, ...otherParams } = params;
|
|
71
|
-
return client.httpClient._get(`/podcasts/${id}/audience`, otherParams);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
client.fetchPodcastsByDomain = (params) => {
|
|
75
|
-
const { domain_name, ...otherParams } = params;
|
|
76
|
-
return client.httpClient._get(`/podcasts/domains/${domain_name}`, otherParams);
|
|
77
|
-
};
|
|
1
|
+
// Generated by listennotes/devtools/api-sdks/sync.py javascript. Do not edit.
|
|
2
|
+
const { request } = require('./Request');
|
|
78
3
|
|
|
4
|
+
const addApiMethodsToClient = (client) => {
|
|
5
|
+
client.search = (params = {}) => request(
|
|
6
|
+
client.httpClient, "GET", "/search",
|
|
7
|
+
{"path": [], "query": ["q", "sort_by_date", "type", "offset", "len_min", "len_max", "episode_count_min", "episode_count_max", "update_freq_min", "update_freq_max", "genre_ids", "published_before", "published_after", "only_in", "language", "region", "ocid", "ncid", "safe_mode", "unique_podcasts", "interviews_only", "sponsored_only", "page_size"], "body": []}, params);
|
|
8
|
+
client.typeahead = (params = {}) => request(
|
|
9
|
+
client.httpClient, "GET", "/typeahead",
|
|
10
|
+
{"path": [], "query": ["q", "show_podcasts", "show_genres", "safe_mode"], "body": []}, params);
|
|
11
|
+
client.searchEpisodeTitles = (params = {}) => request(
|
|
12
|
+
client.httpClient, "GET", "/search_episode_titles",
|
|
13
|
+
{"path": [], "query": ["q", "podcast_id", "podcast_id_type"], "body": []}, params);
|
|
14
|
+
client.spellcheck = (params = {}) => request(
|
|
15
|
+
client.httpClient, "GET", "/spellcheck",
|
|
16
|
+
{"path": [], "query": ["q"], "body": []}, params);
|
|
17
|
+
client.fetchRelatedSearches = (params = {}) => request(
|
|
18
|
+
client.httpClient, "GET", "/related_searches",
|
|
19
|
+
{"path": [], "query": ["q"], "body": []}, params);
|
|
20
|
+
client.fetchTrendingSearches = (params = {}) => request(
|
|
21
|
+
client.httpClient, "GET", "/trending_searches",
|
|
22
|
+
{"path": [], "query": [], "body": []}, params);
|
|
23
|
+
client.fetchBestPodcasts = (params = {}) => request(
|
|
24
|
+
client.httpClient, "GET", "/best_podcasts",
|
|
25
|
+
{"path": [], "query": ["genre_id", "page", "region", "publisher_region", "language", "sort", "safe_mode"], "body": []}, params);
|
|
26
|
+
client.fetchPodcastById = (params = {}) => request(
|
|
27
|
+
client.httpClient, "GET", "/podcasts/{id}",
|
|
28
|
+
{"path": ["id"], "query": ["next_episode_pub_date", "sort"], "body": []}, params);
|
|
29
|
+
client.deletePodcast = (params = {}) => request(
|
|
30
|
+
client.httpClient, "DELETE", "/podcasts/{id}",
|
|
31
|
+
{"path": ["id"], "query": ["reason"], "body": []}, params);
|
|
32
|
+
client.fetchEpisodeById = (params = {}) => request(
|
|
33
|
+
client.httpClient, "GET", "/episodes/{id}",
|
|
34
|
+
{"path": ["id"], "query": ["show_transcript"], "body": []}, params);
|
|
35
|
+
client.batchFetchEpisodes = (params = {}) => request(
|
|
36
|
+
client.httpClient, "POST", "/episodes",
|
|
37
|
+
{"path": [], "query": [], "body": ["ids"]}, params);
|
|
38
|
+
client.batchFetchPodcasts = (params = {}) => request(
|
|
39
|
+
client.httpClient, "POST", "/podcasts",
|
|
40
|
+
{"path": [], "query": [], "body": ["ids", "rsses", "itunes_ids", "spotify_ids", "show_latest_episodes", "next_episode_pub_date"]}, params);
|
|
41
|
+
client.fetchCuratedPodcastsListById = (params = {}) => request(
|
|
42
|
+
client.httpClient, "GET", "/curated_podcasts/{id}",
|
|
43
|
+
{"path": ["id"], "query": [], "body": []}, params);
|
|
44
|
+
client.fetchPodcastGenres = (params = {}) => request(
|
|
45
|
+
client.httpClient, "GET", "/genres",
|
|
46
|
+
{"path": [], "query": ["top_level_only"], "body": []}, params);
|
|
47
|
+
client.fetchPodcastRegions = (params = {}) => request(
|
|
48
|
+
client.httpClient, "GET", "/regions",
|
|
49
|
+
{"path": [], "query": [], "body": []}, params);
|
|
50
|
+
client.fetchPodcastLanguages = (params = {}) => request(
|
|
51
|
+
client.httpClient, "GET", "/languages",
|
|
52
|
+
{"path": [], "query": [], "body": []}, params);
|
|
53
|
+
client.justListen = (params = {}) => request(
|
|
54
|
+
client.httpClient, "GET", "/just_listen",
|
|
55
|
+
{"path": [], "query": [], "body": []}, params);
|
|
56
|
+
client.fetchCuratedPodcastsLists = (params = {}) => request(
|
|
57
|
+
client.httpClient, "GET", "/curated_podcasts",
|
|
58
|
+
{"path": [], "query": ["page"], "body": []}, params);
|
|
59
|
+
client.fetchRecommendationsForPodcast = (params = {}) => request(
|
|
60
|
+
client.httpClient, "GET", "/podcasts/{id}/recommendations",
|
|
61
|
+
{"path": ["id"], "query": ["safe_mode"], "body": []}, params);
|
|
62
|
+
client.fetchRecommendationsForEpisode = (params = {}) => request(
|
|
63
|
+
client.httpClient, "GET", "/episodes/{id}/recommendations",
|
|
64
|
+
{"path": ["id"], "query": ["safe_mode"], "body": []}, params);
|
|
65
|
+
client.submitPodcast = (params = {}) => request(
|
|
66
|
+
client.httpClient, "POST", "/podcasts/submit",
|
|
67
|
+
{"path": [], "query": [], "body": ["rss", "email"]}, params);
|
|
68
|
+
client.fetchPlaylistById = (params = {}) => request(
|
|
69
|
+
client.httpClient, "GET", "/playlists/{id}",
|
|
70
|
+
{"path": ["id"], "query": ["type", "last_timestamp_ms", "sort"], "body": []}, params);
|
|
71
|
+
client.fetchMyPlaylists = (params = {}) => request(
|
|
72
|
+
client.httpClient, "GET", "/playlists",
|
|
73
|
+
{"path": [], "query": ["sort", "page"], "body": []}, params);
|
|
74
|
+
client.fetchAudienceForPodcast = (params = {}) => request(
|
|
75
|
+
client.httpClient, "GET", "/podcasts/{id}/audience",
|
|
76
|
+
{"path": ["id"], "query": [], "body": []}, params);
|
|
77
|
+
client.fetchPodcastsByDomain = (params = {}) => request(
|
|
78
|
+
client.httpClient, "GET", "/podcasts/domains/{domain_name}",
|
|
79
|
+
{"path": ["domain_name"], "query": ["page"], "body": []}, params);
|
|
80
|
+
client.createPlaylist = (params = {}) => request(
|
|
81
|
+
client.httpClient, "POST", "/playlists",
|
|
82
|
+
{"path": [], "query": [], "body": ["name", "description", "visibility", "type"]}, params);
|
|
83
|
+
client.updatePlaylist = (params = {}) => request(
|
|
84
|
+
client.httpClient, "PUT", "/playlists/{id}",
|
|
85
|
+
{"path": ["id"], "query": [], "body": ["name", "description", "visibility", "type"]}, params);
|
|
86
|
+
client.addPlaylistItem = (params = {}) => request(
|
|
87
|
+
client.httpClient, "POST", "/playlists/{id}/items",
|
|
88
|
+
{"path": ["id"], "query": [], "body": ["episode_id", "podcast_id", "notes"]}, params);
|
|
89
|
+
client.deletePlaylistItem = (params = {}) => request(
|
|
90
|
+
client.httpClient, "DELETE", "/playlists/{id}/items/{item_id}",
|
|
91
|
+
{"path": ["id", "item_id"], "query": [], "body": []}, params);
|
|
92
|
+
client.updatePlaylistItemNotes = (params = {}) => request(
|
|
93
|
+
client.httpClient, "PUT", "/playlists/{id}/items/{item_id}",
|
|
94
|
+
{"path": ["id", "item_id"], "query": [], "body": ["notes"]}, params);
|
|
79
95
|
return client;
|
|
80
96
|
};
|
|
81
97
|
|
|
82
|
-
module.exports = {
|
|
83
|
-
addApiMethodsToClient,
|
|
84
|
-
};
|
|
98
|
+
module.exports = { addApiMethodsToClient };
|
package/src/Request.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Shared transport dispatch. Endpoint locations come from the generated methods.
|
|
2
|
+
const request = (httpClient, method, template, locations, params) => {
|
|
3
|
+
const query = {};
|
|
4
|
+
const body = {};
|
|
5
|
+
const path = template.replace(/\{([^}]+)\}/g, (_, name) => {
|
|
6
|
+
if (params[name] === undefined || params[name] === null || params[name] === '') {
|
|
7
|
+
throw new Error(`Missing path parameter: ${name}`);
|
|
8
|
+
}
|
|
9
|
+
return encodeURIComponent(params[name]);
|
|
10
|
+
});
|
|
11
|
+
Object.keys(params).forEach((name) => {
|
|
12
|
+
const value = params[name];
|
|
13
|
+
if (locations.path.includes(name) || value === undefined || value === null) return;
|
|
14
|
+
// Unknown fields retain the historical query/body behavior for forward compatibility.
|
|
15
|
+
const target = locations.query.includes(name) || method === 'GET' || method === 'DELETE' ? query : body;
|
|
16
|
+
target[name] = value;
|
|
17
|
+
});
|
|
18
|
+
if (method === 'POST' || method === 'PUT') {
|
|
19
|
+
return httpClient[`_${method.toLowerCase()}`](path, body, query);
|
|
20
|
+
}
|
|
21
|
+
return httpClient[`_${method.toLowerCase()}`](path, query);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports = { request };
|