/* tslint:disable */
/* eslint-disable */
/**
 * Streaming Availability API
 * Streaming Availability API allows getting streaming availability information of movies and series; and querying the list of available shows on streaming services such as Netflix, Disney+, Apple TV, Max and Hulu across 60 countries!
 *
 * The version of the OpenAPI document: 4.1.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import { mapValues } from '../runtime';
import type { Addon } from './Addon';
import {
    AddonFromJSON,
    AddonFromJSONTyped,
    AddonToJSON,
} from './Addon';
import type { ChangeType } from './ChangeType';
import {
    ChangeTypeFromJSON,
    ChangeTypeFromJSONTyped,
    ChangeTypeToJSON,
} from './ChangeType';
import type { ItemType } from './ItemType';
import {
    ItemTypeFromJSON,
    ItemTypeFromJSONTyped,
    ItemTypeToJSON,
} from './ItemType';
import type { ServiceInfo } from './ServiceInfo';
import {
    ServiceInfoFromJSON,
    ServiceInfoFromJSONTyped,
    ServiceInfoToJSON,
} from './ServiceInfo';
import type { ShowType } from './ShowType';
import {
    ShowTypeFromJSON,
    ShowTypeFromJSONTyped,
    ShowTypeToJSON,
} from './ShowType';
import type { StreamingOptionType } from './StreamingOptionType';
import {
    StreamingOptionTypeFromJSON,
    StreamingOptionTypeFromJSONTyped,
    StreamingOptionTypeToJSON,
} from './StreamingOptionType';

/**
 * A change object represents a future or past change in a streaming catalog.
 * It contains the details such as the type of the change
 * (could be past change such as like new, updated, removed;
 * or a future change such as expiring, upcoming),
 * the affected item type (show, season or episode), timestamp of the change and more.
 * 
 * Via change endpoints, you can get the most recent updates in the streaming catalogs.
 * On top of the changes, you can also get the details of the affected shows. Every change object
 * has a showId field.
 * You can find the list of shows affected by the changes in the shows field of the response, and match
 * the show ids with the showId field of the change objects.
 * 
 * @export
 * @interface Change
 */
export interface Change {
    /**
     * Type of the change.
     * @type {ChangeType}
     * @memberof Change
     */
    changeType: ChangeType;
    /**
     * Type of the item affected from the change.
     * @type {ItemType}
     * @memberof Change
     */
    itemType: ItemType;
    /**
     * Id of the show affected from the change.
     * @type {string}
     * @memberof Change
     */
    showId: string;
    /**
     * Type of the show affected from the change.
     * @type {ShowType}
     * @memberof Change
     */
    showType: ShowType;
    /**
     * Number of the season affected from the change. Omitted if item_type is not seasonor episode.
     * @type {number}
     * @memberof Change
     */
    season?: number;
    /**
     * Number of the episode affected from the change. Omitted if item_type is not episode.
     * @type {number}
     * @memberof Change
     */
    episode?: number;
    /**
     * Service affected from the change.
     * @type {ServiceInfo}
     * @memberof Change
     */
    service: ServiceInfo;
    /**
     * 
     * @type {StreamingOptionType}
     * @memberof Change
     */
    streamingOptionType: StreamingOptionType;
    /**
     * Addon info, if the streamingOptionType is addon. Otherwise omitted.
     * @type {Addon}
     * @memberof Change
     */
    addon?: Addon;
    /**
     * [Unix Time Stamp](https://www.unixtimestamp.com/) of the change.
     * Past changes (new, updated, removed) will always have a timestamp.
     * Future changes (expiring, upcoming) will have a timestamp if the exact date is known.
     * If not, timestamp will be omitted, e.g. a show is known to be expiring soon, but the exact date is not known.
     * 
     * @type {number}
     * @memberof Change
     */
    timestamp?: number;
    /**
     * Deep link to the affected streaming option's page in the web app of the streaming service.
     * This field is guaranteed to be populated when changeType is new, updated, expiring or removed.
     * When changeType is upcoming, this field might be populated or null depending on if the link of the future streaming option is known.
     * 
     * @type {string}
     * @memberof Change
     */
    link?: string;
}

/**
 * Check if a given object implements the Change interface.
 */
export function instanceOfChange(value: object): boolean {
    if (!('changeType' in value)) return false;
    if (!('itemType' in value)) return false;
    if (!('showId' in value)) return false;
    if (!('showType' in value)) return false;
    if (!('service' in value)) return false;
    if (!('streamingOptionType' in value)) return false;
    return true;
}

export function ChangeFromJSON(json: any): Change {
    return ChangeFromJSONTyped(json, false);
}

export function ChangeFromJSONTyped(json: any, ignoreDiscriminator: boolean): Change {
    if (json == null) {
        return json;
    }
    return {
        
        'changeType': ChangeTypeFromJSON(json['changeType']),
        'itemType': ItemTypeFromJSON(json['itemType']),
        'showId': json['showId'],
        'showType': ShowTypeFromJSON(json['showType']),
        'season': json['season'] == null ? undefined : json['season'],
        'episode': json['episode'] == null ? undefined : json['episode'],
        'service': ServiceInfoFromJSON(json['service']),
        'streamingOptionType': StreamingOptionTypeFromJSON(json['streamingOptionType']),
        'addon': json['addon'] == null ? undefined : AddonFromJSON(json['addon']),
        'timestamp': json['timestamp'] == null ? undefined : json['timestamp'],
        'link': json['link'] == null ? undefined : json['link'],
    };
}

export function ChangeToJSON(value?: Change | null): any {
    if (value == null) {
        return value;
    }
    return {
        
        'changeType': ChangeTypeToJSON(value['changeType']),
        'itemType': ItemTypeToJSON(value['itemType']),
        'showId': value['showId'],
        'showType': ShowTypeToJSON(value['showType']),
        'season': value['season'],
        'episode': value['episode'],
        'service': ServiceInfoToJSON(value['service']),
        'streamingOptionType': StreamingOptionTypeToJSON(value['streamingOptionType']),
        'addon': AddonToJSON(value['addon']),
        'timestamp': value['timestamp'],
        'link': value['link'],
    };
}

