generated from antfu/starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { CategoryItem, GetCategoriesOptions, GetCategoriesResults } from '../types' | ||
import { ApiPart } from './api.part' | ||
|
||
export class CategoriesApi extends ApiPart { | ||
public async getCategories(opts: GetCategoriesOptions = {}): Promise<GetCategoriesResults> { | ||
return this.$fetch<GetCategoriesResults>('/browse/categories', { | ||
query: opts, | ||
}) | ||
} | ||
|
||
public async getCategory(id: string, opts: Pick<GetCategoriesOptions, 'country' | 'locale'> = {}): Promise<CategoryItem> { | ||
return this.$fetch<CategoryItem>(`/browse/categories/${id}`, { | ||
query: opts, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import type { ImageObject, PaginatedResults } from './common' | ||
|
||
export interface GetCategoriesOptions { | ||
/** | ||
* A country: an [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. | ||
* Provide this parameter if you want the list of returned items to be relevant to a particular country. | ||
* If omitted, the returned items will be relevant to all countries. | ||
*/ | ||
country?: string | ||
|
||
/** | ||
* The desired language, consisting of a lowercase [ISO 639-1 ](https://en.wikipedia.org/wiki/ISO_639-1) language code | ||
* and an uppercase [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code, joined by an underscore. | ||
* For example: `es_MX`, meaning "Spanish (Mexico)". | ||
* | ||
* Provide this parameter if you want the results returned in a particular language (where available). | ||
* | ||
* **Note:** if locale is not supplied, or if the specified language is not available, all strings will be returned in | ||
* the Spotify default language (American English). | ||
* | ||
* The locale parameter, combined with the country parameter, may give odd results if not carefully matched.For example country=SE&locale=de_DE will return a list of categories relevant to Sweden but as German language strings. | ||
*/ | ||
locale?: string | ||
|
||
/** | ||
* The maximum number of items to return. | ||
* @default 20 | ||
* @max `50` | ||
*/ | ||
limit?: number | ||
|
||
/** | ||
* The index of the first item to return. Use with limit to get the next set of items. | ||
* @default 0 | ||
*/ | ||
offset?: number | ||
} | ||
|
||
export interface CategoryItem { | ||
/** | ||
* A link to the Web API endpoint returning full details of the category. | ||
*/ | ||
href: string | ||
|
||
/** | ||
* The category icon, in various sizes. | ||
*/ | ||
icons: ImageObject[] | ||
|
||
/** | ||
* The Spotify [category ID](https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids) of the category. | ||
*/ | ||
id: string | ||
|
||
/** | ||
* The name of the category. | ||
*/ | ||
name: string | ||
} | ||
|
||
export interface GetCategoriesResults { | ||
categories: PaginatedResults<CategoryItem> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters