generated from JoshuaKGoldberg/create-typescript-app
-
-
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
16 changed files
with
468 additions
and
65 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,28 @@ | ||
import type { | ||
SoundcloudFilter, | ||
SoundcloudSelectionSearch, | ||
SoundcloudTrackSearch, | ||
} from "../types"; | ||
import { Base } from "./Base"; | ||
|
||
export class Discover extends Base { | ||
public recentTracks = async (genre: string, params?: SoundcloudFilter) => { | ||
return this.api.fetch<SoundcloudTrackSearch>( | ||
`/recent_tracks/${genre}`, | ||
"GET", | ||
{ | ||
params, | ||
}, | ||
); | ||
}; | ||
|
||
public mixedCollections = async (params?: SoundcloudFilter) => { | ||
return this.api.fetch<SoundcloudSelectionSearch>( | ||
`/mixed_collections`, | ||
"GET", | ||
{ | ||
params, | ||
}, | ||
); | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,10 +1,72 @@ | ||
import type { | ||
SoundcloudFilter, | ||
SoundcloudPlaylist, | ||
SoundcloudTrack, | ||
} from "../types"; | ||
import { | ||
type SoundcloudLikesIDsSearch, | ||
type SoundcloudWhoToFollowFilter, | ||
type SoundcloudWhoToFollowSearch, | ||
} from "../types/MeTypes"; | ||
import type { SoundcloudUser } from "../types/UserTypes"; | ||
|
||
import { Base } from "./Base.js"; | ||
|
||
export class Me extends Base { | ||
public get = async () => { | ||
const response = await this.sc.api.get("/me"); | ||
return (await response.json()) as SoundcloudUser; | ||
return this.api.fetch<SoundcloudUser>("/me", "GET"); | ||
}; | ||
|
||
trackReposts = { | ||
put: async (id: number) => { | ||
return this.sc.api.fetch<null>(`/me/track_reposts/${id}`, "PUT"); | ||
}, | ||
delete: async (id: number) => { | ||
return this.sc.api.fetch<null>(`/me/track_reposts/${id}`, "DELETE"); | ||
}, | ||
caption: async (id: number, caption: string) => { | ||
return await this.sc.api.fetch<null>( | ||
`/me/track_reposts/${id}/caption`, | ||
"PUT", | ||
{ | ||
body: { payload: { caption }, type: "raw" }, | ||
}, | ||
); | ||
}, | ||
}; | ||
trackLikes = { | ||
get: async (params?: SoundcloudFilter) => { | ||
return this.sc.api.fetch<SoundcloudLikesIDsSearch>( | ||
"/me/track_likes/ids", | ||
"GET", | ||
{ | ||
params, | ||
}, | ||
); | ||
}, | ||
put: async (id: number) => { | ||
return this.sc.api.fetch<null>(`/me/track_likes/${id}`, "PUT"); | ||
}, | ||
delete: async (id: number) => { | ||
return this.sc.api.fetch<null>(`/me/track_likes/${id}`, "DELETE"); | ||
}, | ||
}; | ||
library = { | ||
all: async (params?: SoundcloudFilter) => { | ||
return this.api.fetch<SoundcloudPlaylist>("/me/library", "GET", { | ||
params, | ||
}); | ||
}, | ||
}; | ||
suggested = { | ||
who_to_follow: async (params?: SoundcloudWhoToFollowFilter) => { | ||
return this.api.fetch<SoundcloudWhoToFollowSearch>( | ||
"/me/suggested/who_to_follow", | ||
"GET", | ||
{ | ||
params, | ||
}, | ||
); | ||
}, | ||
}; | ||
} |
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,64 @@ | ||
import type { | ||
SoundcloudAlbumFilter, | ||
SoundcloudAlbumSearch, | ||
SoundcloudAllSearch, | ||
SoundcloudPlaylistFilter, | ||
SoundcloudPlaylistSearch, | ||
SoundcloudQuerySearch, | ||
SoundcloudSearchFilter, | ||
SoundcloudTrackFilter, | ||
SoundcloudTrackSearch, | ||
SoundcloudUserFilter, | ||
SoundcloudUserSearch, | ||
} from "../types"; | ||
import { Base } from "./Base"; | ||
|
||
export class Search extends Base { | ||
public tracks = async (params?: SoundcloudTrackFilter) => { | ||
return await this.api.fetch<SoundcloudTrackSearch>( | ||
"/search/tracks", | ||
"GET", | ||
{ params }, | ||
); | ||
}; | ||
|
||
public users = async (params?: SoundcloudUserFilter) => { | ||
return await this.api.fetch<SoundcloudUserSearch>("/search/users", "GET", { | ||
params, | ||
}); | ||
}; | ||
|
||
public queries = async (params?: SoundcloudSearchFilter) => { | ||
return await this.api.fetch<SoundcloudQuerySearch>( | ||
"/search/queries", | ||
"GET", | ||
{ params }, | ||
); | ||
}; | ||
|
||
public playlists = async (params?: SoundcloudPlaylistFilter) => { | ||
return await this.api.fetch<SoundcloudPlaylistSearch>( | ||
"/search/playlists", | ||
"GET", | ||
{ params }, | ||
); | ||
}; | ||
|
||
public albums = async (params?: SoundcloudAlbumFilter) => { | ||
return await this.api.fetch<SoundcloudAlbumSearch>( | ||
"/search/albums", | ||
"GET", | ||
{ params }, | ||
); | ||
}; | ||
|
||
public all = async (params?: SoundcloudSearchFilter) => { | ||
return await this.api.fetch<SoundcloudAllSearch>("/search", "GET", { | ||
params, | ||
}); | ||
}; | ||
|
||
public async searchNext<T>(next_href: string) { | ||
return await this.api.getURL(next_href); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,24 +1,38 @@ | ||
import type { | ||
SoundcloudCommentSearch, | ||
SoundcloudTrack, | ||
SoundcloudTrackFilter, | ||
SoundcloudTrackSearch, | ||
SoundcloudCommentFilter, | ||
SoundcloudFilter, | ||
} from "../types"; | ||
|
||
import { Base } from "./Base.js"; | ||
|
||
export class Tracks extends Base { | ||
public get = async (id: number) => { | ||
const response = await this.api.get(`/tracks/${id}`); | ||
return (await response.json()) as SoundcloudTrack; | ||
return await this.api.fetch<SoundcloudTrack>(`/tracks/${id}`, "GET"); | ||
}; | ||
|
||
public related = async (id: number, limit?: number) => { | ||
const response = await this.api.get(`/tracks/${id}/related`, { limit }); | ||
return (await response.json()) as SoundcloudTrack[]; | ||
public related = async (id: number, params?: SoundcloudFilter) => { | ||
return await this.api.fetch<SoundcloudTrackSearch>( | ||
`/tracks/${id}/related`, | ||
"GET", | ||
{ params }, | ||
); | ||
}; | ||
|
||
public search = async (params?: SoundcloudTrackFilter) => { | ||
const response = await this.api.get("/search/tracks", params); | ||
return (await response.json()) as SoundcloudTrackSearch; | ||
public getMultiple = async (ids: number[]) => { | ||
const params = { ids: ids.join(",") }; | ||
return await this.api.fetch<SoundcloudTrack[]>(`/tracks`, "GET", { | ||
params, | ||
}); | ||
}; | ||
|
||
public comments = async (id: number, params?: SoundcloudCommentFilter) => { | ||
return await this.api.fetch<SoundcloudCommentSearch>( | ||
`/tracks/${id}/comments`, | ||
"GET", | ||
{ params }, | ||
); | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,11 +1,24 @@ | ||
export interface SoundcloudFilter { | ||
limit?: number; | ||
offset?: number; | ||
} | ||
|
||
export interface SoundcloudSearchFilter extends SoundcloudFilter { | ||
q: string; | ||
} | ||
|
||
export interface SoundcloudSearch { | ||
next_href: string; | ||
next_href: string | null; | ||
query_urn: string; | ||
total_results: number; | ||
total_results?: number; | ||
} | ||
|
||
export type SoundcloudLicense = | ||
| "all-rights-reserved" | ||
| "cc-by" | ||
| "cc-by-nc" | ||
| "cc-by-nc-nd" | ||
| "cc-by-nc-sa" | ||
| "cc-by-nd" | ||
| "cc-by-sa" | ||
| "no-rights-reserved"; |
Oops, something went wrong.