-
Notifications
You must be signed in to change notification settings - Fork 13
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
1 parent
3dc8146
commit 6d2a17d
Showing
3 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// biome-ignore lint/style/useImportType: deepkit/type | ||
import { Social } from '../../structures/social' | ||
|
||
export interface ChannelSocialsResponse { | ||
socials: Social[] | ||
} |
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,22 @@ | ||
import { cast } from '@deepkit/type' | ||
import type { Kient } from '../../kient' | ||
// biome-ignore lint/style/useImportType: deepkit/type | ||
import { CommonAPIResponse, isSuccessResponse } from '../../util/common-api-response' | ||
// biome-ignore lint/style/useImportType: deepkit/type | ||
import { ChannelSocialsResponse } from './get-socials.response' | ||
// biome-ignore lint/style/useImportType: deepkit/type | ||
import { Social } from '../../structures/social' | ||
|
||
export async function getSocials(kient: Kient, slugOrId: string) { | ||
const response = await kient._apiClient.fetch<CommonAPIResponse<ChannelSocialsResponse>>( | ||
`/channels/${slugOrId}/socials`, | ||
) | ||
|
||
const typedResponse = cast<CommonAPIResponse<ChannelSocialsResponse>>(response) | ||
if (!isSuccessResponse(typedResponse)) { | ||
throw new Error(`Request failed: ${typedResponse.data}`) | ||
} | ||
|
||
const socials = cast<Social[]>({ ...typedResponse.data.socials, kient }) | ||
return socials | ||
} |
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 @@ | ||
export class Social {} |