@foxtware/mineral 0.1.28 → 0.1.30
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/.creds.yml.sample +35 -2
- package/AGENTS.md +7 -0
- package/_build_scripts/createNewFunction.js +26 -3
- package/api/dpd/docs.md +6 -0
- package/api/dpd/dpd.constants.js +9 -0
- package/api/dpd/dpd.utils.js +145 -0
- package/api/dpd/dpdTrackingGet.js +64 -0
- package/api/dropbox/docs.md +7 -0
- package/api/dropbox/dropbox.constants.js +10 -0
- package/api/dropbox/dropbox.utils.js +67 -0
- package/api/dropbox/dropboxAccountGet.js +64 -0
- package/api/dropbox/dropboxFileCopy.js +67 -0
- package/api/dropbox/dropboxFileDelete.js +89 -0
- package/api/dropbox/dropboxFileDownload.js +139 -0
- package/api/dropbox/dropboxFileMetadataGet.js +100 -0
- package/api/dropbox/dropboxFileMove.js +67 -0
- package/api/dropbox/dropboxFileUpload.js +129 -0
- package/api/dropbox/dropboxFolderCreate.js +68 -0
- package/api/dropbox/dropboxFolderList.js +66 -0
- package/api/dropbox/dropboxGet.js +158 -0
- package/api/dropbox/dropboxSearch.js +161 -0
- package/api/dropbox/dropboxSharedLinkCreate.js +68 -0
- package/api/dropbox/dropboxSpaceUsageGet.js +55 -0
- package/api/dropbox/dropboxTemporaryLinkGet.js +75 -0
- package/api/fedex/docs.md +6 -0
- package/api/fedex/fedex.constants.js +11 -0
- package/api/fedex/fedex.utils.js +151 -0
- package/api/fedex/fedexTrackingGet.js +76 -0
- package/api/google/docs.md +1 -0
- package/api/google/google.constants.js +1 -0
- package/api/google/google.utils.js +21 -0
- package/api/google/googleanalyticsMetadataGet.js +62 -0
- package/api/google/googleanalyticsRealtimeReportRun.js +103 -0
- package/api/google/googleanalyticsReportRun.js +114 -0
- package/api/paypal/docs.md +14 -0
- package/api/paypal/paypal.constants.js +13 -0
- package/api/paypal/paypal.utils.js +166 -0
- package/api/paypal/paypalAccessTokenGet.js +81 -0
- package/api/paypal/paypalAuthorizationCapture.js +75 -0
- package/api/paypal/paypalAuthorizationGet.js +57 -0
- package/api/paypal/paypalBalancesGet.js +65 -0
- package/api/paypal/paypalCaptureGet.js +57 -0
- package/api/paypal/paypalCaptureRefund.js +78 -0
- package/api/paypal/paypalOrderAuthorize.js +69 -0
- package/api/paypal/paypalOrderCapture.js +69 -0
- package/api/paypal/paypalOrderCreate.js +81 -0
- package/api/paypal/paypalOrderGet.js +57 -0
- package/api/paypal/paypalRefundGet.js +57 -0
- package/api/paypal/paypalTransactionsGet.js +101 -0
- package/api/paypal/paypalUserInfoGet.js +62 -0
- package/api/royalmail/docs.md +6 -0
- package/api/royalmail/royalmail.constants.js +7 -0
- package/api/royalmail/royalmail.utils.js +55 -0
- package/api/royalmail/royalmailTrackingGet.js +70 -0
- package/api/shopify/shopify.utils.js +65 -4
- package/api/shopify/shopifyMetaobjectCreate.js +13 -6
- package/api/shopify/shopifyMetaobjectDelete.js +90 -0
- package/api/shopify/shopifyMetaobjectGet.js +80 -0
- package/api/shopify/shopifyMetaobjectUpdate.js +108 -0
- package/api/shopify/shopifyStorefrontSearch.js +158 -0
- package/api/spotify/docs.md +8 -0
- package/api/spotify/spotify.constants.js +12 -0
- package/api/spotify/spotify.utils.js +106 -0
- package/api/spotify/spotifyAlbumGet.js +76 -0
- package/api/spotify/spotifyAlbumTracksGet.js +49 -0
- package/api/spotify/spotifyArtistAlbumsGet.js +55 -0
- package/api/spotify/spotifyArtistGet.js +71 -0
- package/api/spotify/spotifyArtistTopTracksGet.js +56 -0
- package/api/spotify/spotifyGet.js +171 -0
- package/api/spotify/spotifyMeGet.js +48 -0
- package/api/spotify/spotifyPlayerCurrentlyPlayingGet.js +62 -0
- package/api/spotify/spotifyPlayerDevicesGet.js +51 -0
- package/api/spotify/spotifyPlayerGet.js +63 -0
- package/api/spotify/spotifyPlayerNext.js +55 -0
- package/api/spotify/spotifyPlayerPause.js +55 -0
- package/api/spotify/spotifyPlayerPlay.js +70 -0
- package/api/spotify/spotifyPlayerPrevious.js +55 -0
- package/api/spotify/spotifyPlaylistCreate.js +63 -0
- package/api/spotify/spotifyPlaylistGet.js +91 -0
- package/api/spotify/spotifyPlaylistItemsAdd.js +61 -0
- package/api/spotify/spotifyPlaylistItemsGet.js +58 -0
- package/api/spotify/spotifyPlaylistItemsRemove.js +67 -0
- package/api/spotify/spotifyPlaylistUpdate.js +64 -0
- package/api/spotify/spotifyPlaylistsGet.js +47 -0
- package/api/spotify/spotifySavedTracksGet.js +46 -0
- package/api/spotify/spotifySavedTracksRemove.js +59 -0
- package/api/spotify/spotifySavedTracksSave.js +59 -0
- package/api/spotify/spotifySearch.js +174 -0
- package/api/spotify/spotifyTrackGet.js +76 -0
- package/api/starshipit/starshipitProductUpdate.js +102 -0
- package/api/starshipit/starshipitProductsGet.js +2 -2
- package/api/stylearcade/stylearcadeGet.js +5 -2
- package/api/utils.js +39 -0
- package/package.json +1 -1
- package/server.js +3 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/get-playlist
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, actionSingleOrMultiple, logDeep } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['playlistId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const spotifyPlaylistGetSingle = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
playlistId,
|
|
15
|
+
{
|
|
16
|
+
market,
|
|
17
|
+
fields,
|
|
18
|
+
additionalTypes,
|
|
19
|
+
fetchClient = spotifyClient,
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
const response = await fetchClient.fetch({
|
|
23
|
+
context: { credsPayload },
|
|
24
|
+
requestPayload: {
|
|
25
|
+
method: 'get',
|
|
26
|
+
url: `/playlists/${ playlistId }`,
|
|
27
|
+
params: {
|
|
28
|
+
...(market !== undefined && { market }),
|
|
29
|
+
...(fields !== undefined && { fields }),
|
|
30
|
+
...(additionalTypes !== undefined && {
|
|
31
|
+
additional_types: Array.isArray(additionalTypes)
|
|
32
|
+
? additionalTypes.join(',')
|
|
33
|
+
: additionalTypes,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const { ok, data, error } = response;
|
|
40
|
+
if (!ok) {
|
|
41
|
+
logDeep({ error });
|
|
42
|
+
return { ok: false, error };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return { ok: true, data };
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const spotifyPlaylistGet = async (
|
|
49
|
+
credsPayload,
|
|
50
|
+
playlistId,
|
|
51
|
+
{
|
|
52
|
+
market,
|
|
53
|
+
fields,
|
|
54
|
+
additionalTypes,
|
|
55
|
+
queueRunOptions,
|
|
56
|
+
fetchClient,
|
|
57
|
+
} = {},
|
|
58
|
+
) => {
|
|
59
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
60
|
+
credsPayload,
|
|
61
|
+
playlistId,
|
|
62
|
+
});
|
|
63
|
+
if (rejectResponse) {
|
|
64
|
+
return rejectResponse;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return actionSingleOrMultiple(
|
|
68
|
+
playlistId,
|
|
69
|
+
spotifyPlaylistGetSingle,
|
|
70
|
+
(playlistIdItem) => ({
|
|
71
|
+
args: [credsPayload, playlistIdItem, {
|
|
72
|
+
market,
|
|
73
|
+
fields,
|
|
74
|
+
additionalTypes,
|
|
75
|
+
fetchClient,
|
|
76
|
+
}],
|
|
77
|
+
}),
|
|
78
|
+
{
|
|
79
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const funcApiConfig = {
|
|
85
|
+
argsWarden,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
spotifyPlaylistGet,
|
|
90
|
+
funcApiConfig,
|
|
91
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/add-items-to-playlist
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, logDeep } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['playlistId'],
|
|
10
|
+
['uris'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const spotifyPlaylistItemsAdd = async (
|
|
14
|
+
credsPayload,
|
|
15
|
+
playlistId,
|
|
16
|
+
uris,
|
|
17
|
+
{
|
|
18
|
+
position,
|
|
19
|
+
fetchClient = spotifyClient,
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
23
|
+
credsPayload,
|
|
24
|
+
playlistId,
|
|
25
|
+
uris,
|
|
26
|
+
});
|
|
27
|
+
if (rejectResponse) {
|
|
28
|
+
return rejectResponse;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const uriList = Array.isArray(uris) ? uris : [uris];
|
|
32
|
+
|
|
33
|
+
const response = await fetchClient.fetch({
|
|
34
|
+
context: { credsPayload },
|
|
35
|
+
requestPayload: {
|
|
36
|
+
method: 'post',
|
|
37
|
+
url: `/playlists/${ playlistId }/items`,
|
|
38
|
+
body: {
|
|
39
|
+
uris: uriList,
|
|
40
|
+
...(position !== undefined && { position }),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const { ok, data, error } = response;
|
|
46
|
+
if (!ok) {
|
|
47
|
+
logDeep({ error });
|
|
48
|
+
return { ok: false, error };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return { ok: true, data };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const funcApiConfig = {
|
|
55
|
+
argsWarden,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
spotifyPlaylistItemsAdd,
|
|
60
|
+
funcApiConfig,
|
|
61
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/get-playlists-items
|
|
2
|
+
// (formerly /tracks; renamed to /items)
|
|
3
|
+
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { credsValidator } = require('../validators');
|
|
6
|
+
const { spotifyGet } = require('../spotify/spotifyGet');
|
|
7
|
+
const { MAX_PER_PAGE } = require('../spotify/spotify.constants');
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
['playlistId'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const spotifyPlaylistItemsGet = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
playlistId,
|
|
17
|
+
{
|
|
18
|
+
market,
|
|
19
|
+
fields,
|
|
20
|
+
additionalTypes,
|
|
21
|
+
perPage = MAX_PER_PAGE,
|
|
22
|
+
fetchClient,
|
|
23
|
+
...getterOptions
|
|
24
|
+
} = {},
|
|
25
|
+
) => {
|
|
26
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
27
|
+
credsPayload,
|
|
28
|
+
playlistId,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return spotifyGet(credsPayload, `/playlists/${ playlistId }/items`, {
|
|
35
|
+
params: {
|
|
36
|
+
...(market !== undefined && { market }),
|
|
37
|
+
...(fields !== undefined && { fields }),
|
|
38
|
+
...(additionalTypes !== undefined && {
|
|
39
|
+
additional_types: Array.isArray(additionalTypes)
|
|
40
|
+
? additionalTypes.join(',')
|
|
41
|
+
: additionalTypes,
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
perPage,
|
|
45
|
+
resultsKey: 'items',
|
|
46
|
+
fetchClient,
|
|
47
|
+
...getterOptions,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const funcApiConfig = {
|
|
52
|
+
argsWarden,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
spotifyPlaylistItemsGet,
|
|
57
|
+
funcApiConfig,
|
|
58
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/remove-playlist-items
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, logDeep } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['playlistId'],
|
|
10
|
+
['tracks'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
// tracks: array of { uri, positions? } or array of uri strings
|
|
14
|
+
const spotifyPlaylistItemsRemove = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
playlistId,
|
|
17
|
+
tracks,
|
|
18
|
+
{
|
|
19
|
+
snapshotId,
|
|
20
|
+
fetchClient = spotifyClient,
|
|
21
|
+
} = {},
|
|
22
|
+
) => {
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
24
|
+
credsPayload,
|
|
25
|
+
playlistId,
|
|
26
|
+
tracks,
|
|
27
|
+
});
|
|
28
|
+
if (rejectResponse) {
|
|
29
|
+
return rejectResponse;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const trackList = (Array.isArray(tracks) ? tracks : [tracks]).map((entry) => {
|
|
33
|
+
if (typeof entry === 'string') {
|
|
34
|
+
return { uri: entry };
|
|
35
|
+
}
|
|
36
|
+
return entry;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const response = await fetchClient.fetch({
|
|
40
|
+
context: { credsPayload },
|
|
41
|
+
requestPayload: {
|
|
42
|
+
method: 'delete',
|
|
43
|
+
url: `/playlists/${ playlistId }/items`,
|
|
44
|
+
body: {
|
|
45
|
+
tracks: trackList,
|
|
46
|
+
...(snapshotId !== undefined && { snapshot_id: snapshotId }),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const { ok, data, error } = response;
|
|
52
|
+
if (!ok) {
|
|
53
|
+
logDeep({ error });
|
|
54
|
+
return { ok: false, error };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { ok: true, data };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const funcApiConfig = {
|
|
61
|
+
argsWarden,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
spotifyPlaylistItemsRemove,
|
|
66
|
+
funcApiConfig,
|
|
67
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/change-playlist-details
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, logDeep } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['playlistId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const spotifyPlaylistUpdate = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
playlistId,
|
|
15
|
+
{
|
|
16
|
+
name,
|
|
17
|
+
public: isPublic,
|
|
18
|
+
collaborative,
|
|
19
|
+
description,
|
|
20
|
+
fetchClient = spotifyClient,
|
|
21
|
+
} = {},
|
|
22
|
+
) => {
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
24
|
+
credsPayload,
|
|
25
|
+
playlistId,
|
|
26
|
+
});
|
|
27
|
+
if (rejectResponse) {
|
|
28
|
+
return rejectResponse;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const response = await fetchClient.fetch({
|
|
32
|
+
context: { credsPayload },
|
|
33
|
+
requestPayload: {
|
|
34
|
+
method: 'put',
|
|
35
|
+
url: `/playlists/${ playlistId }`,
|
|
36
|
+
body: {
|
|
37
|
+
...(name !== undefined && { name }),
|
|
38
|
+
...(isPublic !== undefined && { public: isPublic }),
|
|
39
|
+
...(collaborative !== undefined && { collaborative }),
|
|
40
|
+
...(description !== undefined && { description }),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const { ok, data, error } = response;
|
|
46
|
+
if (!ok) {
|
|
47
|
+
logDeep({ error });
|
|
48
|
+
return { ok: false, error };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
ok: true,
|
|
53
|
+
data: data ?? null,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const funcApiConfig = {
|
|
58
|
+
argsWarden,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
spotifyPlaylistUpdate,
|
|
63
|
+
funcApiConfig,
|
|
64
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/get-a-list-of-current-users-playlists
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyGet } = require('../spotify/spotifyGet');
|
|
6
|
+
const { MAX_PER_PAGE } = require('../spotify/spotify.constants');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const spotifyPlaylistsGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
userId,
|
|
16
|
+
perPage = MAX_PER_PAGE,
|
|
17
|
+
fetchClient,
|
|
18
|
+
...getterOptions
|
|
19
|
+
} = {},
|
|
20
|
+
) => {
|
|
21
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
22
|
+
credsPayload,
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const url = userId
|
|
29
|
+
? `/users/${ userId }/playlists`
|
|
30
|
+
: '/me/playlists';
|
|
31
|
+
|
|
32
|
+
return spotifyGet(credsPayload, url, {
|
|
33
|
+
perPage,
|
|
34
|
+
resultsKey: 'items',
|
|
35
|
+
fetchClient,
|
|
36
|
+
...getterOptions,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const funcApiConfig = {
|
|
41
|
+
argsWarden,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
spotifyPlaylistsGet,
|
|
46
|
+
funcApiConfig,
|
|
47
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/get-users-saved-tracks
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyGet } = require('../spotify/spotifyGet');
|
|
6
|
+
const { MAX_PER_PAGE } = require('../spotify/spotify.constants');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const spotifySavedTracksGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
market,
|
|
16
|
+
perPage = MAX_PER_PAGE,
|
|
17
|
+
fetchClient,
|
|
18
|
+
...getterOptions
|
|
19
|
+
} = {},
|
|
20
|
+
) => {
|
|
21
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
22
|
+
credsPayload,
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return spotifyGet(credsPayload, '/me/tracks', {
|
|
29
|
+
params: {
|
|
30
|
+
...(market !== undefined && { market }),
|
|
31
|
+
},
|
|
32
|
+
perPage,
|
|
33
|
+
resultsKey: 'items',
|
|
34
|
+
fetchClient,
|
|
35
|
+
...getterOptions,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const funcApiConfig = {
|
|
40
|
+
argsWarden,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
spotifySavedTracksGet,
|
|
45
|
+
funcApiConfig,
|
|
46
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/remove-tracks-user
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, logDeep } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['ids'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const spotifySavedTracksRemove = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
ids,
|
|
15
|
+
{
|
|
16
|
+
fetchClient = spotifyClient,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
20
|
+
credsPayload,
|
|
21
|
+
ids,
|
|
22
|
+
});
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const idList = Array.isArray(ids) ? ids : [ids];
|
|
28
|
+
|
|
29
|
+
const response = await fetchClient.fetch({
|
|
30
|
+
context: { credsPayload },
|
|
31
|
+
requestPayload: {
|
|
32
|
+
method: 'delete',
|
|
33
|
+
url: '/me/tracks',
|
|
34
|
+
params: {
|
|
35
|
+
ids: idList.join(','),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const { ok, data, error } = response;
|
|
41
|
+
if (!ok) {
|
|
42
|
+
logDeep({ error });
|
|
43
|
+
return { ok: false, error };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
ok: true,
|
|
48
|
+
data: data ?? null,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const funcApiConfig = {
|
|
53
|
+
argsWarden,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
spotifySavedTracksRemove,
|
|
58
|
+
funcApiConfig,
|
|
59
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/save-tracks-user
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, logDeep } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['ids'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const spotifySavedTracksSave = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
ids,
|
|
15
|
+
{
|
|
16
|
+
fetchClient = spotifyClient,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
20
|
+
credsPayload,
|
|
21
|
+
ids,
|
|
22
|
+
});
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const idList = Array.isArray(ids) ? ids : [ids];
|
|
28
|
+
|
|
29
|
+
const response = await fetchClient.fetch({
|
|
30
|
+
context: { credsPayload },
|
|
31
|
+
requestPayload: {
|
|
32
|
+
method: 'put',
|
|
33
|
+
url: '/me/tracks',
|
|
34
|
+
params: {
|
|
35
|
+
ids: idList.join(','),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const { ok, data, error } = response;
|
|
41
|
+
if (!ok) {
|
|
42
|
+
logDeep({ error });
|
|
43
|
+
return { ok: false, error };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
ok: true,
|
|
48
|
+
data: data ?? null,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const funcApiConfig = {
|
|
53
|
+
argsWarden,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
spotifySavedTracksSave,
|
|
58
|
+
funcApiConfig,
|
|
59
|
+
};
|