Skip to content

Commit

Permalink
Merge f354b0a into d1fc173
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalonen committed Oct 28, 2018
2 parents d1fc173 + f354b0a commit 365c8ca
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
import { ApiResponseProgramsNow } from '../client.types';

const programs: ApiResponseProgramsNow = {
"apiVersion": "1.1.322",
"meta": {
"start": 0,
Expand Down Expand Up @@ -15380,4 +15382,6 @@
"version": 1536685248
}
]
}
}

export default programs
3 changes: 2 additions & 1 deletion src/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from 'fs'
import * as path from 'path'
import MOCK_PROGRAM from './__mocks__/program'
import MOCK_PROGRAMS_NOW from './__mocks__/programs-now'
import Client, { IMAGES_URL } from './client'
import { ApiAuth } from './client.types'

Expand Down Expand Up @@ -60,7 +61,7 @@ describe('Client', () => {
})

test('fetchProgramsNow', async () => {
const data = readJSONMock('programs-now.json')
const data = MOCK_PROGRAMS_NOW
const client = new Client(VALID_APIKEYS, mockFetchResultWith(data))
const programs = await client.fetchProgramsNow()

Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
ApiAuth,
ApiRequestPrograms,
ApiRequestProgramsNow,
ApiResponse,
ApiResponseMediaPlayouts,
ApiResponseProgram,
ApiResponsePrograms,
ApiResponseProgramsNow,
PlayoutProtocol,
Program,
ProgramPublicationEvent
Expand Down Expand Up @@ -44,7 +44,7 @@ class Client {
return this.retrieveJSONOrError(response)
}

public async fetchProgramsNow(queryOptions: ApiRequestProgramsNow = {}): Promise<ApiResponse> {
public async fetchProgramsNow(queryOptions: ApiRequestProgramsNow = {}): Promise<ApiResponseProgramsNow> {
const url =
URI(API_URL)
.segment('programs')
Expand Down
99 changes: 51 additions & 48 deletions src/client.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type PublicationEventType = 'ScheduledTransmission' | 'OnDemandPublication'
export type PublicationEventTemporalStatus = 'currently' | 'in-future'
export type PublicationEventTemporalStatus = 'in-past' | 'currently' | 'in-future'
export type PlayoutProtocol = 'HLS' | 'HDS' | 'PMD' | 'RTMPE'
export type Order =
'playcount.6h:asc' |
Expand All @@ -23,31 +23,10 @@ export interface ApiAuth {
decryptKey?: string
}

export interface ApiResponseMetadata {
offset: string
limit: string
count: number
program: number
clip: number
}

export interface ApiResponse {
apiVersion: string
meta: ApiResponseMetadata
data: any
}

export interface LocalizedField {
[key: string]: string
}

export interface ProgramImage {
id: string
available: boolean
type: string
version: number
}

export interface Service {
id: string
}
Expand All @@ -72,7 +51,7 @@ export interface Media {
}

export interface ProgramPublicationEvent {
tags: Tags
tags?: Tags
service: Service
publisher: Service[]
startTime: string
Expand All @@ -86,7 +65,9 @@ export interface ProgramPublicationEvent {
version: number
}

type Language = 'fi' | 'sv'
export interface ProgramNow extends ProgramPublicationEvent {
content: Program
}

export interface Format {
inScheme: string
Expand All @@ -95,7 +76,7 @@ export interface Format {
}

export interface AV {
language: Language[]
language: Array<'fi' | 'sv' | 'en'>
format: Format[]
}

Expand All @@ -112,22 +93,27 @@ export interface Program {
video: Video
typeMedia: string
creator: unknown
partOfSeason: unknown
partOfSeries: unknown
episodeNumber: number
interactions: unknown
indexDataModified: string
partOfSeason?: unknown
partOfSeries?: unknown
episodeNumber?: number
interactions?: unknown
indexDataModified?: string
alternativeId: string[]
type: string
duration: string
productionId: string
productionId?: string
contentRating: unknown
title: LocalizedField
itemTitle: unknown
countryOfOrigin: string[]
id: string
typeCreative: string
image: ProgramImage
image: {
id?: string
available?: boolean
type?: string
version?: number
}
audio: Audio[]
originalTitle: unknown
publicationEvent: ProgramPublicationEvent[]
Expand All @@ -149,18 +135,6 @@ export interface MediaPlayout {
protectionType: string
}

export interface ApiResponseProgram {
apiVersion: string
meta: {
id: string;
}
data: Program
}

export interface ApiResponsePrograms extends ApiResponse {
data: Program[]
}

export interface ApiRequestPrograms {
id?: string // Multiple IDs can be passed as a comma separated list.
type?: 'program' | 'clip' | 'tvcontent' | 'tvprogram' | 'tvclip' | 'radiocontent' | 'radioprogram' | 'radioclip'
Expand All @@ -187,17 +161,46 @@ export interface ApiRequestProgramsNow {
mediaobject?: 'video' | 'audio'
}

export interface ApiResponseMediaPlayouts extends ApiResponse {
data: MediaPlayout[]
}

export interface ApiRequestProgramsNow {
service?: string // Multiple service IDs can be passes as a comma separated list.
start?: number // Allowed values range from -10 to 0. -1 means that the previous program will be included
end?: number // Allowed values range from 0 to 10. 1 means that the next program will be included
mediaobject?: 'video' | 'audio'
}

export interface ApiResponse {
apiVersion: string
}

export interface ApiResponseProgram extends ApiResponse {
meta: {
id: string
}
data: Program
}

export interface ApiResponsePrograms extends ApiResponse {
meta: {
offset: string
limit: string
count: number
program: number
clip: number
}
data: Program[]
}

export interface ApiResponseProgramsNow extends ApiResponse {
meta: {
start: number
end: number
}
data: ProgramNow[]
}

export interface ApiResponseMediaPlayouts extends ApiResponse {
meta: {
id: string
}
data: MediaPlayout[]
}

0 comments on commit 365c8ca

Please sign in to comment.