/* 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 { SupermarketCategory } from './SupermarketCategory'; import { SupermarketCategoryFromJSON, SupermarketCategoryFromJSONTyped, SupermarketCategoryToJSON, } from './SupermarketCategory'; import type { Unit } from './Unit'; import { UnitFromJSON, UnitFromJSONTyped, UnitToJSON, } from './Unit'; import type { Property } from './Property'; import { PropertyFromJSON, PropertyFromJSONTyped, PropertyToJSON, } from './Property'; import type { FoodInheritField } from './FoodInheritField'; import { FoodInheritFieldFromJSON, FoodInheritFieldFromJSONTyped, FoodInheritFieldToJSON, } from './FoodInheritField'; import type { FoodSimple } from './FoodSimple'; import { FoodSimpleFromJSON, FoodSimpleFromJSONTyped, FoodSimpleToJSON, } from './FoodSimple'; import type { RecipeSimple } from './RecipeSimple'; import { RecipeSimpleFromJSON, RecipeSimpleFromJSONTyped, RecipeSimpleToJSON, } from './RecipeSimple'; /** * 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 PatchedFood */ export interface PatchedFood { /** * * @type {number} * @memberof PatchedFood */ id?: number; /** * * @type {string} * @memberof PatchedFood */ name?: string; /** * * @type {string} * @memberof PatchedFood */ pluralName?: string; /** * * @type {string} * @memberof PatchedFood */ description?: string; /** * * @type {string} * @memberof PatchedFood */ readonly shopping?: string; /** * * @type {RecipeSimple} * @memberof PatchedFood */ recipe?: RecipeSimple; /** * * @type {string} * @memberof PatchedFood */ url?: string; /** * * @type {Array} * @memberof PatchedFood */ properties?: Array; /** * * @type {number} * @memberof PatchedFood */ propertiesFoodAmount?: number; /** * * @type {Unit} * @memberof PatchedFood */ propertiesFoodUnit?: Unit; /** * * @type {number} * @memberof PatchedFood */ fdcId?: number; /** * * @type {boolean} * @memberof PatchedFood */ foodOnhand?: boolean; /** * * @type {SupermarketCategory} * @memberof PatchedFood */ supermarketCategory?: SupermarketCategory; /** * * @type {number} * @memberof PatchedFood */ readonly parent?: number; /** * * @type {number} * @memberof PatchedFood */ readonly numchild?: number; /** * * @type {Array} * @memberof PatchedFood */ inheritFields?: Array; /** * Returns a string representation of a tree node and it's ancestors, * e.g. 'Cuisine > Asian > Chinese > Catonese'. * @type {string} * @memberof PatchedFood */ readonly fullName?: string; /** * * @type {boolean} * @memberof PatchedFood */ ignoreShopping?: boolean; /** * * @type {Array} * @memberof PatchedFood */ substitute?: Array; /** * * @type {boolean} * @memberof PatchedFood */ substituteSiblings?: boolean; /** * * @type {boolean} * @memberof PatchedFood */ substituteChildren?: boolean; /** * * @type {boolean} * @memberof PatchedFood */ readonly substituteOnhand?: boolean; /** * * @type {Array} * @memberof PatchedFood */ childInheritFields?: Array; /** * * @type {string} * @memberof PatchedFood */ openDataSlug?: string; } /** * Check if a given object implements the PatchedFood interface. */ export function instanceOfPatchedFood(value: object): value is PatchedFood { return true; } export function PatchedFoodFromJSON(json: any): PatchedFood { return PatchedFoodFromJSONTyped(json, false); } export function PatchedFoodFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchedFood { if (json == null) { return json; } return { 'id': json['id'] == null ? undefined : json['id'], 'name': json['name'] == null ? undefined : json['name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'], 'description': json['description'] == null ? undefined : json['description'], 'shopping': json['shopping'] == null ? undefined : 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).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'] == null ? undefined : json['parent'], 'numchild': json['numchild'] == null ? undefined : json['numchild'], 'inheritFields': json['inherit_fields'] == null ? undefined : ((json['inherit_fields'] as Array).map(FoodInheritFieldFromJSON)), 'fullName': json['full_name'] == null ? undefined : json['full_name'], 'ignoreShopping': json['ignore_shopping'] == null ? undefined : json['ignore_shopping'], 'substitute': json['substitute'] == null ? undefined : ((json['substitute'] as Array).map(FoodSimpleFromJSON)), 'substituteSiblings': json['substitute_siblings'] == null ? undefined : json['substitute_siblings'], 'substituteChildren': json['substitute_children'] == null ? undefined : json['substitute_children'], 'substituteOnhand': json['substitute_onhand'] == null ? undefined : json['substitute_onhand'], 'childInheritFields': json['child_inherit_fields'] == null ? undefined : ((json['child_inherit_fields'] as Array).map(FoodInheritFieldFromJSON)), 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'], }; } export function PatchedFoodToJSON(value?: Omit | null): any { if (value == null) { return value; } return { 'id': value['id'], '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).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).map(FoodInheritFieldToJSON)), 'ignore_shopping': value['ignoreShopping'], 'substitute': value['substitute'] == null ? undefined : ((value['substitute'] as Array).map(FoodSimpleToJSON)), 'substitute_siblings': value['substituteSiblings'], 'substitute_children': value['substituteChildren'], 'child_inherit_fields': value['childInheritFields'] == null ? undefined : ((value['childInheritFields'] as Array).map(FoodInheritFieldToJSON)), 'open_data_slug': value['openDataSlug'], }; }