Files
recipes/vue3/models/Food.ts
2024-04-18 10:56:15 -05:00

318 lines
9.2 KiB
TypeScript

/* tslint:disable */
/* eslint-disable */
/**
* Tandoor
* Tandoor API Docs
*
* The version of the OpenAPI document: 0.0.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 { FoodInheritField } from './FoodInheritField';
import {
FoodInheritFieldFromJSON,
FoodInheritFieldFromJSONTyped,
FoodInheritFieldToJSON,
} from './FoodInheritField';
import type { FoodSimple } from './FoodSimple';
import {
FoodSimpleFromJSON,
FoodSimpleFromJSONTyped,
FoodSimpleToJSON,
} from './FoodSimple';
import type { Property } from './Property';
import {
PropertyFromJSON,
PropertyFromJSONTyped,
PropertyToJSON,
} from './Property';
import type { RecipeSimple } from './RecipeSimple';
import {
RecipeSimpleFromJSON,
RecipeSimpleFromJSONTyped,
RecipeSimpleToJSON,
} from './RecipeSimple';
import type { SupermarketCategory } from './SupermarketCategory';
import {
SupermarketCategoryFromJSON,
SupermarketCategoryFromJSONTyped,
SupermarketCategoryToJSON,
} from './SupermarketCategory';
import type { Unit } from './Unit';
import {
UnitFromJSON,
UnitFromJSONTyped,
UnitToJSON,
} from './Unit';
/**
* Moves `UniqueValidator`'s from the validation stage to the save stage.
* It solves the problem with nested validation for unique fields on update.
*
* If you want more details, you can read related issues and articles:
* https://github.com/beda-software/drf-writable-nested/issues/1
* http://www.django-rest-framework.org/api-guide/validators/#updating-nested-serializers
*
* Example of usage:
* ```
* class Child(models.Model):
* field = models.CharField(unique=True)
*
*
* class Parent(models.Model):
* child = models.ForeignKey('Child')
*
*
* class ChildSerializer(UniqueFieldsMixin, serializers.ModelSerializer):
* class Meta:
* model = Child
*
*
* class ParentSerializer(NestedUpdateMixin, serializers.ModelSerializer):
* child = ChildSerializer()
*
* class Meta:
* model = Parent
* ```
*
* Note: `UniqueFieldsMixin` must be applied only on the serializer
* which has unique fields.
*
* Note: When you are using both mixins
* (`UniqueFieldsMixin` and `NestedCreateMixin` or `NestedUpdateMixin`)
* you should put `UniqueFieldsMixin` ahead.
* @export
* @interface Food
*/
export interface Food {
/**
*
* @type {number}
* @memberof Food
*/
readonly id: number;
/**
*
* @type {string}
* @memberof Food
*/
name: string;
/**
*
* @type {string}
* @memberof Food
*/
pluralName?: string;
/**
*
* @type {string}
* @memberof Food
*/
description?: string;
/**
*
* @type {string}
* @memberof Food
*/
readonly shopping: string;
/**
*
* @type {RecipeSimple}
* @memberof Food
*/
recipe?: RecipeSimple;
/**
*
* @type {string}
* @memberof Food
*/
url?: string;
/**
*
* @type {Array<Property>}
* @memberof Food
*/
properties?: Array<Property>;
/**
*
* @type {number}
* @memberof Food
*/
propertiesFoodAmount?: number;
/**
*
* @type {Unit}
* @memberof Food
*/
propertiesFoodUnit?: Unit;
/**
*
* @type {number}
* @memberof Food
*/
fdcId?: number;
/**
*
* @type {boolean}
* @memberof Food
*/
foodOnhand?: boolean;
/**
*
* @type {SupermarketCategory}
* @memberof Food
*/
supermarketCategory?: SupermarketCategory;
/**
*
* @type {number}
* @memberof Food
*/
readonly parent: number;
/**
*
* @type {number}
* @memberof Food
*/
readonly numchild: number;
/**
*
* @type {Array<FoodInheritField>}
* @memberof Food
*/
inheritFields?: Array<FoodInheritField>;
/**
* Returns a string representation of a tree node and it's ancestors,
* e.g. 'Cuisine > Asian > Chinese > Catonese'.
* @type {string}
* @memberof Food
*/
readonly fullName: string;
/**
*
* @type {boolean}
* @memberof Food
*/
ignoreShopping?: boolean;
/**
*
* @type {Array<FoodSimple>}
* @memberof Food
*/
substitute?: Array<FoodSimple>;
/**
*
* @type {boolean}
* @memberof Food
*/
substituteSiblings?: boolean;
/**
*
* @type {boolean}
* @memberof Food
*/
substituteChildren?: boolean;
/**
*
* @type {boolean}
* @memberof Food
*/
readonly substituteOnhand: boolean;
/**
*
* @type {Array<FoodInheritField>}
* @memberof Food
*/
childInheritFields?: Array<FoodInheritField>;
/**
*
* @type {string}
* @memberof Food
*/
openDataSlug?: string;
}
/**
* Check if a given object implements the Food interface.
*/
export function instanceOfFood(value: object): boolean {
if (!('id' in value)) return false;
if (!('name' in value)) return false;
if (!('shopping' in value)) return false;
if (!('parent' in value)) return false;
if (!('numchild' in value)) return false;
if (!('fullName' in value)) return false;
if (!('substituteOnhand' in value)) return false;
return true;
}
export function FoodFromJSON(json: any): Food {
return FoodFromJSONTyped(json, false);
}
export function FoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): Food {
if (json == null) {
return json;
}
return {
'id': json['id'],
'name': json['name'],
'pluralName': json['plural_name'] == null ? undefined : json['plural_name'],
'description': json['description'] == null ? undefined : json['description'],
'shopping': json['shopping'],
'recipe': json['recipe'] == null ? undefined : RecipeSimpleFromJSON(json['recipe']),
'url': json['url'] == null ? undefined : json['url'],
'properties': json['properties'] == null ? undefined : ((json['properties'] as Array<any>).map(PropertyFromJSON)),
'propertiesFoodAmount': json['properties_food_amount'] == null ? undefined : json['properties_food_amount'],
'propertiesFoodUnit': json['properties_food_unit'] == null ? undefined : UnitFromJSON(json['properties_food_unit']),
'fdcId': json['fdc_id'] == null ? undefined : json['fdc_id'],
'foodOnhand': json['food_onhand'] == null ? undefined : json['food_onhand'],
'supermarketCategory': json['supermarket_category'] == null ? undefined : SupermarketCategoryFromJSON(json['supermarket_category']),
'parent': json['parent'],
'numchild': json['numchild'],
'inheritFields': json['inherit_fields'] == null ? undefined : ((json['inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)),
'fullName': json['full_name'],
'ignoreShopping': json['ignore_shopping'] == null ? undefined : json['ignore_shopping'],
'substitute': json['substitute'] == null ? undefined : ((json['substitute'] as Array<any>).map(FoodSimpleFromJSON)),
'substituteSiblings': json['substitute_siblings'] == null ? undefined : json['substitute_siblings'],
'substituteChildren': json['substitute_children'] == null ? undefined : json['substitute_children'],
'substituteOnhand': json['substitute_onhand'],
'childInheritFields': json['child_inherit_fields'] == null ? undefined : ((json['child_inherit_fields'] as Array<any>).map(FoodInheritFieldFromJSON)),
'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'],
};
}
export function FoodToJSON(value?: Omit<Food, 'id'|'shopping'|'parent'|'numchild'|'full_name'|'substitute_onhand'> | null): any {
if (value == null) {
return value;
}
return {
'name': value['name'],
'plural_name': value['pluralName'],
'description': value['description'],
'recipe': RecipeSimpleToJSON(value['recipe']),
'url': value['url'],
'properties': value['properties'] == null ? undefined : ((value['properties'] as Array<any>).map(PropertyToJSON)),
'properties_food_amount': value['propertiesFoodAmount'],
'properties_food_unit': UnitToJSON(value['propertiesFoodUnit']),
'fdc_id': value['fdcId'],
'food_onhand': value['foodOnhand'],
'supermarket_category': SupermarketCategoryToJSON(value['supermarketCategory']),
'inherit_fields': value['inheritFields'] == null ? undefined : ((value['inheritFields'] as Array<any>).map(FoodInheritFieldToJSON)),
'ignore_shopping': value['ignoreShopping'],
'substitute': value['substitute'] == null ? undefined : ((value['substitute'] as Array<any>).map(FoodSimpleToJSON)),
'substitute_siblings': value['substituteSiblings'],
'substitute_children': value['substituteChildren'],
'child_inherit_fields': value['childInheritFields'] == null ? undefined : ((value['childInheritFields'] as Array<any>).map(FoodInheritFieldToJSON)),
'open_data_slug': value['openDataSlug'],
};
}