/* 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 { ProductType } from './ProductType';
import {
    ProductTypeFromJSON,
    ProductTypeFromJSONTyped,
    ProductTypeToJSON,
    ProductTypeToJSONTyped,
} from './ProductType';
import type { ProductPrice } from './ProductPrice';
import {
    ProductPriceFromJSON,
    ProductPriceFromJSONTyped,
    ProductPriceToJSON,
    ProductPriceToJSONTyped,
} from './ProductPrice';

/**
 * 
 * @export
 * @interface Product
 */
export interface Product {
    /**
     * 
     * @type {string}
     * @memberof Product
     */
    id?: string;
    /**
     * 
     * @type {string}
     * @memberof Product
     */
    name: string | null;
    /**
     * 
     * @type {string}
     * @memberof Product
     */
    description?: string | null;
    /**
     * 
     * @type {ProductType}
     * @memberof Product
     */
    type?: ProductType;
    /**
     * 
     * @type {string}
     * @memberof Product
     */
    slug?: string | null;
    /**
     * 
     * @type {string}
     * @memberof Product
     */
    imageUrl?: string | null;
    /**
     * 
     * @type {boolean}
     * @memberof Product
     */
    isPhysical?: boolean;
    /**
     * 
     * @type {Array<ProductPrice>}
     * @memberof Product
     */
    prices?: Array<ProductPrice> | null;
    /**
     * 
     * @type {Date}
     * @memberof Product
     */
    created?: Date;
    /**
     * 
     * @type {Date}
     * @memberof Product
     */
    updated?: Date | null;
}



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

export function ProductFromJSON(json: any): Product {
    return ProductFromJSONTyped(json, false);
}

export function ProductFromJSONTyped(json: any, ignoreDiscriminator: boolean): Product {
    if (json == null) {
        return json;
    }
    return {
        
        'id': json['id'] == null ? undefined : json['id'],
        'name': json['name'],
        'description': json['description'] == null ? undefined : json['description'],
        'type': json['type'] == null ? undefined : ProductTypeFromJSON(json['type']),
        'slug': json['slug'] == null ? undefined : json['slug'],
        'imageUrl': json['image_url'] == null ? undefined : json['image_url'],
        'isPhysical': json['is_physical'] == null ? undefined : json['is_physical'],
        'prices': json['prices'] == null ? undefined : ((json['prices'] as Array<any>).map(ProductPriceFromJSON)),
        'created': json['created'] == null ? undefined : (new Date(json['created'])),
        'updated': json['updated'] == null ? undefined : (new Date(json['updated'])),
    };
}

export function ProductToJSON(json: any): Product {
    return ProductToJSONTyped(json, false);
}

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

    return {
        
        'id': value['id'],
        'name': value['name'],
        'description': value['description'],
        'type': ProductTypeToJSON(value['type']),
        'slug': value['slug'],
        'image_url': value['imageUrl'],
        'is_physical': value['isPhysical'],
        'prices': value['prices'] == null ? undefined : ((value['prices'] as Array<any>).map(ProductPriceToJSON)),
        'created': value['created'] == null ? undefined : ((value['created']).toISOString()),
        'updated': value['updated'] == null ? undefined : ((value['updated'] as any).toISOString()),
    };
}

