shared_link_response_dto.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. //
  2. // AUTO-GENERATED FILE, DO NOT MODIFY!
  3. //
  4. // @dart=2.12
  5. // ignore_for_file: unused_element, unused_import
  6. // ignore_for_file: always_put_required_named_parameters_first
  7. // ignore_for_file: constant_identifier_names
  8. // ignore_for_file: lines_longer_than_80_chars
  9. part of openapi.api;
  10. class SharedLinkResponseDto {
  11. /// Returns a new [SharedLinkResponseDto] instance.
  12. SharedLinkResponseDto({
  13. required this.type,
  14. required this.id,
  15. this.description,
  16. required this.userId,
  17. required this.key,
  18. required this.createdAt,
  19. required this.expiresAt,
  20. this.assets = const [],
  21. this.album,
  22. required this.allowUpload,
  23. required this.allowDownload,
  24. required this.showExif,
  25. });
  26. SharedLinkType type;
  27. String id;
  28. ///
  29. /// Please note: This property should have been non-nullable! Since the specification file
  30. /// does not include a default value (using the "default:" property), however, the generated
  31. /// source code must fall back to having a nullable type.
  32. /// Consider adding a "default:" property in the specification file to hide this note.
  33. ///
  34. String? description;
  35. String userId;
  36. String key;
  37. DateTime createdAt;
  38. DateTime? expiresAt;
  39. List<AssetResponseDto> assets;
  40. ///
  41. /// Please note: This property should have been non-nullable! Since the specification file
  42. /// does not include a default value (using the "default:" property), however, the generated
  43. /// source code must fall back to having a nullable type.
  44. /// Consider adding a "default:" property in the specification file to hide this note.
  45. ///
  46. AlbumResponseDto? album;
  47. bool allowUpload;
  48. bool allowDownload;
  49. bool showExif;
  50. @override
  51. bool operator ==(Object other) => identical(this, other) || other is SharedLinkResponseDto &&
  52. other.type == type &&
  53. other.id == id &&
  54. other.description == description &&
  55. other.userId == userId &&
  56. other.key == key &&
  57. other.createdAt == createdAt &&
  58. other.expiresAt == expiresAt &&
  59. other.assets == assets &&
  60. other.album == album &&
  61. other.allowUpload == allowUpload &&
  62. other.allowDownload == allowDownload &&
  63. other.showExif == showExif;
  64. @override
  65. int get hashCode =>
  66. // ignore: unnecessary_parenthesis
  67. (type.hashCode) +
  68. (id.hashCode) +
  69. (description == null ? 0 : description!.hashCode) +
  70. (userId.hashCode) +
  71. (key.hashCode) +
  72. (createdAt.hashCode) +
  73. (expiresAt == null ? 0 : expiresAt!.hashCode) +
  74. (assets.hashCode) +
  75. (album == null ? 0 : album!.hashCode) +
  76. (allowUpload.hashCode) +
  77. (allowDownload.hashCode) +
  78. (showExif.hashCode);
  79. @override
  80. String toString() => 'SharedLinkResponseDto[type=$type, id=$id, description=$description, userId=$userId, key=$key, createdAt=$createdAt, expiresAt=$expiresAt, assets=$assets, album=$album, allowUpload=$allowUpload, allowDownload=$allowDownload, showExif=$showExif]';
  81. Map<String, dynamic> toJson() {
  82. final json = <String, dynamic>{};
  83. json[r'type'] = this.type;
  84. json[r'id'] = this.id;
  85. if (this.description != null) {
  86. json[r'description'] = this.description;
  87. } else {
  88. // json[r'description'] = null;
  89. }
  90. json[r'userId'] = this.userId;
  91. json[r'key'] = this.key;
  92. json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
  93. if (this.expiresAt != null) {
  94. json[r'expiresAt'] = this.expiresAt!.toUtc().toIso8601String();
  95. } else {
  96. // json[r'expiresAt'] = null;
  97. }
  98. json[r'assets'] = this.assets;
  99. if (this.album != null) {
  100. json[r'album'] = this.album;
  101. } else {
  102. // json[r'album'] = null;
  103. }
  104. json[r'allowUpload'] = this.allowUpload;
  105. json[r'allowDownload'] = this.allowDownload;
  106. json[r'showExif'] = this.showExif;
  107. return json;
  108. }
  109. /// Returns a new [SharedLinkResponseDto] instance and imports its values from
  110. /// [value] if it's a [Map], null otherwise.
  111. // ignore: prefer_constructors_over_static_methods
  112. static SharedLinkResponseDto? fromJson(dynamic value) {
  113. if (value is Map) {
  114. final json = value.cast<String, dynamic>();
  115. // Ensure that the map contains the required keys.
  116. // Note 1: the values aren't checked for validity beyond being non-null.
  117. // Note 2: this code is stripped in release mode!
  118. assert(() {
  119. requiredKeys.forEach((key) {
  120. assert(json.containsKey(key), 'Required key "SharedLinkResponseDto[$key]" is missing from JSON.');
  121. assert(json[key] != null, 'Required key "SharedLinkResponseDto[$key]" has a null value in JSON.');
  122. });
  123. return true;
  124. }());
  125. return SharedLinkResponseDto(
  126. type: SharedLinkType.fromJson(json[r'type'])!,
  127. id: mapValueOfType<String>(json, r'id')!,
  128. description: mapValueOfType<String>(json, r'description'),
  129. userId: mapValueOfType<String>(json, r'userId')!,
  130. key: mapValueOfType<String>(json, r'key')!,
  131. createdAt: mapDateTime(json, r'createdAt', '')!,
  132. expiresAt: mapDateTime(json, r'expiresAt', ''),
  133. assets: AssetResponseDto.listFromJson(json[r'assets']),
  134. album: AlbumResponseDto.fromJson(json[r'album']),
  135. allowUpload: mapValueOfType<bool>(json, r'allowUpload')!,
  136. allowDownload: mapValueOfType<bool>(json, r'allowDownload')!,
  137. showExif: mapValueOfType<bool>(json, r'showExif')!,
  138. );
  139. }
  140. return null;
  141. }
  142. static List<SharedLinkResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
  143. final result = <SharedLinkResponseDto>[];
  144. if (json is List && json.isNotEmpty) {
  145. for (final row in json) {
  146. final value = SharedLinkResponseDto.fromJson(row);
  147. if (value != null) {
  148. result.add(value);
  149. }
  150. }
  151. }
  152. return result.toList(growable: growable);
  153. }
  154. static Map<String, SharedLinkResponseDto> mapFromJson(dynamic json) {
  155. final map = <String, SharedLinkResponseDto>{};
  156. if (json is Map && json.isNotEmpty) {
  157. json = json.cast<String, dynamic>(); // ignore: parameter_assignments
  158. for (final entry in json.entries) {
  159. final value = SharedLinkResponseDto.fromJson(entry.value);
  160. if (value != null) {
  161. map[entry.key] = value;
  162. }
  163. }
  164. }
  165. return map;
  166. }
  167. // maps a json object with a list of SharedLinkResponseDto-objects as value to a dart map
  168. static Map<String, List<SharedLinkResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
  169. final map = <String, List<SharedLinkResponseDto>>{};
  170. if (json is Map && json.isNotEmpty) {
  171. // ignore: parameter_assignments
  172. json = json.cast<String, dynamic>();
  173. for (final entry in json.entries) {
  174. map[entry.key] = SharedLinkResponseDto.listFromJson(entry.value, growable: growable,);
  175. }
  176. }
  177. return map;
  178. }
  179. /// The list of required keys that must be present in a JSON.
  180. static const requiredKeys = <String>{
  181. 'type',
  182. 'id',
  183. 'userId',
  184. 'key',
  185. 'createdAt',
  186. 'expiresAt',
  187. 'assets',
  188. 'allowUpload',
  189. 'allowDownload',
  190. 'showExif',
  191. };
  192. }