Skip to content

Commit

Permalink
feat: add getPerson
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Sep 17, 2017
1 parent a6df9d2 commit 341defe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Tmdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
import type {
MovieCastCreditType,
MovieCrewCreditType,
MovieType
MovieType,
PersonType
} from './types';

const debug = createDebug('Tmdb');
Expand Down Expand Up @@ -111,14 +112,21 @@ class Tmdb {
}

async getMovie (movieId: number): Promise<MovieType> {

const movie = await this.get('movie/' + movieId, {
language: this.language
});

return movie;
}

async getPerson (personId: number): Promise<PersonType> {
const person = await this.get('person/' + personId, {
language: this.language
});

return person;
}

async findId (resourceType: 'movie', externalSource: 'imdb', externalId: string): Promise<number> {
if (resourceType !== 'movie') {
throw new Unimplemented();
Expand Down
3 changes: 3 additions & 0 deletions src/bin/generate-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const typeMap = {
},
MovieType: (data) => {
return data.paths['/movie/{movie_id}'].get.responses['200'].schema.properties;
},
PersonType: (data) => {
return data.paths['/person/{person_id}'].get.responses['200'].schema.properties;
}
};

Expand Down
16 changes: 16 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,19 @@ export type MovieType = {|
+voteAverage: number,
+voteCount: number
|};

export type PersonType = {|
+adult: boolean,
+alsoKnownAs: $ReadOnlyArray<Object>,
+biography: string,
+birthday: string | null,
+deathday: string | null,
+gender: number,
+homepage: string | null,
+id: number,
+imdbId: string,
+name: string,
+placeOfBirth: string | null,
+popularity: number,
+profilePath: ImagePathType
|};

0 comments on commit 341defe

Please sign in to comment.