/* tslint:disable */
/* eslint-disable */
/**
 * Tribufu API
 * REST API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.1.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';
/**
 * 
 * @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
     */
    imageUrl?: string | null;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    authorId?: string;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    version?: string | null;
    /**
     * 
     * @type {string}
     * @memberof Package
     */
    fileUrl?: string | null;
    /**
     * 
     * @type {number}
     * @memberof Package
     */
    rawSize?: number;
    /**
     * 
     * @type {number}
     * @memberof Package
     */
    downloadCount?: number;
    /**
     * 
     * @type {Date}
     * @memberof Package
     */
    lastDownload?: Date | 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 {
    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'] == null ? undefined : json['name'],
        'description': json['description'] == null ? undefined : json['description'],
        'imageUrl': json['image_url'] == null ? undefined : json['image_url'],
        'authorId': json['author_id'] == null ? undefined : json['author_id'],
        'version': json['version'] == null ? undefined : json['version'],
        'fileUrl': json['file_url'] == null ? undefined : json['file_url'],
        'rawSize': json['raw_size'] == null ? undefined : json['raw_size'],
        'downloadCount': json['download_count'] == null ? undefined : json['download_count'],
        'lastDownload': json['last_download'] == null ? undefined : (new Date(json['last_download'])),
        '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'],
        'image_url': value['imageUrl'],
        'author_id': value['authorId'],
        'version': value['version'],
        'file_url': value['fileUrl'],
        'raw_size': value['rawSize'],
        'download_count': value['downloadCount'],
        'last_download': value['lastDownload'] == null ? undefined : ((value['lastDownload'] as any).toISOString()),
        'created': value['created'] == null ? undefined : ((value['created']).toISOString()),
        'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()),
    };
}

