-
Notifications
You must be signed in to change notification settings - Fork 2
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
8 changed files
with
283 additions
and
13 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
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,38 @@ | ||
import { Image } from './image'; | ||
/** | ||
* | ||
* @export | ||
* @interface ImageDocsResponseDtoV1_4 | ||
*/ | ||
export interface ImageDocsResponseDtoV1_4 { | ||
/** | ||
* | ||
* @type {Array<Image>} | ||
* @memberof ImageDocsResponseDtoV1_4 | ||
*/ | ||
docs: Array<Image>; | ||
/** | ||
* Общее количество результатов | ||
* @type {number} | ||
* @memberof ImageDocsResponseDtoV1_4 | ||
*/ | ||
total: number; | ||
/** | ||
* Количество результатов на странице | ||
* @type {number} | ||
* @memberof ImageDocsResponseDtoV1_4 | ||
*/ | ||
limit: number; | ||
/** | ||
* Текущая страница | ||
* @type {number} | ||
* @memberof ImageDocsResponseDtoV1_4 | ||
*/ | ||
page: number; | ||
/** | ||
* Сколько страниц всего | ||
* @type {number} | ||
* @memberof ImageDocsResponseDtoV1_4 | ||
*/ | ||
pages: number; | ||
} |
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,154 @@ | ||
import { SortType } from "../../../enums"; | ||
|
||
export enum ImageFieldV1_4 { | ||
'movieId' = 'movieId', | ||
'type' = 'type', | ||
'language' = 'language', | ||
'url' = 'url', | ||
'previewUrl' = 'previewUrl', | ||
'height' = 'height', | ||
'width' = 'width', | ||
updatedAt = 'updatedAt', | ||
createdAt = 'createdAt', | ||
} | ||
|
||
export enum ImageSelectFieldV1_4 { | ||
'movieId' = 'movieId', | ||
'type' = 'type', | ||
'language' = 'language', | ||
'url' = 'url', | ||
'previewUrl' = 'previewUrl', | ||
'height' = 'height', | ||
'width' = 'width', | ||
updatedAt = 'updatedAt', | ||
createdAt = 'createdAt', | ||
} | ||
|
||
export enum ImageTypeV1_4 { | ||
'backdrops' = 'backdrops', | ||
'cover' = 'cover', | ||
'frame' = 'frame', | ||
'promo' = 'promo', | ||
'screenshot' = 'screenshot', | ||
'shooting' = 'shooting', | ||
'still' = 'still', | ||
'wallpaper' = 'wallpaper', | ||
} | ||
|
||
export enum ImageLanguageV1_4 { | ||
'ab' = 'ab', | ||
'af' = 'af', | ||
'am' = 'am', | ||
'ar' = 'ar', | ||
'as' = 'as', | ||
'av' = 'av', | ||
'ba' = 'ba', | ||
'be' = 'be', | ||
'bg' = 'bg', | ||
'bn' = 'bn', | ||
'ca' = 'ca', | ||
'ce' = 'ce', | ||
'cn' = 'cn', | ||
'cs' = 'cs', | ||
'cu' = 'cu', | ||
'cv' = 'cv', | ||
'da' = 'da', | ||
'de' = 'de', | ||
} | ||
|
||
export type QueryStrategyV1_4 = '!' | '+' | ''; | ||
export type WithQueryStrategyV1_4<T> = T extends string ? `${QueryStrategyV1_4}${T}` : never; | ||
|
||
export interface ImageRequestV1_4 { | ||
/** | ||
* Номер страницы | ||
* @type {number} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
page?: number; | ||
|
||
/** | ||
* Количество элементов на странице | ||
* @type {number} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
limit?: number; | ||
|
||
/** | ||
* Список полей требуемых в ответе из модели | ||
* @type {Array<ImageSelectFieldV1_4>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
selectFields?: Array<ImageSelectFieldV1_4>; | ||
|
||
/** | ||
* Список полей которые не должны быть null или пусты | ||
* @type {Array<ImageFieldV1_4>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
notNullFields?: Array<ImageFieldV1_4>; | ||
|
||
/** | ||
* Сортировка по полям из модели | ||
* @type {Array<ImageFieldV1_4>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
sortField?: Array<ImageFieldV1_4>; | ||
|
||
/** | ||
* Тип сортировки применительно к полям из sortField (пример: `"1", "-1"`) | ||
* @type {Array<SortType>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
|
||
sortType?: Array<SortType>; | ||
|
||
/** | ||
* Поиск картинок по id фильма (пример: `"666", "!666"`) | ||
* @type {Array<WithQueryStrategyV1_4<string>>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
movieId?: Array<WithQueryStrategyV1_4<string>>; | ||
|
||
/** | ||
* Поиск картинок по типу (пример: `"cover", "!cover"`) | ||
* @type {Array<WithQueryStrategyV1_4<ImageTypeV1_4>>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
type?: Array<WithQueryStrategyV1_4<ImageTypeV1_4>>; | ||
|
||
/** | ||
* Поиск картинок по языку (пример: `"en", "!de"`) | ||
* @type {Array<ImageLanguageV1_4>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
language?: Array<ImageLanguageV1_4>; | ||
|
||
/** | ||
* Поиск картинок по высоте (пример: `"1920", "360-1920"`) | ||
* @type {Array<WithQueryStrategyV1_4<string>>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
height?: Array<WithQueryStrategyV1_4<string>>; | ||
|
||
/** | ||
* Поиск картинок по ширине (пример: `"1080", "320-1080"`) | ||
* @type {Array<WithQueryStrategyV1_4<string>>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
width?: Array<WithQueryStrategyV1_4<string>>; | ||
|
||
/** | ||
* Поиск по дате обновления в базе (пример: `01.01.2020, 01.01.2020-31.12.2020`) | ||
* @type {Array<WithQueryStrategyV1_4<string>>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
updatedAt?: Array<WithQueryStrategyV1_4<string>>; | ||
|
||
/** | ||
* Поиск по дате добавления в базу (пример: `01.01.2020, 01.01.2020-31.12.2020`) | ||
* @type {Array<WithQueryStrategyV1_4<string>>} | ||
* @memberof ImageRequestV1_4 | ||
*/ | ||
createdAt?: Array<WithQueryStrategyV1_4<string>>; | ||
} |
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,61 @@ | ||
/** | ||
* | ||
* @export | ||
* @interface Image | ||
*/ | ||
export interface Image { | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof Image | ||
*/ | ||
movieId: number; | ||
/** | ||
* | ||
* @type {string} | ||
* @memberof Image | ||
*/ | ||
type?: string; | ||
/** | ||
* | ||
* @type {string} | ||
* @memberof Image | ||
*/ | ||
language?: string; | ||
/** | ||
* | ||
* @type {string} | ||
* @memberof Image | ||
*/ | ||
url?: string; | ||
/** | ||
* | ||
* @type {string} | ||
* @memberof Image | ||
*/ | ||
previewUrl?: string; | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof Image | ||
*/ | ||
height?: number; | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof Image | ||
*/ | ||
width?: number; | ||
/** | ||
* | ||
* @type {Date} | ||
* @memberof Image | ||
*/ | ||
updatedAt: Date; | ||
/** | ||
* | ||
* @type {Date} | ||
* @memberof Image | ||
*/ | ||
createdAt: Date; | ||
} |
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,3 @@ | ||
export * from './image'; | ||
export * from './image-docs-response.dto'; | ||
export * from './image-request.dto'; |
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,9 +1,9 @@ | ||
import { ClientRequest } from '../../client-request'; | ||
import { IResponse } from '../response.interface'; | ||
import { ImageDocsResponseDto } from '../api.interface'; | ||
import { ImageRequestV1_4 } from '../dto/image/image-request.dto'; | ||
import { ImageDocsResponseDtoV1_4 } from '../dto/image/image-docs-response.dto'; | ||
|
||
export interface IImageService { | ||
getByFilters( | ||
filters: Record<string, string>, | ||
): Promise<IResponse<ImageDocsResponseDto>>; | ||
filters: ImageRequestV1_4 | Record<string, string>, | ||
): Promise<IResponse<ImageDocsResponseDtoV1_4>> | ||
} |
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,16 +1,20 @@ | ||
import { KinopoiskDev } from '../index'; | ||
import { ClientRequest } from '../client-request'; | ||
import { IResponse } from '../interfaces/response.interface'; | ||
import { ImageDocsResponseDto } from '../interfaces/api.interface'; | ||
import { VERSION } from '../enums/version.enum'; | ||
import { IImageService } from '../interfaces/services/image-service.interface'; | ||
import { ImageRequestV1_4 } from '../interfaces/dto/image/image-request.dto'; | ||
import { ImageDocsResponseDtoV1_4 } from '../interfaces/dto/image/image-docs-response.dto'; | ||
|
||
export class ImageService implements IImageService { | ||
constructor(private readonly request: ClientRequest) {} | ||
|
||
async getByFilters( | ||
filters: Record<string, string>, | ||
): Promise<IResponse<ImageDocsResponseDto>> { | ||
return await this.request.get(VERSION.V1, `/image`, filters); | ||
filters: ImageRequestV1_4 | Record<string, string>, | ||
): Promise<IResponse<ImageDocsResponseDtoV1_4>> { | ||
return await this.request.get<ImageDocsResponseDtoV1_4, typeof filters>( | ||
VERSION.V1_4, | ||
`/image`, | ||
filters, | ||
); | ||
} | ||
} |