diff --git a/lib/Screens/Configurations/configuration_detail_screen.dart b/lib/Screens/Configurations/configuration_detail_screen.dart index 327d327..aeaf53e 100644 --- a/lib/Screens/Configurations/configuration_detail_screen.dart +++ b/lib/Screens/Configurations/configuration_detail_screen.dart @@ -405,7 +405,7 @@ class _ConfigurationDetailScreenState extends State { if (snapshot.connectionState == ConnectionState.done) { if(configurationDTO.isMobile!) { - // Only see Article and Quizz type + // Only see Article and Quiz type sections = new List.from(snapshot.data).where((section) => !section.isSubSection! && (section.type == SectionType.Article || section.type == SectionType.Quiz)).toList(); } else { sections = new List.from(snapshot.data).where((section) => !section.isSubSection!).toList(); diff --git a/lib/api/swagger.yaml b/lib/api/swagger.yaml index 33f6f37..f5170cd 100644 --- a/lib/api/swagger.yaml +++ b/lib/api/swagger.yaml @@ -4,11 +4,11 @@ "info": { "title": "Manager Service", "description": "API Manager Service", - "version": "Version Alpha" + "version": "Version Alpha 3" }, "servers": [ { - "url": "http://localhost:5000" + "url": "https://localhost:5001" } ], "paths": { @@ -1790,9 +1790,7 @@ "description": "", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/SectionDTO" - } + "schema": {} } } }, @@ -1944,6 +1942,59 @@ ] } }, + "/api/Section/configuration/{id}/detail": { + "get": { + "tags": [ + "Section" + ], + "operationId": "Section_GetFromConfigurationDetail", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "nullable": true + }, + "x-position": 1 + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": {} + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, "/api/Section/{id}/subsections": { "get": { "tags": [ @@ -2887,7 +2938,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/QuizQuestion" + "$ref": "#/components/schemas/QuestionDTO" } } } @@ -2954,7 +3005,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/QuizQuestion" + "$ref": "#/components/schemas/QuestionDTO" } } } @@ -3655,7 +3706,8 @@ }, "dateCreation": { "type": "string", - "format": "date-time" + "format": "date-time", + "nullable": true }, "order": { "type": "integer", @@ -4322,7 +4374,8 @@ "properties": { "id": { "type": "integer", - "format": "int32" + "format": "int32", + "nullable": true }, "label": { "type": "array", @@ -4356,7 +4409,8 @@ }, "order": { "type": "integer", - "format": "int32" + "format": "int32", + "nullable": true } } }, @@ -4889,111 +4943,6 @@ } } }, - "QuizQuestion": { - "type": "object", - "additionalProperties": false, - "required": [ - "id", - "label", - "responses" - ], - "properties": { - "id": { - "type": "integer", - "format": "int32" - }, - "label": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TranslationAndResourceDTO" - } - }, - "resourceId": { - "type": "string", - "nullable": true - }, - "resource": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/Resource" - } - ] - }, - "order": { - "type": "integer", - "format": "int32" - }, - "responses": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ResponseDTO" - } - }, - "sectionQuizId": { - "type": "string", - "nullable": true - }, - "sectionQuiz": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/SectionQuiz" - } - ] - } - } - }, - "SectionQuiz": { - "allOf": [ - { - "$ref": "#/components/schemas/Section" - }, - { - "type": "object", - "additionalProperties": false, - "required": [ - "quizQuestions", - "quizBadLevel", - "quizMediumLevel", - "quizGoodLevel", - "quizGreatLevel" - ], - "properties": { - "quizQuestions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/QuizQuestion" - } - }, - "quizBadLevel": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TranslationAndResourceDTO" - } - }, - "quizMediumLevel": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TranslationAndResourceDTO" - } - }, - "quizGoodLevel": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TranslationAndResourceDTO" - } - }, - "quizGreatLevel": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TranslationAndResourceDTO" - } - } - } - } - ] - }, "User": { "type": "object", "additionalProperties": false, diff --git a/manager_api_new/.openapi-generator/FILES b/manager_api_new/.openapi-generator/FILES index 2c3515b..8f248e2 100644 --- a/manager_api_new/.openapi-generator/FILES +++ b/manager_api_new/.openapi-generator/FILES @@ -38,8 +38,6 @@ doc/PuzzleDTOAllOfPuzzleImage.md doc/QuestionDTO.md doc/QuestionDTOImageBackgroundResourceType.md doc/QuizDTO.md -doc/QuizQuestion.md -doc/QuizQuestionSectionQuiz.md doc/Resource.md doc/ResourceApi.md doc/ResourceDTO.md @@ -54,7 +52,6 @@ doc/SectionMapAllOfMapMapType.md doc/SectionMapAllOfMapResource.md doc/SectionMapAllOfMapTypeMapbox.md doc/SectionMapApi.md -doc/SectionQuiz.md doc/SectionQuizApi.md doc/SectionType.md doc/SliderDTO.md @@ -118,8 +115,6 @@ lib/model/puzzle_dto_all_of_puzzle_image.dart lib/model/question_dto.dart lib/model/question_dto_image_background_resource_type.dart lib/model/quiz_dto.dart -lib/model/quiz_question.dart -lib/model/quiz_question_section_quiz.dart lib/model/resource.dart lib/model/resource_dto.dart lib/model/resource_type.dart @@ -131,7 +126,6 @@ lib/model/section_map_all_of_map_map_provider.dart lib/model/section_map_all_of_map_map_type.dart lib/model/section_map_all_of_map_resource.dart lib/model/section_map_all_of_map_type_mapbox.dart -lib/model/section_quiz.dart lib/model/section_type.dart lib/model/slider_dto.dart lib/model/token_dto.dart @@ -143,12 +137,3 @@ lib/model/video_dto.dart lib/model/weather_dto.dart lib/model/web_dto.dart pubspec.yaml -test/geo_point_section_map_test.dart -test/quiz_question_section_quiz_test.dart -test/section_map_all_of_map_map_provider_test.dart -test/section_map_all_of_map_map_type_test.dart -test/section_map_all_of_map_resource_test.dart -test/section_map_all_of_map_type_mapbox_test.dart -test/section_map_test.dart -test/section_quiz_test.dart -test/section_test.dart diff --git a/manager_api_new/README.md b/manager_api_new/README.md index 9452f76..ca87372 100644 --- a/manager_api_new/README.md +++ b/manager_api_new/README.md @@ -3,7 +3,7 @@ API Manager Service This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: -- API version: Version Alpha +- API version: Version Alpha 3 - Generator version: 7.9.0 - Build package: org.openapitools.codegen.languages.DartClientCodegen @@ -61,7 +61,7 @@ try { ## Documentation for API Endpoints -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- @@ -104,6 +104,7 @@ Class | Method | HTTP request | Description *SectionApi* | [**sectionGetArticleDTO**](doc//SectionApi.md#sectiongetarticledto) | **GET** /api/Section/ArticleDTO | *SectionApi* | [**sectionGetDetail**](doc//SectionApi.md#sectiongetdetail) | **GET** /api/Section/{id} | *SectionApi* | [**sectionGetFromConfiguration**](doc//SectionApi.md#sectiongetfromconfiguration) | **GET** /api/Section/configuration/{id} | +*SectionApi* | [**sectionGetFromConfigurationDetail**](doc//SectionApi.md#sectiongetfromconfigurationdetail) | **GET** /api/Section/configuration/{id}/detail | *SectionApi* | [**sectionGetMapDTO**](doc//SectionApi.md#sectiongetmapdto) | **GET** /api/Section/MapDTO | *SectionApi* | [**sectionGetMenuDTO**](doc//SectionApi.md#sectiongetmenudto) | **GET** /api/Section/MenuDTO | *SectionApi* | [**sectionGetPdfDTO**](doc//SectionApi.md#sectiongetpdfdto) | **GET** /api/Section/PdfDTO | @@ -165,8 +166,6 @@ Class | Method | HTTP request | Description - [QuestionDTO](doc//QuestionDTO.md) - [QuestionDTOImageBackgroundResourceType](doc//QuestionDTOImageBackgroundResourceType.md) - [QuizDTO](doc//QuizDTO.md) - - [QuizQuestion](doc//QuizQuestion.md) - - [QuizQuestionSectionQuiz](doc//QuizQuestionSectionQuiz.md) - [Resource](doc//Resource.md) - [ResourceDTO](doc//ResourceDTO.md) - [ResourceType](doc//ResourceType.md) @@ -178,7 +177,6 @@ Class | Method | HTTP request | Description - [SectionMapAllOfMapMapType](doc//SectionMapAllOfMapMapType.md) - [SectionMapAllOfMapResource](doc//SectionMapAllOfMapResource.md) - [SectionMapAllOfMapTypeMapbox](doc//SectionMapAllOfMapTypeMapbox.md) - - [SectionQuiz](doc//SectionQuiz.md) - [SectionType](doc//SectionType.md) - [SliderDTO](doc//SliderDTO.md) - [TokenDTO](doc//TokenDTO.md) diff --git a/manager_api_new/doc/AuthenticationApi.md b/manager_api_new/doc/AuthenticationApi.md index b17a2f1..9ef127e 100644 --- a/manager_api_new/doc/AuthenticationApi.md +++ b/manager_api_new/doc/AuthenticationApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/manager_api_new/doc/ConfigurationApi.md b/manager_api_new/doc/ConfigurationApi.md index 6b4f5c9..8e88412 100644 --- a/manager_api_new/doc/ConfigurationApi.md +++ b/manager_api_new/doc/ConfigurationApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/manager_api_new/doc/DeviceApi.md b/manager_api_new/doc/DeviceApi.md index a586e58..1173900 100644 --- a/manager_api_new/doc/DeviceApi.md +++ b/manager_api_new/doc/DeviceApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/manager_api_new/doc/InstanceApi.md b/manager_api_new/doc/InstanceApi.md index 0b675c0..5d8e006 100644 --- a/manager_api_new/doc/InstanceApi.md +++ b/manager_api_new/doc/InstanceApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/manager_api_new/doc/ResourceApi.md b/manager_api_new/doc/ResourceApi.md index fcf1ea2..ff8f425 100644 --- a/manager_api_new/doc/ResourceApi.md +++ b/manager_api_new/doc/ResourceApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/manager_api_new/doc/SectionApi.md b/manager_api_new/doc/SectionApi.md index 71f061a..2f7236f 100644 --- a/manager_api_new/doc/SectionApi.md +++ b/manager_api_new/doc/SectionApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- @@ -19,6 +19,7 @@ Method | HTTP request | Description [**sectionGetArticleDTO**](SectionApi.md#sectiongetarticledto) | **GET** /api/Section/ArticleDTO | [**sectionGetDetail**](SectionApi.md#sectiongetdetail) | **GET** /api/Section/{id} | [**sectionGetFromConfiguration**](SectionApi.md#sectiongetfromconfiguration) | **GET** /api/Section/configuration/{id} | +[**sectionGetFromConfigurationDetail**](SectionApi.md#sectiongetfromconfigurationdetail) | **GET** /api/Section/configuration/{id}/detail | [**sectionGetMapDTO**](SectionApi.md#sectiongetmapdto) | **GET** /api/Section/MapDTO | [**sectionGetMenuDTO**](SectionApi.md#sectiongetmenudto) | **GET** /api/Section/MenuDTO | [**sectionGetPdfDTO**](SectionApi.md#sectiongetpdfdto) | **GET** /api/Section/PdfDTO | @@ -455,6 +456,49 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **sectionGetFromConfigurationDetail** +> List sectionGetFromConfigurationDetail(id) + + + +### Example +```dart +import 'package:manager_api_new/api.dart'; +// TODO Configure OAuth2 access token for authorization: bearer +//defaultApiClient.getAuthentication('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; + +final api_instance = SectionApi(); +final id = id_example; // String | + +try { + final result = api_instance.sectionGetFromConfigurationDetail(id); + print(result); +} catch (e) { + print('Exception when calling SectionApi->sectionGetFromConfigurationDetail: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **id** | **String**| | + +### Return type + +[**List**](Object.md) + +### Authorization + +[bearer](../README.md#bearer) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **sectionGetMapDTO** > MapDTO sectionGetMapDTO() @@ -846,7 +890,7 @@ This endpoint does not need any parameter. [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **sectionUpdate** -> SectionDTO sectionUpdate(body) +> Object sectionUpdate(body) @@ -875,7 +919,7 @@ Name | Type | Description | Notes ### Return type -[**SectionDTO**](SectionDTO.md) +[**Object**](Object.md) ### Authorization diff --git a/manager_api_new/doc/SectionMapApi.md b/manager_api_new/doc/SectionMapApi.md index 4d8a73f..5cb26c5 100644 --- a/manager_api_new/doc/SectionMapApi.md +++ b/manager_api_new/doc/SectionMapApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/manager_api_new/doc/SectionQuizApi.md b/manager_api_new/doc/SectionQuizApi.md index 2b8ae38..6d35ebf 100644 --- a/manager_api_new/doc/SectionQuizApi.md +++ b/manager_api_new/doc/SectionQuizApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- @@ -16,7 +16,7 @@ Method | HTTP request | Description # **sectionQuizCreate** -> QuizQuestion sectionQuizCreate(sectionId, questionDTO) +> QuestionDTO sectionQuizCreate(sectionId, questionDTO) @@ -47,7 +47,7 @@ Name | Type | Description | Notes ### Return type -[**QuizQuestion**](QuizQuestion.md) +[**QuestionDTO**](QuestionDTO.md) ### Authorization @@ -147,7 +147,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **sectionQuizUpdate** -> QuizQuestion sectionQuizUpdate(questionDTO) +> QuestionDTO sectionQuizUpdate(questionDTO) @@ -176,7 +176,7 @@ Name | Type | Description | Notes ### Return type -[**QuizQuestion**](QuizQuestion.md) +[**QuestionDTO**](QuestionDTO.md) ### Authorization diff --git a/manager_api_new/doc/UserApi.md b/manager_api_new/doc/UserApi.md index 05129f6..c46e856 100644 --- a/manager_api_new/doc/UserApi.md +++ b/manager_api_new/doc/UserApi.md @@ -5,7 +5,7 @@ import 'package:manager_api_new/api.dart'; ``` -All URIs are relative to *http://localhost:5000* +All URIs are relative to *https://localhost:5001* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/manager_api_new/lib/api.dart b/manager_api_new/lib/api.dart index 51455aa..142059a 100644 --- a/manager_api_new/lib/api.dart +++ b/manager_api_new/lib/api.dart @@ -70,8 +70,6 @@ part 'model/puzzle_dto_all_of_puzzle_image.dart'; part 'model/question_dto.dart'; part 'model/question_dto_image_background_resource_type.dart'; part 'model/quiz_dto.dart'; -part 'model/quiz_question.dart'; -part 'model/quiz_question_section_quiz.dart'; part 'model/resource.dart'; part 'model/resource_dto.dart'; part 'model/resource_type.dart'; @@ -83,7 +81,6 @@ part 'model/section_map_all_of_map_map_provider.dart'; part 'model/section_map_all_of_map_map_type.dart'; part 'model/section_map_all_of_map_resource.dart'; part 'model/section_map_all_of_map_type_mapbox.dart'; -part 'model/section_quiz.dart'; part 'model/section_type.dart'; part 'model/slider_dto.dart'; part 'model/token_dto.dart'; diff --git a/manager_api_new/lib/api/section_api.dart b/manager_api_new/lib/api/section_api.dart index 9039607..47e8877 100644 --- a/manager_api_new/lib/api/section_api.dart +++ b/manager_api_new/lib/api/section_api.dart @@ -556,6 +556,63 @@ class SectionApi { return null; } + /// Performs an HTTP 'GET /api/Section/configuration/{id}/detail' operation and returns the [Response]. + /// Parameters: + /// + /// * [String] id (required): + Future sectionGetFromConfigurationDetailWithHttpInfo( + String id, + ) async { + // ignore: prefer_const_declarations + final path = + r'/api/Section/configuration/{id}/detail'.replaceAll('{id}', id); + + // ignore: prefer_final_locals + Object? postBody; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + const contentTypes = []; + + return apiClient.invokeAPI( + path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentTypes.isEmpty ? null : contentTypes.first, + ); + } + + /// Parameters: + /// + /// * [String] id (required): + Future?> sectionGetFromConfigurationDetail( + String id, + ) async { + final response = await sectionGetFromConfigurationDetailWithHttpInfo( + id, + ); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + // When a remote server returns no body with a status of 204, we shall not decode it. + // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" + // FormatException when trying to decode an empty string. + if (response.body.isNotEmpty && + response.statusCode != HttpStatus.noContent) { + final responseBody = await _decodeBodyBytes(response); + return (await apiClient.deserializeAsync(responseBody, 'List') + as List) + .cast() + .toList(growable: false); + } + return null; + } + /// Performs an HTTP 'GET /api/Section/MapDTO' operation and returns the [Response]. Future sectionGetMapDTOWithHttpInfo() async { // ignore: prefer_const_declarations diff --git a/manager_api_new/lib/api/section_quiz_api.dart b/manager_api_new/lib/api/section_quiz_api.dart index 34db353..4bddda1 100644 --- a/manager_api_new/lib/api/section_quiz_api.dart +++ b/manager_api_new/lib/api/section_quiz_api.dart @@ -55,7 +55,7 @@ class SectionQuizApi { /// * [String] sectionId (required): /// /// * [QuestionDTO] questionDTO (required): - Future sectionQuizCreate( + Future sectionQuizCreate( String sectionId, QuestionDTO questionDTO, ) async { @@ -73,8 +73,8 @@ class SectionQuizApi { response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync( await _decodeBodyBytes(response), - 'QuizQuestion', - ) as QuizQuestion; + 'QuestionDTO', + ) as QuestionDTO; } return null; } @@ -225,7 +225,7 @@ class SectionQuizApi { /// Parameters: /// /// * [QuestionDTO] questionDTO (required): - Future sectionQuizUpdate( + Future sectionQuizUpdate( QuestionDTO questionDTO, ) async { final response = await sectionQuizUpdateWithHttpInfo( @@ -241,8 +241,8 @@ class SectionQuizApi { response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync( await _decodeBodyBytes(response), - 'QuizQuestion', - ) as QuizQuestion; + 'QuestionDTO', + ) as QuestionDTO; } return null; } diff --git a/manager_api_new/lib/api_client.dart b/manager_api_new/lib/api_client.dart index bf35150..a1dca31 100644 --- a/manager_api_new/lib/api_client.dart +++ b/manager_api_new/lib/api_client.dart @@ -12,7 +12,7 @@ part of openapi.api; class ApiClient { ApiClient({ - this.basePath = 'http://localhost:5000', + this.basePath = 'https://localhost:5001', this.authentication, }); @@ -293,10 +293,6 @@ class ApiClient { return QuestionDTOImageBackgroundResourceType.fromJson(value); case 'QuizDTO': return QuizDTO.fromJson(value); - case 'QuizQuestion': - return QuizQuestion.fromJson(value); - case 'QuizQuestionSectionQuiz': - return QuizQuestionSectionQuiz.fromJson(value); case 'Resource': return Resource.fromJson(value); case 'ResourceDTO': @@ -319,8 +315,6 @@ class ApiClient { return SectionMapAllOfMapResource.fromJson(value); case 'SectionMapAllOfMapTypeMapbox': return SectionMapAllOfMapTypeMapbox.fromJson(value); - case 'SectionQuiz': - return SectionQuiz.fromJson(value); case 'SectionType': return SectionTypeTypeTransformer().decode(value); case 'SliderDTO': diff --git a/manager_api_new/lib/model/map_type_map_box.dart b/manager_api_new/lib/model/map_type_map_box.dart index fa8676a..3f64cd0 100644 --- a/manager_api_new/lib/model/map_type_map_box.dart +++ b/manager_api_new/lib/model/map_type_map_box.dart @@ -23,32 +23,28 @@ class MapTypeMapBox { int toJson() => value; - static const number0 = MapTypeMapBox._(0); - static const number1 = MapTypeMapBox._(1); - static const number2 = MapTypeMapBox._(2); - static const number3 = MapTypeMapBox._(3); - static const number4 = MapTypeMapBox._(4); - static const number5 = MapTypeMapBox._(5); - static const number6 = MapTypeMapBox._(6); + static const standard = MapTypeMapBox._(0); + static const streets = MapTypeMapBox._(1); + static const outdoors = MapTypeMapBox._(2); + static const light = MapTypeMapBox._(3); + static const dark = MapTypeMapBox._(4); + static const satellite = MapTypeMapBox._(5); + static const satellite_streets = MapTypeMapBox._(6); /// List of all possible values in this [enum][MapTypeMapBox]. static const values = [ - number0, - number1, - number2, - number3, - number4, - number5, - number6, + standard, + streets, + outdoors, + light, + dark, + satellite, + satellite_streets, ]; - static MapTypeMapBox? fromJson(dynamic value) => - MapTypeMapBoxTypeTransformer().decode(value); + static MapTypeMapBox? fromJson(dynamic value) => MapTypeMapBoxTypeTransformer().decode(value); - static List listFromJson( - dynamic json, { - bool growable = false, - }) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -65,8 +61,7 @@ class MapTypeMapBox { /// Transformation class that can [encode] an instance of [MapTypeMapBox] to int, /// and [decode] dynamic data back to [MapTypeMapBox]. class MapTypeMapBoxTypeTransformer { - factory MapTypeMapBoxTypeTransformer() => - _instance ??= const MapTypeMapBoxTypeTransformer._(); + factory MapTypeMapBoxTypeTransformer() => _instance ??= const MapTypeMapBoxTypeTransformer._(); const MapTypeMapBoxTypeTransformer._(); @@ -82,30 +77,42 @@ class MapTypeMapBoxTypeTransformer { /// and users are still using an old app with the old code. MapTypeMapBox? decode(dynamic data, {bool allowNull = true}) { if (data != null) { - switch (data) { - case 0: - return MapTypeMapBox.number0; - case 1: - return MapTypeMapBox.number1; - case 2: - return MapTypeMapBox.number2; - case 3: - return MapTypeMapBox.number3; - case 4: - return MapTypeMapBox.number4; - case 5: - return MapTypeMapBox.number5; - case 6: - return MapTypeMapBox.number6; - default: - if (!allowNull) { - throw ArgumentError('Unknown enum value to decode: $data'); + if(data.runtimeType == String) { + switch (data.toString().toLowerCase()) { + case r'standard': return MapTypeMapBox.standard; + case r'streets': return MapTypeMapBox.streets; + case r'outdoors': return MapTypeMapBox.outdoors; + case r'light': return MapTypeMapBox.light; + case r'dark': return MapTypeMapBox.dark; + case r'satellite': return MapTypeMapBox.satellite; + case r'satellite_streets': return MapTypeMapBox.satellite_streets; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + } else { + if(data.runtimeType == int) { + switch (data) { + case 0: return MapTypeMapBox.standard; + case 1: return MapTypeMapBox.streets; + case 2: return MapTypeMapBox.outdoors; + case 3: return MapTypeMapBox.light; + case 4: return MapTypeMapBox.dark; + case 5: return MapTypeMapBox.satellite; + case 6: return MapTypeMapBox.satellite_streets; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } } + } } + } return null; } /// Singleton [MapTypeMapBoxTypeTransformer] instance. static MapTypeMapBoxTypeTransformer? _instance; -} +} \ No newline at end of file