adding tv networks

This commit is contained in:
Benjamin Lei
2023-09-01 19:27:15 -07:00
parent 8738ac7fda
commit d5013db314
4 changed files with 44 additions and 0 deletions

23
src/endpoints/networks.ts Normal file
View File

@@ -0,0 +1,23 @@
import { NetworkDetails, NetworkImages } from '..';
import { AlternativeNames } from './../types/companies';
import { BaseEndpoint } from './base';
export class NetworksEndpoint extends BaseEndpoint {
constructor(protected readonly accessToken: string) {
super(accessToken);
}
async details(id: number): Promise<NetworkDetails> {
return await this.api.get<NetworkDetails>(`/network/${id}`);
}
async alternativeNames(id: number): Promise<AlternativeNames> {
return await this.api.get<AlternativeNames>(
`/network/${id}/alternative_names`
);
}
async images(id: number): Promise<NetworkImages> {
return await this.api.get<NetworkImages>(`/network/${id}/images`);
}
}

View File

@@ -19,6 +19,7 @@ import {
TvEpisodesEndpoint,
} from './endpoints';
import { CompaniesEndpoint } from './endpoints/companies';
import { NetworksEndpoint } from './endpoints/networks';
export class TMDB {
private readonly accessToken: string;
@@ -51,6 +52,10 @@ export class TMDB {
return new CompaniesEndpoint(this.accessToken);
}
get networks(): NetworksEndpoint {
return new NetworksEndpoint(this.accessToken);
}
get search(): SearchEndpoint {
return new SearchEndpoint(this.accessToken);
}

View File

@@ -2,6 +2,7 @@ export * from './options';
export * from './certification';
export * from './credits';
export * from './companies';
export * from './networks';
export * from './configuration';
export * from './changes';
export * from './movies';

15
src/types/networks.ts Normal file
View File

@@ -0,0 +1,15 @@
import { Image } from '.';
export interface NetworkDetails {
headquarters: string;
homepage: string;
id: number;
logo_path: string;
name: string;
origin_country: string;
}
export interface NetworkImages {
id: number;
logos: Image[];
}