feat: implement create playlist action for spotify
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create playlist',
|
||||
key: 'cratePlaylist',
|
||||
description: `Create playlist on user's account.`,
|
||||
arguments: [
|
||||
{
|
||||
label: 'Playlist name',
|
||||
key: 'playlistName',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Playlist name',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Playlist visibility',
|
||||
key: 'playlistVisibility',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: 'Playlist visibility',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'public', value: 'Public' },
|
||||
{ label: 'private', value: 'Private' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Playlist description',
|
||||
key: 'playlistDescription',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Playlist description',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const playlistName = $.step.parameters.playlistName as string;
|
||||
const playlistDescription = $.step.parameters.playlistDescription as string;
|
||||
const playlistVisibility =
|
||||
$.step.parameters.playlistVisibility === 'public'
|
||||
? true
|
||||
: (false as boolean);
|
||||
|
||||
const response = await $.http.post(
|
||||
`v1/users/${$.auth.data.userId}/playlists`,
|
||||
{
|
||||
name: playlistName,
|
||||
public: playlistVisibility,
|
||||
description: playlistDescription,
|
||||
}
|
||||
);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
3
packages/backend/src/apps/spotify/actions/index.ts
Normal file
3
packages/backend/src/apps/spotify/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import cratePlaylist from './create-playlist';
|
||||
|
||||
export default [cratePlaylist];
|
0
packages/backend/src/apps/spotify/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/spotify/index.d.ts
vendored
Normal file
@@ -1,5 +1,6 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import actions from './actions';
|
||||
import auth from './auth';
|
||||
|
||||
export default defineApp({
|
||||
@@ -13,4 +14,5 @@ export default defineApp({
|
||||
primaryColor: '000000',
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
actions,
|
||||
});
|
||||
|
Reference in New Issue
Block a user