diff --git a/cookbook/urls.py b/cookbook/urls.py index 4ea0e2f3af..4bb3db068d 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -111,6 +111,7 @@ def extend(self, r): path('api/get_recipe_file//', api.get_recipe_file, name='api_get_recipe_file'), path('api/sync_all/', api.sync_all, name='api_sync'), path('api/recipe-from-source/', api.RecipeUrlImportView.as_view(), name='api_recipe_from_source'), + path('api/image-to-recipe/', api.ImageToRecipeView.as_view(), name='api_image_to_recipe'), path('api/ingredient-from-string/', api.ingredient_from_string, name='api_ingredient_from_string'), path('api/share-link/', api.share_link, name='api_share_link'), path('api/reset-food-inheritance/', api.reset_food_inheritance, name='api_reset_food_inheritance'), diff --git a/cookbook/views/api.py b/cookbook/views/api.py index f3e449f79d..feadeeceb7 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -39,6 +39,7 @@ from django_scopes import scopes_disabled from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_view, OpenApiExample, inline_serializer +from google import generativeai from icalendar import Calendar, Event from oauth2_provider.models import AccessToken from recipe_scrapers import scrape_html @@ -1741,7 +1742,7 @@ def post(self, request, *args, **kwargs): if re.match('^(.)*/recipe/[0-9]+/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$', url): recipe_json = requests.get( url.replace('/recipe/', '/api/recipe/').replace(re.split('/recipe/[0-9]+', url)[1], - '') + '?share=' + '') + '?share=' + re.split('/recipe/[0-9]+', url)[1].replace('/', '')).json() recipe_json = clean_dict(recipe_json, 'id') serialized_recipe = RecipeExportSerializer(data=recipe_json, context={'request': request}) @@ -1811,28 +1812,63 @@ def post(self, request, *args, **kwargs): class ImageToRecipeView(APIView): - serializer_class = ImportImageSerializer - http_method_names = ['post', 'options'] - # parser_classes = [MultiPartParser] + # serializer_class = ImportImageSerializer + # http_method_names = ['post', 'options'] + parser_classes = [MultiPartParser] throttle_classes = [RecipeImportThrottle] permission_classes = [CustomIsUser & CustomTokenHasReadWriteScope] + @extend_schema(request=ImportImageSerializer(many=False), responses=RecipeFromSourceResponseSerializer(many=False)) def post(self, request, *args, **kwargs): """ """ + print('method called') serializer = ImportImageSerializer(data=request.data, partial=True) if serializer.is_valid(): - # generativeai.configure(api_key=GOOGLE_AI_API_KEY) + generativeai.configure(api_key=GOOGLE_AI_API_KEY) + + model = generativeai.GenerativeModel('gemini-1.5-flash-latest') + img = PIL.Image.open(serializer.validated_data['image']) + # response = model.generate_content([ + # "The Image given is a photograph or screenshot taken of a cooking recipe. The data contained in the image should be converted to a structured json format adhering to the specification given in the schema.org/recipes schema. It is not allowed to make any data up, the response must only contain data given in the original image. The response must be a plain json object without any formatting characters or other unnecessary information. If unsure please return an empty json object {}. Do not wrap the response in a markdown codeblock (like ```json ```)", + # img], stream=True) + #response.resolve() + + #response_text = response.text + #response_text.replace('```json', '') + #response_text.replace('```', '') + + response_text = '{"@context": "https://schema.org", "@type": "Recipe", "name": "Pennettine mit Nüssen und Zitrone", "prepTime": "PT25M", "recipeYield": "4", "ingredients": [{"@type": "Quantity", "name": "BARILLA Pennettine", "amount": 500, "unitCode": "G"}, {"@type": "Quantity", "name": "Walnußkerne", "amount": 100, "unitCode": "G"}, {"@type": "Quantity", "name": "Sahne", "amount": "1/2-1", "unitCode": "CUP"}, {"@type": "Quantity", "name": "Butter", "amount": 20, "unitCode": "G"}, {"@type": "Quantity", "name": "Zucker", "amount": 10, "unitCode": "G"}, {"@type": "Quantity", "name": "gemahlener Zimt", "amount": 1, "unitCode": "UNIT"}, {"@type": "Quantity", "name": "Zitrone, unbehandelt", "amount": "1/2-1", "unitCode": "UNIT"}, {"@type": "Quantity", "name": "Salz", "amount": null, "unitCode": null}, {"@type": "Quantity", "name": "frisch gemahlener Pfeffer", "amount": null, "unitCode": null}], "recipeInstructions": [{"@type": "HowToStep", "text": "Walnußkerne hacken, in eine große Schüssel geben, Zimt und Zucker mit einer Prise Salz und Pfeffer untermischen."}, {"@type": "HowToStep", "text": "Die Zitrone waschen, Schale einer 1/2 Zitrone abreiben, dann zusammen mit den anderen Zutaten in die Schüssel geben und zuletzt in Stückchen geschnittene Butter untermischen."}, {"@type": "HowToStep", "text": "Die Mischung schmelzen, indem Sie die Schüssel auf den Topf mit dem kochenden Pasta-Wasser stellen und hin und wieder umrühren."}, {"@type": "HowToStep", "text": "Sahne dazugeben und die Zutaten mit einem Schneebesen verrühren."}, {"@type": "HowToStep", "text": "BARILLA Pennettine in reichlich Salzwasser al dente kochen, abgießen und mit der Sauce anrichten."}]}' + + print(response_text) + + try: + data_json = json.loads(response_text) + # if '@context' not in data_json: + # data_json['@context'] = 'https://schema.org' + # if '@type' not in data_json: + # data_json['@type'] = 'Recipe' + data = "" + #data = "" + + scrape = scrape_html(html=data, org_url='https://urlnotfound.none', supported_only=False) + print(str(scrape.ingredients())) + if scrape: + response = {} + response['recipe'] = helper.get_from_scraper(scrape, request) + response['images'] = [] + response['duplicates'] = [] + return Response(RecipeFromSourceResponseSerializer(context={'request': request}).to_representation(response), status=status.HTTP_200_OK) + except JSONDecodeError: + traceback.print_exc() + print('Jsond dcode error') + pass - # model = generativeai.GenerativeModel('gemini-1.5-flash-latest') - # img = PIL.Image.open('') - # response = model.generate_content(["The image contains a recipe. Please return all data contained in the recipe formatted according to the schema.org specification for recipes", img], stream=True) - # response.resolve() - Response({'msg': 'SUCCESS'}) + # TODO proper serializer response + return Response({'msg': 'PARSE_FAIL', 'response': response_text}) else: - Response({'msg': serializer.errors}) - return Response({'test': 'test'}) + return Response({'msg': serializer.errors}) @extend_schema( diff --git a/vue3/src/composables/useFileApi.ts b/vue3/src/composables/useFileApi.ts index 15e21b7995..a05aab5006 100644 --- a/vue3/src/composables/useFileApi.ts +++ b/vue3/src/composables/useFileApi.ts @@ -1,7 +1,7 @@ import {useDjangoUrls} from "@/composables/useDjangoUrls"; import {ref} from "vue"; import {getCookie} from "@/utils/cookie"; -import {RecipeImageFromJSON, UserFile, UserFileFromJSON} from "@/openapi"; +import {RecipeFromJSON, RecipeFromSourceFromJSON, RecipeFromSourceResponseFromJSON, RecipeImageFromJSON, UserFile, UserFileFromJSON} from "@/openapi"; import {ErrorMessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore"; /** @@ -76,5 +76,28 @@ export function useFileApi() { }) } - return {fileApiLoading, createOrUpdateUserFile, updateRecipeImage} + /** + * uploads the given file to the image recognition endpoint + * @param file file object to upload + */ + function convertImageToRecipe(file: File){ + let formData = new FormData() + if (file != null) { + formData.append('image', file) + } + + return fetch(getDjangoUrl(`api/image-to-recipe/`), { + method: 'POST', + headers: {'X-CSRFToken': getCookie('csrftoken')}, + body: formData + }).then(r => { + return r.json().then(r => { + return RecipeFromSourceResponseFromJSON(r) + }) + }).finally(() => { + fileApiLoading.value = false + }) + } + + return {fileApiLoading, createOrUpdateUserFile, updateRecipeImage, convertImageToRecipe} } \ No newline at end of file diff --git a/vue3/src/openapi/.openapi-generator/FILES b/vue3/src/openapi/.openapi-generator/FILES index 8ad5b6b79a..f3ea5c240f 100644 --- a/vue3/src/openapi/.openapi-generator/FILES +++ b/vue3/src/openapi/.openapi-generator/FILES @@ -7,8 +7,6 @@ models/AccessToken.ts models/AuthToken.ts models/AutoMealPlan.ts models/Automation.ts -models/AutomationTypeEnum.ts -models/BaseUnitEnum.ts models/BookmarkletImport.ts models/BookmarkletImportList.ts models/ConnectorConfigConfig.ts @@ -22,7 +20,6 @@ models/FoodInheritField.ts models/FoodShoppingUpdate.ts models/FoodSimple.ts models/Group.ts -models/ImportImage.ts models/ImportLog.ts models/Ingredient.ts models/IngredientString.ts @@ -34,16 +31,6 @@ models/MealPlan.ts models/MealType.ts models/MethodEnum.ts models/NutritionInformation.ts -models/OpenDataCategory.ts -models/OpenDataConversion.ts -models/OpenDataFood.ts -models/OpenDataFoodProperty.ts -models/OpenDataProperty.ts -models/OpenDataStore.ts -models/OpenDataStoreCategory.ts -models/OpenDataUnit.ts -models/OpenDataUnitTypeEnum.ts -models/OpenDataVersion.ts models/PaginatedAutomationList.ts models/PaginatedBookmarkletImportListList.ts models/PaginatedCookLogList.ts @@ -90,13 +77,6 @@ models/PatchedInviteLink.ts models/PatchedKeyword.ts models/PatchedMealPlan.ts models/PatchedMealType.ts -models/PatchedOpenDataCategory.ts -models/PatchedOpenDataConversion.ts -models/PatchedOpenDataFood.ts -models/PatchedOpenDataProperty.ts -models/PatchedOpenDataStore.ts -models/PatchedOpenDataUnit.ts -models/PatchedOpenDataVersion.ts models/PatchedProperty.ts models/PatchedPropertyType.ts models/PatchedRecipe.ts @@ -156,6 +136,7 @@ models/SupermarketCategoryRelation.ts models/Sync.ts models/SyncLog.ts models/ThemeEnum.ts +models/TypeEnum.ts models/Unit.ts models/UnitConversion.ts models/User.ts diff --git a/vue3/src/openapi/apis/ApiApi.ts b/vue3/src/openapi/apis/ApiApi.ts index 37ccc57307..9874f42229 100644 --- a/vue3/src/openapi/apis/ApiApi.ts +++ b/vue3/src/openapi/apis/ApiApi.ts @@ -27,7 +27,6 @@ import type { FoodInheritField, FoodShoppingUpdate, Group, - ImportImage, ImportLog, Ingredient, IngredientString, @@ -36,13 +35,6 @@ import type { Localization, MealPlan, MealType, - OpenDataCategory, - OpenDataConversion, - OpenDataFood, - OpenDataProperty, - OpenDataStore, - OpenDataUnit, - OpenDataVersion, PaginatedAutomationList, PaginatedBookmarkletImportListList, PaginatedCookLogList, @@ -89,13 +81,6 @@ import type { PatchedKeyword, PatchedMealPlan, PatchedMealType, - PatchedOpenDataCategory, - PatchedOpenDataConversion, - PatchedOpenDataFood, - PatchedOpenDataProperty, - PatchedOpenDataStore, - PatchedOpenDataUnit, - PatchedOpenDataVersion, PatchedProperty, PatchedPropertyType, PatchedRecipe, @@ -174,8 +159,6 @@ import { FoodShoppingUpdateToJSON, GroupFromJSON, GroupToJSON, - ImportImageFromJSON, - ImportImageToJSON, ImportLogFromJSON, ImportLogToJSON, IngredientFromJSON, @@ -192,20 +175,6 @@ import { MealPlanToJSON, MealTypeFromJSON, MealTypeToJSON, - OpenDataCategoryFromJSON, - OpenDataCategoryToJSON, - OpenDataConversionFromJSON, - OpenDataConversionToJSON, - OpenDataFoodFromJSON, - OpenDataFoodToJSON, - OpenDataPropertyFromJSON, - OpenDataPropertyToJSON, - OpenDataStoreFromJSON, - OpenDataStoreToJSON, - OpenDataUnitFromJSON, - OpenDataUnitToJSON, - OpenDataVersionFromJSON, - OpenDataVersionToJSON, PaginatedAutomationListFromJSON, PaginatedAutomationListToJSON, PaginatedBookmarkletImportListListFromJSON, @@ -298,20 +267,6 @@ import { PatchedMealPlanToJSON, PatchedMealTypeFromJSON, PatchedMealTypeToJSON, - PatchedOpenDataCategoryFromJSON, - PatchedOpenDataCategoryToJSON, - PatchedOpenDataConversionFromJSON, - PatchedOpenDataConversionToJSON, - PatchedOpenDataFoodFromJSON, - PatchedOpenDataFoodToJSON, - PatchedOpenDataPropertyFromJSON, - PatchedOpenDataPropertyToJSON, - PatchedOpenDataStoreFromJSON, - PatchedOpenDataStoreToJSON, - PatchedOpenDataUnitFromJSON, - PatchedOpenDataUnitToJSON, - PatchedOpenDataVersionFromJSON, - PatchedOpenDataVersionToJSON, PatchedPropertyFromJSON, PatchedPropertyToJSON, PatchedPropertyTypeFromJSON, @@ -684,7 +639,11 @@ export interface ApiGroupRetrieveRequest { } export interface ApiImageToRecipeCreateRequest { - importImage: ImportImage; + image: string; +} + +export interface ApiImageToRecipeCreate2Request { + image: string; } export interface ApiImportLogCreateRequest { @@ -887,164 +846,6 @@ export interface ApiMealTypeUpdateRequest { mealType: Omit; } -export interface ApiOpenDataCategoryCreateRequest { - openDataCategory: Omit; -} - -export interface ApiOpenDataCategoryDestroyRequest { - id: number; -} - -export interface ApiOpenDataCategoryPartialUpdateRequest { - id: number; - patchedOpenDataCategory?: Omit; -} - -export interface ApiOpenDataCategoryRetrieveRequest { - id: number; -} - -export interface ApiOpenDataCategoryUpdateRequest { - id: number; - openDataCategory: Omit; -} - -export interface ApiOpenDataConversionCreateRequest { - openDataConversion: Omit; -} - -export interface ApiOpenDataConversionDestroyRequest { - id: number; -} - -export interface ApiOpenDataConversionPartialUpdateRequest { - id: number; - patchedOpenDataConversion?: Omit; -} - -export interface ApiOpenDataConversionRetrieveRequest { - id: number; -} - -export interface ApiOpenDataConversionUpdateRequest { - id: number; - openDataConversion: Omit; -} - -export interface ApiOpenDataFDCRetrieveRequest { - id: string; -} - -export interface ApiOpenDataFoodCreateRequest { - openDataFood: Omit; -} - -export interface ApiOpenDataFoodDestroyRequest { - id: number; -} - -export interface ApiOpenDataFoodPartialUpdateRequest { - id: number; - patchedOpenDataFood?: Omit; -} - -export interface ApiOpenDataFoodRetrieveRequest { - id: number; -} - -export interface ApiOpenDataFoodUpdateRequest { - id: number; - openDataFood: Omit; -} - -export interface ApiOpenDataPropertyCreateRequest { - openDataProperty: Omit; -} - -export interface ApiOpenDataPropertyDestroyRequest { - id: number; -} - -export interface ApiOpenDataPropertyPartialUpdateRequest { - id: number; - patchedOpenDataProperty?: Omit; -} - -export interface ApiOpenDataPropertyRetrieveRequest { - id: number; -} - -export interface ApiOpenDataPropertyUpdateRequest { - id: number; - openDataProperty: Omit; -} - -export interface ApiOpenDataStoreCreateRequest { - openDataStore: Omit; -} - -export interface ApiOpenDataStoreDestroyRequest { - id: number; -} - -export interface ApiOpenDataStorePartialUpdateRequest { - id: number; - patchedOpenDataStore?: Omit; -} - -export interface ApiOpenDataStoreRetrieveRequest { - id: number; -} - -export interface ApiOpenDataStoreUpdateRequest { - id: number; - openDataStore: Omit; -} - -export interface ApiOpenDataUnitCreateRequest { - openDataUnit: Omit; -} - -export interface ApiOpenDataUnitDestroyRequest { - id: number; -} - -export interface ApiOpenDataUnitPartialUpdateRequest { - id: number; - patchedOpenDataUnit?: Omit; -} - -export interface ApiOpenDataUnitRetrieveRequest { - id: number; -} - -export interface ApiOpenDataUnitUpdateRequest { - id: number; - openDataUnit: Omit; -} - -export interface ApiOpenDataVersionCreateRequest { - openDataVersion: OpenDataVersion; -} - -export interface ApiOpenDataVersionDestroyRequest { - id: number; -} - -export interface ApiOpenDataVersionPartialUpdateRequest { - id: number; - patchedOpenDataVersion?: PatchedOpenDataVersion; -} - -export interface ApiOpenDataVersionRetrieveRequest { - id: number; -} - -export interface ApiOpenDataVersionUpdateRequest { - id: number; - openDataVersion: OpenDataVersion; -} - export interface ApiPropertyCreateRequest { property: Property; } @@ -4127,11 +3928,11 @@ export class ApiApi extends runtime.BaseAPI { /** */ - async apiImageToRecipeCreateRaw(requestParameters: ApiImageToRecipeCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['importImage'] == null) { + async apiImageToRecipeCreateRaw(requestParameters: ApiImageToRecipeCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['image'] == null) { throw new runtime.RequiredError( - 'importImage', - 'Required parameter "importImage" was null or undefined when calling apiImageToRecipeCreate().' + 'image', + 'Required parameter "image" was null or undefined when calling apiImageToRecipeCreate().' ); } @@ -4139,30 +3940,100 @@ export class ApiApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['Content-Type'] = 'application/json'; - if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication } + const consumes: runtime.Consume[] = [ + { contentType: 'multipart/form-data' }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); + } + + if (requestParameters['image'] != null) { + formParams.append('image', requestParameters['image'] as any); + } + const response = await this.request({ path: `/api/image-to-recipe`, method: 'POST', headers: headerParameters, query: queryParameters, - body: ImportImageToJSON(requestParameters['importImage']), + body: formParams, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => ImportImageFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => RecipeFromSourceResponseFromJSON(jsonValue)); } /** */ - async apiImageToRecipeCreate(requestParameters: ApiImageToRecipeCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async apiImageToRecipeCreate(requestParameters: ApiImageToRecipeCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.apiImageToRecipeCreateRaw(requestParameters, initOverrides); return await response.value(); } + /** + */ + async apiImageToRecipeCreate2Raw(requestParameters: ApiImageToRecipeCreate2Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['image'] == null) { + throw new runtime.RequiredError( + 'image', + 'Required parameter "image" was null or undefined when calling apiImageToRecipeCreate2().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication + } + + const consumes: runtime.Consume[] = [ + { contentType: 'multipart/form-data' }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); + } + + if (requestParameters['image'] != null) { + formParams.append('image', requestParameters['image'] as any); + } + + const response = await this.request({ + path: `/api/image-to-recipe/`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: formParams, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => RecipeFromSourceResponseFromJSON(jsonValue)); + } + + /** + */ + async apiImageToRecipeCreate2(requestParameters: ApiImageToRecipeCreate2Request, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.apiImageToRecipeCreate2Raw(requestParameters, initOverrides); + return await response.value(); + } + /** * function to handle files passed by application importer */ @@ -5904,1593 +5775,6 @@ export class ApiApi extends runtime.BaseAPI { return await response.value(); } - /** - */ - async apiOpenDataCategoryCreateRaw(requestParameters: ApiOpenDataCategoryCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['openDataCategory'] == null) { - throw new runtime.RequiredError( - 'openDataCategory', - 'Required parameter "openDataCategory" was null or undefined when calling apiOpenDataCategoryCreate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-category/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: OpenDataCategoryToJSON(requestParameters['openDataCategory']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataCategoryFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataCategoryCreate(requestParameters: ApiOpenDataCategoryCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataCategoryCreateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataCategoryDestroyRaw(requestParameters: ApiOpenDataCategoryDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataCategoryDestroy().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-category/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataCategoryDestroy(requestParameters: ApiOpenDataCategoryDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataCategoryDestroyRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataCategoryListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-category/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OpenDataCategoryFromJSON)); - } - - /** - */ - async apiOpenDataCategoryList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.apiOpenDataCategoryListRaw(initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataCategoryPartialUpdateRaw(requestParameters: ApiOpenDataCategoryPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataCategoryPartialUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-category/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PATCH', - headers: headerParameters, - query: queryParameters, - body: PatchedOpenDataCategoryToJSON(requestParameters['patchedOpenDataCategory']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataCategoryFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataCategoryPartialUpdate(requestParameters: ApiOpenDataCategoryPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataCategoryPartialUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataCategoryRetrieveRaw(requestParameters: ApiOpenDataCategoryRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataCategoryRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-category/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataCategoryFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataCategoryRetrieve(requestParameters: ApiOpenDataCategoryRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataCategoryRetrieveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataCategoryUpdateRaw(requestParameters: ApiOpenDataCategoryUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataCategoryUpdate().' - ); - } - - if (requestParameters['openDataCategory'] == null) { - throw new runtime.RequiredError( - 'openDataCategory', - 'Required parameter "openDataCategory" was null or undefined when calling apiOpenDataCategoryUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-category/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: OpenDataCategoryToJSON(requestParameters['openDataCategory']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataCategoryFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataCategoryUpdate(requestParameters: ApiOpenDataCategoryUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataCategoryUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataConversionCreateRaw(requestParameters: ApiOpenDataConversionCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['openDataConversion'] == null) { - throw new runtime.RequiredError( - 'openDataConversion', - 'Required parameter "openDataConversion" was null or undefined when calling apiOpenDataConversionCreate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-conversion/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: OpenDataConversionToJSON(requestParameters['openDataConversion']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataConversionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataConversionCreate(requestParameters: ApiOpenDataConversionCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataConversionCreateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataConversionDestroyRaw(requestParameters: ApiOpenDataConversionDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataConversionDestroy().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-conversion/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataConversionDestroy(requestParameters: ApiOpenDataConversionDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataConversionDestroyRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataConversionListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-conversion/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OpenDataConversionFromJSON)); - } - - /** - */ - async apiOpenDataConversionList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.apiOpenDataConversionListRaw(initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataConversionPartialUpdateRaw(requestParameters: ApiOpenDataConversionPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataConversionPartialUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-conversion/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PATCH', - headers: headerParameters, - query: queryParameters, - body: PatchedOpenDataConversionToJSON(requestParameters['patchedOpenDataConversion']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataConversionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataConversionPartialUpdate(requestParameters: ApiOpenDataConversionPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataConversionPartialUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataConversionRetrieveRaw(requestParameters: ApiOpenDataConversionRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataConversionRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-conversion/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataConversionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataConversionRetrieve(requestParameters: ApiOpenDataConversionRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataConversionRetrieveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataConversionUpdateRaw(requestParameters: ApiOpenDataConversionUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataConversionUpdate().' - ); - } - - if (requestParameters['openDataConversion'] == null) { - throw new runtime.RequiredError( - 'openDataConversion', - 'Required parameter "openDataConversion" was null or undefined when calling apiOpenDataConversionUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-conversion/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: OpenDataConversionToJSON(requestParameters['openDataConversion']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataConversionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataConversionUpdate(requestParameters: ApiOpenDataConversionUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataConversionUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataFDCRetrieveRaw(requestParameters: ApiOpenDataFDCRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataFDCRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-FDC/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataFDCRetrieve(requestParameters: ApiOpenDataFDCRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataFDCRetrieveRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataFoodCreateRaw(requestParameters: ApiOpenDataFoodCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['openDataFood'] == null) { - throw new runtime.RequiredError( - 'openDataFood', - 'Required parameter "openDataFood" was null or undefined when calling apiOpenDataFoodCreate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-food/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: OpenDataFoodToJSON(requestParameters['openDataFood']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataFoodFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataFoodCreate(requestParameters: ApiOpenDataFoodCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataFoodCreateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataFoodDestroyRaw(requestParameters: ApiOpenDataFoodDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataFoodDestroy().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-food/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataFoodDestroy(requestParameters: ApiOpenDataFoodDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataFoodDestroyRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataFoodListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-food/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OpenDataFoodFromJSON)); - } - - /** - */ - async apiOpenDataFoodList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.apiOpenDataFoodListRaw(initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataFoodPartialUpdateRaw(requestParameters: ApiOpenDataFoodPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataFoodPartialUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-food/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PATCH', - headers: headerParameters, - query: queryParameters, - body: PatchedOpenDataFoodToJSON(requestParameters['patchedOpenDataFood']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataFoodFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataFoodPartialUpdate(requestParameters: ApiOpenDataFoodPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataFoodPartialUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataFoodRetrieveRaw(requestParameters: ApiOpenDataFoodRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataFoodRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-food/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataFoodFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataFoodRetrieve(requestParameters: ApiOpenDataFoodRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataFoodRetrieveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataFoodUpdateRaw(requestParameters: ApiOpenDataFoodUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataFoodUpdate().' - ); - } - - if (requestParameters['openDataFood'] == null) { - throw new runtime.RequiredError( - 'openDataFood', - 'Required parameter "openDataFood" was null or undefined when calling apiOpenDataFoodUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-food/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: OpenDataFoodToJSON(requestParameters['openDataFood']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataFoodFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataFoodUpdate(requestParameters: ApiOpenDataFoodUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataFoodUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataPropertyCreateRaw(requestParameters: ApiOpenDataPropertyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['openDataProperty'] == null) { - throw new runtime.RequiredError( - 'openDataProperty', - 'Required parameter "openDataProperty" was null or undefined when calling apiOpenDataPropertyCreate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-property/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: OpenDataPropertyToJSON(requestParameters['openDataProperty']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataPropertyFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataPropertyCreate(requestParameters: ApiOpenDataPropertyCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataPropertyCreateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataPropertyDestroyRaw(requestParameters: ApiOpenDataPropertyDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataPropertyDestroy().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-property/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataPropertyDestroy(requestParameters: ApiOpenDataPropertyDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataPropertyDestroyRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataPropertyListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-property/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OpenDataPropertyFromJSON)); - } - - /** - */ - async apiOpenDataPropertyList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.apiOpenDataPropertyListRaw(initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataPropertyPartialUpdateRaw(requestParameters: ApiOpenDataPropertyPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataPropertyPartialUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-property/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PATCH', - headers: headerParameters, - query: queryParameters, - body: PatchedOpenDataPropertyToJSON(requestParameters['patchedOpenDataProperty']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataPropertyFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataPropertyPartialUpdate(requestParameters: ApiOpenDataPropertyPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataPropertyPartialUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataPropertyRetrieveRaw(requestParameters: ApiOpenDataPropertyRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataPropertyRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-property/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataPropertyFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataPropertyRetrieve(requestParameters: ApiOpenDataPropertyRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataPropertyRetrieveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataPropertyUpdateRaw(requestParameters: ApiOpenDataPropertyUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataPropertyUpdate().' - ); - } - - if (requestParameters['openDataProperty'] == null) { - throw new runtime.RequiredError( - 'openDataProperty', - 'Required parameter "openDataProperty" was null or undefined when calling apiOpenDataPropertyUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-property/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: OpenDataPropertyToJSON(requestParameters['openDataProperty']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataPropertyFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataPropertyUpdate(requestParameters: ApiOpenDataPropertyUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataPropertyUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataStatsRetrieveRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-stats/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataStatsRetrieve(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataStatsRetrieveRaw(initOverrides); - } - - /** - */ - async apiOpenDataStoreCreateRaw(requestParameters: ApiOpenDataStoreCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['openDataStore'] == null) { - throw new runtime.RequiredError( - 'openDataStore', - 'Required parameter "openDataStore" was null or undefined when calling apiOpenDataStoreCreate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-store/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: OpenDataStoreToJSON(requestParameters['openDataStore']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataStoreFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataStoreCreate(requestParameters: ApiOpenDataStoreCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataStoreCreateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataStoreDestroyRaw(requestParameters: ApiOpenDataStoreDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataStoreDestroy().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-store/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataStoreDestroy(requestParameters: ApiOpenDataStoreDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataStoreDestroyRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataStoreListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-store/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OpenDataStoreFromJSON)); - } - - /** - */ - async apiOpenDataStoreList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.apiOpenDataStoreListRaw(initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataStorePartialUpdateRaw(requestParameters: ApiOpenDataStorePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataStorePartialUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-store/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PATCH', - headers: headerParameters, - query: queryParameters, - body: PatchedOpenDataStoreToJSON(requestParameters['patchedOpenDataStore']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataStoreFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataStorePartialUpdate(requestParameters: ApiOpenDataStorePartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataStorePartialUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataStoreRetrieveRaw(requestParameters: ApiOpenDataStoreRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataStoreRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-store/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataStoreFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataStoreRetrieve(requestParameters: ApiOpenDataStoreRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataStoreRetrieveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataStoreUpdateRaw(requestParameters: ApiOpenDataStoreUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataStoreUpdate().' - ); - } - - if (requestParameters['openDataStore'] == null) { - throw new runtime.RequiredError( - 'openDataStore', - 'Required parameter "openDataStore" was null or undefined when calling apiOpenDataStoreUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-store/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: OpenDataStoreToJSON(requestParameters['openDataStore']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataStoreFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataStoreUpdate(requestParameters: ApiOpenDataStoreUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataStoreUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataUnitCreateRaw(requestParameters: ApiOpenDataUnitCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['openDataUnit'] == null) { - throw new runtime.RequiredError( - 'openDataUnit', - 'Required parameter "openDataUnit" was null or undefined when calling apiOpenDataUnitCreate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-unit/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: OpenDataUnitToJSON(requestParameters['openDataUnit']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataUnitFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataUnitCreate(requestParameters: ApiOpenDataUnitCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataUnitCreateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataUnitDestroyRaw(requestParameters: ApiOpenDataUnitDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataUnitDestroy().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-unit/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataUnitDestroy(requestParameters: ApiOpenDataUnitDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataUnitDestroyRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataUnitListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-unit/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OpenDataUnitFromJSON)); - } - - /** - */ - async apiOpenDataUnitList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.apiOpenDataUnitListRaw(initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataUnitPartialUpdateRaw(requestParameters: ApiOpenDataUnitPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataUnitPartialUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-unit/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PATCH', - headers: headerParameters, - query: queryParameters, - body: PatchedOpenDataUnitToJSON(requestParameters['patchedOpenDataUnit']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataUnitFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataUnitPartialUpdate(requestParameters: ApiOpenDataUnitPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataUnitPartialUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataUnitRetrieveRaw(requestParameters: ApiOpenDataUnitRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataUnitRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-unit/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataUnitFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataUnitRetrieve(requestParameters: ApiOpenDataUnitRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataUnitRetrieveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataUnitUpdateRaw(requestParameters: ApiOpenDataUnitUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataUnitUpdate().' - ); - } - - if (requestParameters['openDataUnit'] == null) { - throw new runtime.RequiredError( - 'openDataUnit', - 'Required parameter "openDataUnit" was null or undefined when calling apiOpenDataUnitUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-unit/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: OpenDataUnitToJSON(requestParameters['openDataUnit']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataUnitFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataUnitUpdate(requestParameters: ApiOpenDataUnitUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataUnitUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataVersionCreateRaw(requestParameters: ApiOpenDataVersionCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['openDataVersion'] == null) { - throw new runtime.RequiredError( - 'openDataVersion', - 'Required parameter "openDataVersion" was null or undefined when calling apiOpenDataVersionCreate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-version/`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: OpenDataVersionToJSON(requestParameters['openDataVersion']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataVersionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataVersionCreate(requestParameters: ApiOpenDataVersionCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataVersionCreateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataVersionDestroyRaw(requestParameters: ApiOpenDataVersionDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataVersionDestroy().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-version/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'DELETE', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.VoidApiResponse(response); - } - - /** - */ - async apiOpenDataVersionDestroy(requestParameters: ApiOpenDataVersionDestroyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - await this.apiOpenDataVersionDestroyRaw(requestParameters, initOverrides); - } - - /** - */ - async apiOpenDataVersionListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-version/`, - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(OpenDataVersionFromJSON)); - } - - /** - */ - async apiOpenDataVersionList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - const response = await this.apiOpenDataVersionListRaw(initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataVersionPartialUpdateRaw(requestParameters: ApiOpenDataVersionPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataVersionPartialUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-version/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PATCH', - headers: headerParameters, - query: queryParameters, - body: PatchedOpenDataVersionToJSON(requestParameters['patchedOpenDataVersion']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataVersionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataVersionPartialUpdate(requestParameters: ApiOpenDataVersionPartialUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataVersionPartialUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataVersionRetrieveRaw(requestParameters: ApiOpenDataVersionRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataVersionRetrieve().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-version/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'GET', - headers: headerParameters, - query: queryParameters, - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataVersionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataVersionRetrieve(requestParameters: ApiOpenDataVersionRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataVersionRetrieveRaw(requestParameters, initOverrides); - return await response.value(); - } - - /** - */ - async apiOpenDataVersionUpdateRaw(requestParameters: ApiOpenDataVersionUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['id'] == null) { - throw new runtime.RequiredError( - 'id', - 'Required parameter "id" was null or undefined when calling apiOpenDataVersionUpdate().' - ); - } - - if (requestParameters['openDataVersion'] == null) { - throw new runtime.RequiredError( - 'openDataVersion', - 'Required parameter "openDataVersion" was null or undefined when calling apiOpenDataVersionUpdate().' - ); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - if (this.configuration && this.configuration.apiKey) { - headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication - } - - const response = await this.request({ - path: `/api/open-data-version/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))), - method: 'PUT', - headers: headerParameters, - query: queryParameters, - body: OpenDataVersionToJSON(requestParameters['openDataVersion']), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => OpenDataVersionFromJSON(jsonValue)); - } - - /** - */ - async apiOpenDataVersionUpdate(requestParameters: ApiOpenDataVersionUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.apiOpenDataVersionUpdateRaw(requestParameters, initOverrides); - return await response.value(); - } - /** * logs request counts to redis cache total/per user/ */ diff --git a/vue3/src/openapi/models/Automation.ts b/vue3/src/openapi/models/Automation.ts index 019419723f..792a135cce 100644 --- a/vue3/src/openapi/models/Automation.ts +++ b/vue3/src/openapi/models/Automation.ts @@ -13,13 +13,13 @@ */ import { mapValues } from '../runtime'; -import type { AutomationTypeEnum } from './AutomationTypeEnum'; +import type { TypeEnum } from './TypeEnum'; import { - AutomationTypeEnumFromJSON, - AutomationTypeEnumFromJSONTyped, - AutomationTypeEnumToJSON, - AutomationTypeEnumToJSONTyped, -} from './AutomationTypeEnum'; + TypeEnumFromJSON, + TypeEnumFromJSONTyped, + TypeEnumToJSON, + TypeEnumToJSONTyped, +} from './TypeEnum'; /** * @@ -35,10 +35,10 @@ export interface Automation { id?: number; /** * - * @type {AutomationTypeEnum} + * @type {TypeEnum} * @memberof Automation */ - type: AutomationTypeEnum; + type: TypeEnum; /** * * @type {string} @@ -111,7 +111,7 @@ export function AutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean) return { 'id': json['id'] == null ? undefined : json['id'], - 'type': AutomationTypeEnumFromJSON(json['type']), + 'type': TypeEnumFromJSON(json['type']), 'name': json['name'] == null ? undefined : json['name'], 'description': json['description'] == null ? undefined : json['description'], 'param1': json['param_1'] == null ? undefined : json['param_1'], @@ -135,7 +135,7 @@ export function AutomationToJSONTyped(value?: Omit | n return { 'id': value['id'], - 'type': AutomationTypeEnumToJSON(value['type']), + 'type': TypeEnumToJSON(value['type']), 'name': value['name'], 'description': value['description'], 'param_1': value['param1'], diff --git a/vue3/src/openapi/models/PatchedAutomation.ts b/vue3/src/openapi/models/PatchedAutomation.ts index d91854c637..68dc430e53 100644 --- a/vue3/src/openapi/models/PatchedAutomation.ts +++ b/vue3/src/openapi/models/PatchedAutomation.ts @@ -13,13 +13,13 @@ */ import { mapValues } from '../runtime'; -import type { AutomationTypeEnum } from './AutomationTypeEnum'; +import type { TypeEnum } from './TypeEnum'; import { - AutomationTypeEnumFromJSON, - AutomationTypeEnumFromJSONTyped, - AutomationTypeEnumToJSON, - AutomationTypeEnumToJSONTyped, -} from './AutomationTypeEnum'; + TypeEnumFromJSON, + TypeEnumFromJSONTyped, + TypeEnumToJSON, + TypeEnumToJSONTyped, +} from './TypeEnum'; /** * @@ -35,10 +35,10 @@ export interface PatchedAutomation { id?: number; /** * - * @type {AutomationTypeEnum} + * @type {TypeEnum} * @memberof PatchedAutomation */ - type?: AutomationTypeEnum; + type?: TypeEnum; /** * * @type {string} @@ -109,7 +109,7 @@ export function PatchedAutomationFromJSONTyped(json: any, ignoreDiscriminator: b return { 'id': json['id'] == null ? undefined : json['id'], - 'type': json['type'] == null ? undefined : AutomationTypeEnumFromJSON(json['type']), + 'type': json['type'] == null ? undefined : TypeEnumFromJSON(json['type']), 'name': json['name'] == null ? undefined : json['name'], 'description': json['description'] == null ? undefined : json['description'], 'param1': json['param_1'] == null ? undefined : json['param_1'], @@ -133,7 +133,7 @@ export function PatchedAutomationToJSONTyped(value?: Omit + + + + @@ -220,13 +226,17 @@ import {useDisplay} from "vuetify"; const {mobile} = useDisplay() const router = useRouter() -const {updateRecipeImage, fileApiLoading} = useFileApi() +const {updateRecipeImage, convertImageToRecipe, fileApiLoading} = useFileApi() const stepper = ref("1") const dialog = ref(false) const loading = ref(false) const importUrl = ref("") + + +const image = ref(null) + const importResponse = ref({} as RecipeFromSourceResponse) const keywordSelect = ref(null) const editingIngredient = ref({} as SourceImportIngredient) @@ -246,6 +256,14 @@ function loadRecipeFromUrl() { }) } +function uploadAndConvertImage(){ + if(image.value != null){ + convertImageToRecipe(image.value).then(r => { + importResponse.value = r + }) + } +} + /** * create recipe in database */ diff --git a/vue3/src/pages/TestPage.vue b/vue3/src/pages/TestPage.vue index 1f9d318fea..0dff20cd91 100644 --- a/vue3/src/pages/TestPage.vue +++ b/vue3/src/pages/TestPage.vue @@ -12,66 +12,43 @@ - - - - - - - - - - {{ i.name }} - - - - - - - - - - - {{ i.name }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -85,8 +62,11 @@ import ModelEditDialog from "@/components/dialogs/ModelEditDialog.vue"; import {DateTime} from "luxon"; import ModelSelect from "@/components/inputs/ModelSelect.vue"; import {VueDraggable} from "vue-draggable-plus"; +import {useFileApi} from "@/composables/useFileApi"; -const image = ref(File) +const {convertImageToRecipe, fileApiLoading} = useFileApi() + +const image = ref(null) const response = ref('') const dialog = ref(false) @@ -96,55 +76,11 @@ const defaultItem = ref({ fromDate: DateTime.now().plus({day: 2}).toJSDate() } as MealPlan) -const items2 = ref([]) -const items1 = ref([ - { - "name": "Jean", - "id": "2" - }, - { - "name": "Johanna-2", - "id": "3-2" - }, - { - "name": "Joao-2", - "id": "1-2" - }, - { - "name": "Juan", - "id": "4" - }, - { - "name": "Joao", - "id": "1" - }, - { - "name": "Jean-2", - "id": "2-2" - }, - { - "name": "Johanna", - "id": "3" - }, - { - "name": "Juan-2", - "id": "4-2" - } -]) function imageToRecipe() { - const api = new ApiApi() - - const reader = new FileReader() - reader.readAsDataURL(image.value) - - api.apiImageToRecipeCreate({image: image.value}).then(r => { - console.log(r) - response.value = r - }).catch(err => { - console.log(err) - response.value = err - }) + if(image.value != null){ + convertImageToRecipe(image.value) + } }