/* tslint:disable */
/* eslint-disable */
/**
 * Tribufu API
 * API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.3.0
 * Contact: contact@tribufu.com
 *
 * 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 { PackageRelease } from './PackageRelease';
import {
    PackageReleaseFromJSON,
    PackageReleaseFromJSONTyped,
    PackageReleaseToJSON,
    PackageReleaseToJSONTyped,
} from './PackageRelease';

/**
 * 
 * @export
 * @interface Package
 */
export interface Package {
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    id?: string;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    name: string | null;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    description?: string | null;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    authorId?: string;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    imageUrl: string | null;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    applicationId?: string | null;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    categoryId?: string | null;
    /**
     * 
     * @type {number}
     * @memberof Package
     */
    downloadCount?: number;
    /**
     * 
     * @type {Date}
     * @memberof Package
     */
    lastDownload?: Date | null;
    /**
     * 
     * @type {Array<PackageRelease>}
     * @memberof Package
     */
    releases?: Array<PackageRelease> | null;
    /**
     * 
     * @type {Date}
     * @memberof Package
     */
    created?: Date;
    /**
     * 
     * @type {Date}
     * @memberof Package
     */
    updated?: Date | null;
}

/**
 * Check if a given object implements the Package interface.
 */
export function instanceOfPackage(value: object): value is Package {
    if (!('name' in value) || value['name'] === undefined) return false;
    if (!('imageUrl' in value) || value['imageUrl'] === undefined) return false;
    return true;
}

export function PackageFromJSON(json: any): Package {
    return PackageFromJSONTyped(json, false);
}

export function PackageFromJSONTyped(json: any, ignoreDiscriminator: boolean): Package {
    if (json == null) {
        return json;
    }
    return {
        
        'id': json['id'] == null ? undefined : json['id'],
        'name': json['name'],
        'description': json['description'] == null ? undefined : json['description'],
        'authorId': json['author_id'] == null ? undefined : json['author_id'],
        'imageUrl': json['image_url'],
        'applicationId': json['application_id'] == null ? undefined : json['application_id'],
        'categoryId': json['category_id'] == null ? undefined : json['category_id'],
        'downloadCount': json['download_count'] == null ? undefined : json['download_count'],
        'lastDownload': json['last_download'] == null ? undefined : (new Date(json['last_download'])),
        'releases': json['releases'] == null ? undefined : ((json['releases'] as Array<any>).map(PackageReleaseFromJSON)),
        'created': json['created'] == null ? undefined : (new Date(json['created'])),
        'updated': json['updated'] == null ? undefined : (new Date(json['updated'])),
    };
}

export function PackageToJSON(json: any): Package {
    return PackageToJSONTyped(json, false);
}

export function PackageToJSONTyped(value?: Package | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }

    return {
        
        'id': value['id'],
        'name': value['name'],
        'description': value['description'],
        'author_id': value['authorId'],
        'image_url': value['imageUrl'],
        'application_id': value['applicationId'],
        'category_id': value['categoryId'],
        'download_count': value['downloadCount'],
        'last_download': value['lastDownload'] == null ? undefined : ((value['lastDownload'] as any).toISOString()),
        'releases': value['releases'] == null ? undefined : ((value['releases'] as Array<any>).map(PackageReleaseToJSON)),
        'created': value['created'] == null ? undefined : ((value['created']).toISOString()),
        'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()),
    };
}

