From 78f19d51e9b1c309e3f7a8f53fb938a5e699e20d Mon Sep 17 00:00:00 2001 From: thexeroxbe Date: Wed, 6 Nov 2024 14:06:01 +0100 Subject: [PATCH] updated api --- mobile/openapi/README.md | 3 +- mobile/openapi/lib/api.dart | 1 + mobile/openapi/lib/api/notifications_api.dart | 18 ++-- mobile/openapi/lib/api_client.dart | 2 + mobile/openapi/lib/model/template_dto.dart | 99 +++++++++++++++++++ open-api/immich-openapi-specs.json | 23 ++++- open-api/typescript-sdk/src/fetch-client.ts | 14 ++- 7 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 mobile/openapi/lib/model/template_dto.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 53cae3ca9b..eb6919500d 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -144,7 +144,7 @@ Class | Method | HTTP request | Description *MemoriesApi* | [**removeMemoryAssets**](doc//MemoriesApi.md#removememoryassets) | **DELETE** /memories/{id}/assets | *MemoriesApi* | [**searchMemories**](doc//MemoriesApi.md#searchmemories) | **GET** /memories | *MemoriesApi* | [**updateMemory**](doc//MemoriesApi.md#updatememory) | **PUT** /memories/{id} | -*NotificationsApi* | [**getNotificationTemplate**](doc//NotificationsApi.md#getnotificationtemplate) | **GET** /notifications/templates/{name} | +*NotificationsApi* | [**getNotificationTemplate**](doc//NotificationsApi.md#getnotificationtemplate) | **POST** /notifications/templates/{name} | *NotificationsApi* | [**sendTestEmail**](doc//NotificationsApi.md#sendtestemail) | **POST** /notifications/test-email | *OAuthApi* | [**finishOAuth**](doc//OAuthApi.md#finishoauth) | **POST** /oauth/callback | *OAuthApi* | [**linkOAuthAccount**](doc//OAuthApi.md#linkoauthaccount) | **POST** /oauth/link | @@ -452,6 +452,7 @@ Class | Method | HTTP request | Description - [TagUpsertDto](doc//TagUpsertDto.md) - [TagsResponse](doc//TagsResponse.md) - [TagsUpdate](doc//TagsUpdate.md) + - [TemplateDto](doc//TemplateDto.md) - [TemplateResponseDto](doc//TemplateResponseDto.md) - [TestEmailResponseDto](doc//TestEmailResponseDto.md) - [TimeBucketResponseDto](doc//TimeBucketResponseDto.md) diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index 4a3fe376b6..65fca58f90 100644 --- a/mobile/openapi/lib/api.dart +++ b/mobile/openapi/lib/api.dart @@ -265,6 +265,7 @@ part 'model/tag_update_dto.dart'; part 'model/tag_upsert_dto.dart'; part 'model/tags_response.dart'; part 'model/tags_update.dart'; +part 'model/template_dto.dart'; part 'model/template_response_dto.dart'; part 'model/test_email_response_dto.dart'; part 'model/time_bucket_response_dto.dart'; diff --git a/mobile/openapi/lib/api/notifications_api.dart b/mobile/openapi/lib/api/notifications_api.dart index ca13dc0d2b..323fbcc3d6 100644 --- a/mobile/openapi/lib/api/notifications_api.dart +++ b/mobile/openapi/lib/api/notifications_api.dart @@ -16,28 +16,30 @@ class NotificationsApi { final ApiClient apiClient; - /// Performs an HTTP 'GET /notifications/templates/{name}' operation and returns the [Response]. + /// Performs an HTTP 'POST /notifications/templates/{name}' operation and returns the [Response]. /// Parameters: /// /// * [String] name (required): - Future getNotificationTemplateWithHttpInfo(String name,) async { + /// + /// * [TemplateDto] templateDto (required): + Future getNotificationTemplateWithHttpInfo(String name, TemplateDto templateDto,) async { // ignore: prefer_const_declarations final path = r'/notifications/templates/{name}' .replaceAll('{name}', name); // ignore: prefer_final_locals - Object? postBody; + Object? postBody = templateDto; final queryParams = []; final headerParams = {}; final formParams = {}; - const contentTypes = []; + const contentTypes = ['application/json']; return apiClient.invokeAPI( path, - 'GET', + 'POST', queryParams, postBody, headerParams, @@ -49,8 +51,10 @@ class NotificationsApi { /// Parameters: /// /// * [String] name (required): - Future getNotificationTemplate(String name,) async { - final response = await getNotificationTemplateWithHttpInfo(name,); + /// + /// * [TemplateDto] templateDto (required): + Future getNotificationTemplate(String name, TemplateDto templateDto,) async { + final response = await getNotificationTemplateWithHttpInfo(name, templateDto,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index cb40250b15..3a6623b910 100644 --- a/mobile/openapi/lib/api_client.dart +++ b/mobile/openapi/lib/api_client.dart @@ -584,6 +584,8 @@ class ApiClient { return TagsResponse.fromJson(value); case 'TagsUpdate': return TagsUpdate.fromJson(value); + case 'TemplateDto': + return TemplateDto.fromJson(value); case 'TemplateResponseDto': return TemplateResponseDto.fromJson(value); case 'TestEmailResponseDto': diff --git a/mobile/openapi/lib/model/template_dto.dart b/mobile/openapi/lib/model/template_dto.dart new file mode 100644 index 0000000000..d2037e8192 --- /dev/null +++ b/mobile/openapi/lib/model/template_dto.dart @@ -0,0 +1,99 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.18 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class TemplateDto { + /// Returns a new [TemplateDto] instance. + TemplateDto({ + required this.tempTemplate, + }); + + String tempTemplate; + + @override + bool operator ==(Object other) => identical(this, other) || other is TemplateDto && + other.tempTemplate == tempTemplate; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (tempTemplate.hashCode); + + @override + String toString() => 'TemplateDto[tempTemplate=$tempTemplate]'; + + Map toJson() { + final json = {}; + json[r'tempTemplate'] = this.tempTemplate; + return json; + } + + /// Returns a new [TemplateDto] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static TemplateDto? fromJson(dynamic value) { + upgradeDto(value, "TemplateDto"); + if (value is Map) { + final json = value.cast(); + + return TemplateDto( + tempTemplate: mapValueOfType(json, r'tempTemplate')!, + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = TemplateDto.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = TemplateDto.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of TemplateDto-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = TemplateDto.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'tempTemplate', + }; +} + diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index f1726b456e..5a6b326f13 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -3431,7 +3431,7 @@ } }, "/notifications/templates/{name}": { - "get": { + "post": { "operationId": "getNotificationTemplate", "parameters": [ { @@ -3443,6 +3443,16 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TemplateDto" + } + } + }, + "required": true + }, "responses": { "200": { "content": { @@ -12417,6 +12427,17 @@ }, "type": "object" }, + "TemplateDto": { + "properties": { + "tempTemplate": { + "type": "string" + } + }, + "required": [ + "tempTemplate" + ], + "type": "object" + }, "TemplateResponseDto": { "properties": { "html": { diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index c25f8e6812..5da54a8fb5 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -639,6 +639,9 @@ export type MemoryUpdateDto = { memoryAt?: string; seenAt?: string; }; +export type TemplateDto = { + tempTemplate: string; +}; export type TemplateResponseDto = { html: string; name: string; @@ -2237,15 +2240,18 @@ export function addMemoryAssets({ id, bulkIdsDto }: { body: bulkIdsDto }))); } -export function getNotificationTemplate({ name }: { +export function getNotificationTemplate({ name, templateDto }: { name: string; + templateDto: TemplateDto; }, opts?: Oazapfts.RequestOpts) { return oazapfts.ok(oazapfts.fetchJson<{ status: 200; data: TemplateResponseDto; - }>(`/notifications/templates/${encodeURIComponent(name)}`, { - ...opts - })); + }>(`/notifications/templates/${encodeURIComponent(name)}`, oazapfts.json({ + ...opts, + method: "POST", + body: templateDto + }))); } export function sendTestEmail({ systemConfigSmtpDto }: { systemConfigSmtpDto: SystemConfigSmtpDto;