Skip to content

Commit

Permalink
chore: rename AdSchedule to AdConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Aug 8, 2024
1 parent e7e3e67 commit 0097951
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions packages/common/src/services/ApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { filterMediaOffers } from '../utils/entitlements';
import { useConfigStore as ConfigStore } from '../stores/ConfigStore';
import type { GetPlaylistParams, Playlist, PlaylistItem } from '../../types/playlist';
import type { ContentList, GetContentSearchParams } from '../../types/content-list';
import type { DeliveryAdSchedule } from '../../types/ad-schedule';
import type { AdSchedule } from '../../types/ad-schedule';
import type { EpisodeInSeries, EpisodesRes, EpisodesWithPagination, GetSeriesParams, Series } from '../../types/series';
import env from '../env';
import { logError } from '../logger';
Expand Down Expand Up @@ -255,15 +255,15 @@ export default class ApiService {
return this.transformEpisodes(episodesRes, seasonNumber);
};

getAdSchedule = async (id: string | undefined | null): Promise<DeliveryAdSchedule | undefined> => {
getAdSchedule = async (id: string | undefined | null): Promise<AdSchedule | undefined> => {
if (!id) {
throw new Error('Ad Schedule ID is required');
}

const url = env.APP_API_BASE_URL + `/v2/advertising/schedules/${id}.json`;
const response = await fetch(url, { credentials: 'omit' });

return (await getDataOrThrow(response)) as DeliveryAdSchedule;
return (await getDataOrThrow(response)) as AdSchedule;
};

/**
Expand Down
17 changes: 8 additions & 9 deletions packages/common/types/ad-schedule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export type AdSchedule = {
adscheduleid?: string;
export type AdConfig = {
client: string;
schedule: string;
};
Expand All @@ -11,21 +10,21 @@ export type AdScheduleUrls = {

export type AdDeliveryMethod = 'csai' | 'ssai';

type DeliverySchedule = {
type Schedule = {
tag: string[];
type: 'linear' | 'nonlinear';
offset: 'pre' | 'post' | string; // seconds, timestamp, percentage
skipoffset?: number;
};

type DeliveryRules = {
type Rules = {
startOnSeek: 'pre' | 'none' | 'mid';
timeBetweenAds: number;
startOn?: number;
frequency?: number;
};

type DeliveryBids = {
type Bids = {
settings: {
bidTimeout: number;
floorPriceCents: number;
Expand Down Expand Up @@ -57,10 +56,10 @@ type DeliveryBids = {
};
};

export type DeliveryAdSchedule = {
rules: DeliveryRules;
schedule: DeliverySchedule[];
bids: DeliveryBids;
export type AdSchedule = {
rules: Rules;
schedule: Schedule[];
bids: Bids;
client: 'vast' | 'googima';
vpaidmode?: 'enabled' | 'disabled' | 'insecure';
adscheduleid: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks-react/src/useAds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore';
import ApiService from '@jwp/ott-common/src/services/ApiService';
import { getModule } from '@jwp/ott-common/src/modules/container';
import { createURL } from '@jwp/ott-common/src/utils/urlFormatting';
import type { AdSchedule } from '@jwp/ott-common/types/ad-schedule';
import type { AdConfig } from '@jwp/ott-common/types/ad-schedule';

const CACHE_TIME = 60 * 1000 * 20;

Expand Down Expand Up @@ -39,7 +39,7 @@ export const useAds = ({ mediaId }: { mediaId: string }) => {
schedule: createURL(adScheduleUrls?.xml || '', {
media_id: mediaId,
}),
} as AdSchedule)
} as AdConfig)
: undefined;

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-react/src/components/Player/Player.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import type { AdSchedule, DeliveryAdSchedule } from '@jwp/ott-common/types/ad-schedule';
import type { AdConfig, AdSchedule } from '@jwp/ott-common/types/ad-schedule';
import type { PlaylistItem } from '@jwp/ott-common/types/playlist';
import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore';
import { deepCopy } from '@jwp/ott-common/src/utils/collection';
Expand All @@ -20,7 +20,7 @@ type Props = {
item: PlaylistItem;
startTime?: number;
autostart?: boolean;
adsData?: AdSchedule | DeliveryAdSchedule;
adsData?: AdConfig | AdSchedule;
onReady?: (player?: JWPlayer) => void;
onPlay?: () => void;
onPause?: () => void;
Expand Down

0 comments on commit 0097951

Please sign in to comment.