Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/four-peas-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@audius/sdk': major
---

Remove getPlaylistByHandleAndSlug in favor of getBulkPlaylists

- Removes `sdk.playlists.getPlaylistByHandleAndSlug()` in favor of calling `sdk.playlists.getBulkPlaylists({ permalink: ['/handle/playlist/playlist-name-slug'] })`
- Changes return values of `CommentsAPI` to match other APIs, removing `success` param.
6 changes: 0 additions & 6 deletions docs/docs/developers/api/sidebar.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,6 @@ const sidebar = {
label: "Create Playlist",
className: "api-method post",
},
{
type: "doc",
id: "developers/api/get-playlist-by-handle-and-slug",
label: "Get Playlist By Handle and Slug",
className: "api-method get",
},
{
type: "doc",
id: "developers/api/search-playlists",
Expand Down
6 changes: 0 additions & 6 deletions docs/docs/developers/api/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,6 @@ const sidebar: SidebarsConfig = {
label: "Create Playlist",
className: "api-method post",
},
{
type: "doc",
id: "developers/api/get-playlist-by-handle-and-slug",
label: "Get Playlist By Handle and Slug",
className: "api-method get",
},
{
type: "doc",
id: "developers/api/search-playlists",
Expand Down
99 changes: 52 additions & 47 deletions docs/docs/developers/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ paths:
get:
tags:
- playlists
description: Gets a list of playlists by ID
description: Gets a list of playlists by ID, UPC, or permalink
operationId: Get Bulk Playlists
parameters:
- name: user_id
Expand All @@ -1101,6 +1101,15 @@ paths:
type: array
items:
type: string
- name: permalink
in: query
description: The permalink(s) of the playlist(s)
style: form
explode: true
schema:
type: array
items:
type: string
- name: upc
in: query
description: The UPC of the playlist(s)
Expand Down Expand Up @@ -1161,37 +1170,6 @@ paths:
'500':
description: Server error
content: {}
/playlists/by_permalink/{handle}/{slug}:
get:
tags:
- playlists
description: Get a playlist by handle and slug
operationId: Get Playlist By Handle and Slug
parameters:
- name: handle
in: path
description: playlist owner handle
required: true
schema:
type: string
- name: slug
in: path
description: playlist slug
required: true
schema:
type: string
- name: user_id
in: query
description: The user ID of the user making the request
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/playlist_response'
/playlists/search:
get:
tags:
Expand Down Expand Up @@ -10415,12 +10393,16 @@ components:
create_user_response:
type: object
properties:
success:
type: boolean
description: Whether the user was created successfully
transaction_hash:
type: string
description: The blockchain transaction hash
block_hash:
type: string
description: The blockchain block hash
block_number:
type: integer
format: int64
description: The blockchain block number/height
user_id:
type: string
description: The ID of the created user
Expand Down Expand Up @@ -10595,12 +10577,16 @@ components:
create_comment_response:
type: object
properties:
success:
type: boolean
description: Whether the comment was created successfully
transaction_hash:
type: string
description: The blockchain transaction hash
block_hash:
type: string
description: The blockchain block hash
block_number:
type: integer
format: int64
description: The blockchain block number/height
comment_id:
type: string
description: The ID of the created comment
Expand Down Expand Up @@ -10644,12 +10630,16 @@ components:
write_response:
type: object
properties:
success:
type: boolean
description: Whether the operation was successful
transaction_hash:
type: string
description: The blockchain transaction hash
block_hash:
type: string
description: The blockchain block hash
block_number:
type: integer
format: int64
description: The blockchain block number/height
playlist_artwork:
type: object
properties:
Expand Down Expand Up @@ -11116,6 +11106,13 @@ components:
transaction_hash:
type: string
description: Transaction hash of the creation
block_hash:
type: string
description: The blockchain block hash
block_number:
type: integer
format: int64
description: The blockchain block number/height
playlist_response:
required:
- latest_chain_block
Expand Down Expand Up @@ -12203,12 +12200,16 @@ components:
create_playlist_response:
type: object
properties:
success:
type: boolean
description: Whether the playlist was created successfully
transaction_hash:
type: string
description: The blockchain transaction hash
block_hash:
type: string
description: The blockchain block hash
block_number:
type: integer
format: int64
description: The blockchain block number/height
playlist_id:
type: string
description: The ID of the created playlist
Expand Down Expand Up @@ -13074,12 +13075,16 @@ components:
create_track_response:
type: object
properties:
success:
type: boolean
description: Whether the track was created successfully
transaction_hash:
type: string
description: The blockchain transaction hash
block_hash:
type: string
description: The blockchain block hash
block_number:
type: integer
format: int64
description: The blockchain block number/height
track_id:
type: string
description: The ID of the created track
Expand Down
13 changes: 7 additions & 6 deletions docs/docs/developers/sdk/playlists.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Returns a `Promise` containing an object with a `data` field. `data` contains a

> #### getBulkPlaylists(`params`)

Get a list of playlists by id.
Get a list of playlists by ID, UPC, or permalink.

Example:

Expand All @@ -61,11 +61,12 @@ console.log(playlists)
Create an object with the following fields and pass it as the first argument, as shown in the
example above.

| Name | Type | Description | Required? |
| :------- | :--------- | :------------------------------------ | :--------- |
| `id` | `string[]` | An array of playlist IDs | _Optional_ |
| `upc` | `string[]` | An array of UPC codes | _Optional_ |
| `userId` | `string` | The ID of the user making the request | _Optional_ |
| Name | Type | Description | Required? |
| :---------- | :--------- | :------------------------------------ | :--------- |
| `id` | `string[]` | An array of playlist IDs | _Optional_ |
| `permalink` | `string[]` | An array of permalinks of playlists | _Optional_ |
| `upc` | `string[]` | An array of UPC codes | _Optional_ |
| `userId` | `string` | The ID of the user making the request | _Optional_ |

#### Returns

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,14 @@ export const getCollectionByPermalinkQueryKey = (
] as unknown as QueryKey<ID>
}

export const playlistPermalinkToHandleAndSlug = (permalink: string) => {
const splitPermalink = permalink.split('/')
if (splitPermalink.length !== 4) {
throw Error(
'Permalink formatted incorrectly. Should follow /<handle>/playlist/<slug> format.'
)
}
const handle = splitPermalink[1]
const slug = splitPermalink[3]
return { handle, slug }
}

export const getCollectionByPermalinkQueryFn = async (
permalink: string,
currentUserId: number | null | undefined,
queryClient: QueryClient,
sdk: any
) => {
const { handle, slug } = playlistPermalinkToHandleAndSlug(permalink)
const { data = [] } = await sdk.playlists.getPlaylistByHandleAndSlug({
handle,
slug,
const { data = [] } = await sdk.playlists.getBulkPlaylists({
permalink: [permalink],
userId: OptionalId.parse(currentUserId)
})

Expand Down
15 changes: 10 additions & 5 deletions packages/embed/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ const DEFAULT_DOMINANT_COLOR = '#7e1bcc'

const RequestType = Object.seal({
TRACK: 'track',
COLLECTION: 'collection'
ALBUM: 'album',
PLAYLIST: 'playlist'
})

const pathComponentRequestTypeMap = {
playlist: RequestType.COLLECTION,
album: RequestType.COLLECTION,
playlist: RequestType.PLAYLIST,
album: RequestType.ALBUM,
track: RequestType.TRACK
}

Expand Down Expand Up @@ -214,12 +215,16 @@ const App = (props) => {

setDominantColor({ primary: color })
}
} else if (requestType === RequestType.COLLECTION) {
} else if (
requestType === RequestType.ALBUM ||
requestType === RequestType.PLAYLIST
) {
let collection
if (request.handle && request.slug) {
collection = await getCollectionByPermalink(
request.handle,
request.slug
request.slug,
requestType
)
} else if (request.hashId) {
collection = await getCollectionWithHashId(request.hashId)
Expand Down
8 changes: 4 additions & 4 deletions packages/embed/src/util/BedtimeClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ export const getCollectionWithHashId = async (hashId) => {
return getFormattedCollectionResponse(res.data)
}

export const getCollectionByPermalink = async (handle, slug) => {
const res = await audiusSdk.playlists.getPlaylistByHandleAndSlug({
handle,
slug
export const getCollectionByPermalink = async (handle, slug, type) => {
const permalink = `/${handle}/${type}/${slug}`
const res = await audiusSdk.playlists.getBulkPlaylists({
permalink: [permalink]
})
return getFormattedCollectionResponse(res.data)
}
Expand Down
Loading