/* 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 { FoodInheritFieldRequest } from './FoodInheritFieldRequest'; import { FoodInheritFieldRequestFromJSON, FoodInheritFieldRequestFromJSONTyped, FoodInheritFieldRequestToJSON, } from './FoodInheritFieldRequest'; import type { FoodSimpleRequest } from './FoodSimpleRequest'; import { FoodSimpleRequestFromJSON, FoodSimpleRequestFromJSONTyped, FoodSimpleRequestToJSON, } from './FoodSimpleRequest'; import type { PropertyRequest } from './PropertyRequest'; import { PropertyRequestFromJSON, PropertyRequestFromJSONTyped, PropertyRequestToJSON, } from './PropertyRequest'; import type { RecipeSimpleRequest } from './RecipeSimpleRequest'; import { RecipeSimpleRequestFromJSON, RecipeSimpleRequestFromJSONTyped, RecipeSimpleRequestToJSON, } from './RecipeSimpleRequest'; import type { SupermarketCategoryRequest } from './SupermarketCategoryRequest'; import { SupermarketCategoryRequestFromJSON, SupermarketCategoryRequestFromJSONTyped, SupermarketCategoryRequestToJSON, } from './SupermarketCategoryRequest'; import type { UnitRequest } from './UnitRequest'; import { UnitRequestFromJSON, UnitRequestFromJSONTyped, UnitRequestToJSON, } from './UnitRequest'; /** * 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 FoodRequest */ export interface FoodRequest { /** * * @type {string} * @memberof FoodRequest */ name: string; /** * * @type {string} * @memberof FoodRequest */ pluralName?: string; /** * * @type {string} * @memberof FoodRequest */ description?: string; /** * * @type {RecipeSimpleRequest} * @memberof FoodRequest */ recipe?: RecipeSimpleRequest; /** * * @type {string} * @memberof FoodRequest */ url?: string; /** * * @type {Array} * @memberof FoodRequest */ properties?: Array; /** * * @type {number} * @memberof FoodRequest */ propertiesFoodAmount?: number; /** * * @type {UnitRequest} * @memberof FoodRequest */ propertiesFoodUnit?: UnitRequest; /** * * @type {number} * @memberof FoodRequest */ fdcId?: number; /** * * @type {boolean} * @memberof FoodRequest */ foodOnhand?: boolean; /** * * @type {SupermarketCategoryRequest} * @memberof FoodRequest */ supermarketCategory?: SupermarketCategoryRequest; /** * * @type {Array} * @memberof FoodRequest */ inheritFields?: Array; /** * * @type {boolean} * @memberof FoodRequest */ ignoreShopping?: boolean; /** * * @type {Array} * @memberof FoodRequest */ substitute?: Array; /** * * @type {boolean} * @memberof FoodRequest */ substituteSiblings?: boolean; /** * * @type {boolean} * @memberof FoodRequest */ substituteChildren?: boolean; /** * * @type {Array} * @memberof FoodRequest */ childInheritFields?: Array; /** * * @type {string} * @memberof FoodRequest */ openDataSlug?: string; /** * * @type {number} * @memberof FoodRequest */ id?: number; } /** * Check if a given object implements the FoodRequest interface. */ export function instanceOfFoodRequest(value: object): boolean { if (!('name' in value)) return false; return true; } export function FoodRequestFromJSON(json: any): FoodRequest { return FoodRequestFromJSONTyped(json, false); } export function FoodRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): FoodRequest { if (json == null) { return json; } return { 'name': json['name'], 'pluralName': json['plural_name'] == null ? undefined : json['plural_name'], 'description': json['description'] == null ? undefined : json['description'], 'recipe': json['recipe'] == null ? undefined : RecipeSimpleRequestFromJSON(json['recipe']), 'url': json['url'] == null ? undefined : json['url'], 'properties': json['properties'] == null ? undefined : ((json['properties'] as Array).map(PropertyRequestFromJSON)), 'propertiesFoodAmount': json['properties_food_amount'] == null ? undefined : json['properties_food_amount'], 'propertiesFoodUnit': json['properties_food_unit'] == null ? undefined : UnitRequestFromJSON(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 : SupermarketCategoryRequestFromJSON(json['supermarket_category']), 'inheritFields': json['inherit_fields'] == null ? undefined : ((json['inherit_fields'] as Array).map(FoodInheritFieldRequestFromJSON)), 'ignoreShopping': json['ignore_shopping'] == null ? undefined : json['ignore_shopping'], 'substitute': json['substitute'] == null ? undefined : ((json['substitute'] as Array).map(FoodSimpleRequestFromJSON)), 'substituteSiblings': json['substitute_siblings'] == null ? undefined : json['substitute_siblings'], 'substituteChildren': json['substitute_children'] == null ? undefined : json['substitute_children'], 'childInheritFields': json['child_inherit_fields'] == null ? undefined : ((json['child_inherit_fields'] as Array).map(FoodInheritFieldRequestFromJSON)), 'openDataSlug': json['open_data_slug'] == null ? undefined : json['open_data_slug'], 'id': json['id'] == null ? undefined : json['id'], }; } export function FoodRequestToJSON(value?: FoodRequest | null): any { if (value == null) { return value; } return { 'name': value['name'], 'plural_name': value['pluralName'], 'description': value['description'], 'recipe': RecipeSimpleRequestToJSON(value['recipe']), 'url': value['url'], 'properties': value['properties'] == null ? undefined : ((value['properties'] as Array).map(PropertyRequestToJSON)), 'properties_food_amount': value['propertiesFoodAmount'], 'properties_food_unit': UnitRequestToJSON(value['propertiesFoodUnit']), 'fdc_id': value['fdcId'], 'food_onhand': value['foodOnhand'], 'supermarket_category': SupermarketCategoryRequestToJSON(value['supermarketCategory']), 'inherit_fields': value['inheritFields'] == null ? undefined : ((value['inheritFields'] as Array).map(FoodInheritFieldRequestToJSON)), 'ignore_shopping': value['ignoreShopping'], 'substitute': value['substitute'] == null ? undefined : ((value['substitute'] as Array).map(FoodSimpleRequestToJSON)), 'substitute_siblings': value['substituteSiblings'], 'substitute_children': value['substituteChildren'], 'child_inherit_fields': value['childInheritFields'] == null ? undefined : ((value['childInheritFields'] as Array).map(FoodInheritFieldRequestToJSON)), 'open_data_slug': value['openDataSlug'], 'id': value['id'], }; }