Skip to content

Commit

Permalink
fix(PlayerEndpoint): Don't set undefined fields
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Aug 8, 2024
1 parent 261f2ac commit 0e91a08
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/core/endpoints/PlayerEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const PATH = '/player';
* @returns The payload.
*/
export function build(opts: PlayerEndpointOptions): IPlayerRequest {
return {
const payload: IPlayerRequest = {
playbackContext: {
contentPlaybackContext: {
vis: 0,
Expand All @@ -33,14 +33,22 @@ export function build(opts: PlayerEndpointOptions): IPlayerRequest {
},
racyCheckOk: true,
contentCheckOk: true,
videoId: opts.video_id,
...{
client: opts.client,
playlistId: opts.playlist_id,
params: opts.params,
serviceIntegrityDimensions: {
poToken: opts.po_token || ''
}
}
videoId: opts.video_id
};

if (opts.client)
payload.client = opts.client;

if (opts.playlist_id)
payload.playlistId = opts.playlist_id;

if (opts.params)
payload.params = opts.params;

if (opts.po_token)
payload.serviceIntegrityDimensions = {
poToken: opts.po_token
};

return payload;
}

0 comments on commit 0e91a08

Please sign in to comment.