diff --git a/wien_talks/wien_talks_client/lib/src/protocol/client.dart b/wien_talks/wien_talks_client/lib/src/protocol/client.dart index 7fa2180..de9b4df 100644 --- a/wien_talks/wien_talks_client/lib/src/protocol/client.dart +++ b/wien_talks/wien_talks_client/lib/src/protocol/client.dart @@ -32,6 +32,21 @@ class EndpointGreeting extends _i1.EndpointRef { ); } +/// {@category Endpoint} +class EndpointRecipe extends _i1.EndpointRef { + EndpointRecipe(_i1.EndpointCaller caller) : super(caller); + + @override + String get name => 'recipe'; + + _i2.Future postQuote(String quote) => + caller.callServerEndpoint( + 'recipe', + 'postQuote', + {'quote': quote}, + ); +} + class Client extends _i1.ServerpodClientShared { Client( String host, { @@ -59,12 +74,18 @@ class Client extends _i1.ServerpodClientShared { disconnectStreamsOnLostInternetConnection, ) { greeting = EndpointGreeting(this); + recipe = EndpointRecipe(this); } late final EndpointGreeting greeting; + late final EndpointRecipe recipe; + @override - Map get endpointRefLookup => {'greeting': greeting}; + Map get endpointRefLookup => { + 'greeting': greeting, + 'recipe': recipe, + }; @override Map get moduleLookup => {}; diff --git a/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart b/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart index 92603c6..5719c72 100644 --- a/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart +++ b/wien_talks/wien_talks_client/lib/src/protocol/protocol.dart @@ -11,7 +11,11 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod_client/serverpod_client.dart' as _i1; import 'greeting.dart' as _i2; +import 'quotes/create_quote.dart' as _i3; +import 'quotes/quote.dart' as _i4; export 'greeting.dart'; +export 'quotes/create_quote.dart'; +export 'quotes/quote.dart'; export 'client.dart'; class Protocol extends _i1.SerializationManager { @@ -30,9 +34,31 @@ class Protocol extends _i1.SerializationManager { if (t == _i2.Greeting) { return _i2.Greeting.fromJson(data) as T; } + if (t == _i3.CreateQuoteRequest) { + return _i3.CreateQuoteRequest.fromJson(data) as T; + } + if (t == _i4.Quote) { + return _i4.Quote.fromJson(data) as T; + } if (t == _i1.getType<_i2.Greeting?>()) { return (data != null ? _i2.Greeting.fromJson(data) : null) as T; } + if (t == _i1.getType<_i3.CreateQuoteRequest?>()) { + return (data != null ? _i3.CreateQuoteRequest.fromJson(data) : null) as T; + } + if (t == _i1.getType<_i4.Quote?>()) { + return (data != null ? _i4.Quote.fromJson(data) : null) as T; + } + if (t == _i1.getType?>()) { + return (data != null + ? (data as List).map((e) => deserialize(e)).toList() + : null) as T; + } + if (t == _i1.getType?>()) { + return (data != null + ? (data as List).map((e) => deserialize(e)).toList() + : null) as T; + } return super.deserialize(data, t); } @@ -43,6 +69,12 @@ class Protocol extends _i1.SerializationManager { if (data is _i2.Greeting) { return 'Greeting'; } + if (data is _i3.CreateQuoteRequest) { + return 'CreateQuoteRequest'; + } + if (data is _i4.Quote) { + return 'Quote'; + } return null; } @@ -55,6 +87,12 @@ class Protocol extends _i1.SerializationManager { if (dataClassName == 'Greeting') { return deserialize<_i2.Greeting>(data['data']); } + if (dataClassName == 'CreateQuoteRequest') { + return deserialize<_i3.CreateQuoteRequest>(data['data']); + } + if (dataClassName == 'Quote') { + return deserialize<_i4.Quote>(data['data']); + } return super.deserializeByClassName(data); } } diff --git a/wien_talks/wien_talks_client/lib/src/protocol/quotes/create_quote.dart b/wien_talks/wien_talks_client/lib/src/protocol/quotes/create_quote.dart new file mode 100644 index 0000000..8331a85 --- /dev/null +++ b/wien_talks/wien_talks_client/lib/src/protocol/quotes/create_quote.dart @@ -0,0 +1,116 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod_client/serverpod_client.dart' as _i1; + +abstract class CreateQuoteRequest implements _i1.SerializableModel { + CreateQuoteRequest._({ + required this.text, + this.authorName, + required this.lat, + required this.lng, + this.tags, + }); + + factory CreateQuoteRequest({ + required String text, + String? authorName, + required double lat, + required double lng, + List? tags, + }) = _CreateQuoteRequestImpl; + + factory CreateQuoteRequest.fromJson(Map jsonSerialization) { + return CreateQuoteRequest( + text: jsonSerialization['text'] as String, + authorName: jsonSerialization['authorName'] as String?, + lat: (jsonSerialization['lat'] as num).toDouble(), + lng: (jsonSerialization['lng'] as num).toDouble(), + tags: (jsonSerialization['tags'] as List?) + ?.map((e) => e as String) + .toList(), + ); + } + + String text; + + String? authorName; + + double lat; + + double lng; + + List? tags; + + /// Returns a shallow copy of this [CreateQuoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + CreateQuoteRequest copyWith({ + String? text, + String? authorName, + double? lat, + double? lng, + List? tags, + }); + @override + Map toJson() { + return { + 'text': text, + if (authorName != null) 'authorName': authorName, + 'lat': lat, + 'lng': lng, + if (tags != null) 'tags': tags?.toJson(), + }; + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _CreateQuoteRequestImpl extends CreateQuoteRequest { + _CreateQuoteRequestImpl({ + required String text, + String? authorName, + required double lat, + required double lng, + List? tags, + }) : super._( + text: text, + authorName: authorName, + lat: lat, + lng: lng, + tags: tags, + ); + + /// Returns a shallow copy of this [CreateQuoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + CreateQuoteRequest copyWith({ + String? text, + Object? authorName = _Undefined, + double? lat, + double? lng, + Object? tags = _Undefined, + }) { + return CreateQuoteRequest( + text: text ?? this.text, + authorName: authorName is String? ? authorName : this.authorName, + lat: lat ?? this.lat, + lng: lng ?? this.lng, + tags: tags is List? ? tags : this.tags?.map((e0) => e0).toList(), + ); + } +} diff --git a/wien_talks/wien_talks_client/lib/src/protocol/quotes/quote.dart b/wien_talks/wien_talks_client/lib/src/protocol/quotes/quote.dart new file mode 100644 index 0000000..20d381a --- /dev/null +++ b/wien_talks/wien_talks_client/lib/src/protocol/quotes/quote.dart @@ -0,0 +1,194 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod_client/serverpod_client.dart' as _i1; + +abstract class Quote implements _i1.SerializableModel { + Quote._({ + required this.id, + required this.userId, + required this.text, + this.authorName, + required this.lat, + required this.lng, + required this.geohash, + required this.createdAt, + required this.visibility, + required this.upvotes, + required this.downvotes, + this.tags, + }); + + factory Quote({ + required int id, + required int userId, + required String text, + String? authorName, + required double lat, + required double lng, + required String geohash, + required DateTime createdAt, + required int visibility, + required int upvotes, + required int downvotes, + List? tags, + }) = _QuoteImpl; + + factory Quote.fromJson(Map jsonSerialization) { + return Quote( + id: jsonSerialization['id'] as int, + userId: jsonSerialization['userId'] as int, + text: jsonSerialization['text'] as String, + authorName: jsonSerialization['authorName'] as String?, + lat: (jsonSerialization['lat'] as num).toDouble(), + lng: (jsonSerialization['lng'] as num).toDouble(), + geohash: jsonSerialization['geohash'] as String, + createdAt: + _i1.DateTimeJsonExtension.fromJson(jsonSerialization['createdAt']), + visibility: jsonSerialization['visibility'] as int, + upvotes: jsonSerialization['upvotes'] as int, + downvotes: jsonSerialization['downvotes'] as int, + tags: (jsonSerialization['tags'] as List?) + ?.map((e) => e as String) + .toList(), + ); + } + + int id; + + int userId; + + String text; + + String? authorName; + + double lat; + + double lng; + + String geohash; + + DateTime createdAt; + + int visibility; + + int upvotes; + + int downvotes; + + List? tags; + + /// Returns a shallow copy of this [Quote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + Quote copyWith({ + int? id, + int? userId, + String? text, + String? authorName, + double? lat, + double? lng, + String? geohash, + DateTime? createdAt, + int? visibility, + int? upvotes, + int? downvotes, + List? tags, + }); + @override + Map toJson() { + return { + 'id': id, + 'userId': userId, + 'text': text, + if (authorName != null) 'authorName': authorName, + 'lat': lat, + 'lng': lng, + 'geohash': geohash, + 'createdAt': createdAt.toJson(), + 'visibility': visibility, + 'upvotes': upvotes, + 'downvotes': downvotes, + if (tags != null) 'tags': tags?.toJson(), + }; + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _QuoteImpl extends Quote { + _QuoteImpl({ + required int id, + required int userId, + required String text, + String? authorName, + required double lat, + required double lng, + required String geohash, + required DateTime createdAt, + required int visibility, + required int upvotes, + required int downvotes, + List? tags, + }) : super._( + id: id, + userId: userId, + text: text, + authorName: authorName, + lat: lat, + lng: lng, + geohash: geohash, + createdAt: createdAt, + visibility: visibility, + upvotes: upvotes, + downvotes: downvotes, + tags: tags, + ); + + /// Returns a shallow copy of this [Quote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + Quote copyWith({ + int? id, + int? userId, + String? text, + Object? authorName = _Undefined, + double? lat, + double? lng, + String? geohash, + DateTime? createdAt, + int? visibility, + int? upvotes, + int? downvotes, + Object? tags = _Undefined, + }) { + return Quote( + id: id ?? this.id, + userId: userId ?? this.userId, + text: text ?? this.text, + authorName: authorName is String? ? authorName : this.authorName, + lat: lat ?? this.lat, + lng: lng ?? this.lng, + geohash: geohash ?? this.geohash, + createdAt: createdAt ?? this.createdAt, + visibility: visibility ?? this.visibility, + upvotes: upvotes ?? this.upvotes, + downvotes: downvotes ?? this.downvotes, + tags: tags is List? ? tags : this.tags?.map((e0) => e0).toList(), + ); + } +} diff --git a/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart b/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart index 25c4573..399a21e 100644 --- a/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart +++ b/wien_talks/wien_talks_server/lib/src/generated/endpoints.dart @@ -11,6 +11,7 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod/serverpod.dart' as _i1; import '../greeting_endpoint.dart' as _i2; +import '../quotes/location_endpoint.dart' as _i3; class Endpoints extends _i1.EndpointDispatch { @override @@ -21,7 +22,13 @@ class Endpoints extends _i1.EndpointDispatch { server, 'greeting', null, - ) + ), + 'recipe': _i3.RecipeEndpoint() + ..initialize( + server, + 'recipe', + null, + ), }; connectors['greeting'] = _i1.EndpointConnector( name: 'greeting', @@ -47,5 +54,29 @@ class Endpoints extends _i1.EndpointDispatch { ) }, ); + connectors['recipe'] = _i1.EndpointConnector( + name: 'recipe', + endpoint: endpoints['recipe']!, + methodConnectors: { + 'postQuote': _i1.MethodConnector( + name: 'postQuote', + params: { + 'quote': _i1.ParameterDescription( + name: 'quote', + type: _i1.getType(), + nullable: false, + ) + }, + call: ( + _i1.Session session, + Map params, + ) async => + (endpoints['recipe'] as _i3.RecipeEndpoint).postQuote( + session, + params['quote'], + ), + ) + }, + ); } } diff --git a/wien_talks/wien_talks_server/lib/src/generated/protocol.dart b/wien_talks/wien_talks_server/lib/src/generated/protocol.dart index 1bd69cc..7187a0b 100644 --- a/wien_talks/wien_talks_server/lib/src/generated/protocol.dart +++ b/wien_talks/wien_talks_server/lib/src/generated/protocol.dart @@ -12,7 +12,11 @@ import 'package:serverpod/serverpod.dart' as _i1; import 'package:serverpod/protocol.dart' as _i2; import 'greeting.dart' as _i3; +import 'quotes/create_quote.dart' as _i4; +import 'quotes/quote.dart' as _i5; export 'greeting.dart'; +export 'quotes/create_quote.dart'; +export 'quotes/quote.dart'; class Protocol extends _i1.SerializationManagerServer { Protocol._(); @@ -34,9 +38,31 @@ class Protocol extends _i1.SerializationManagerServer { if (t == _i3.Greeting) { return _i3.Greeting.fromJson(data) as T; } + if (t == _i4.CreateQuoteRequest) { + return _i4.CreateQuoteRequest.fromJson(data) as T; + } + if (t == _i5.Quote) { + return _i5.Quote.fromJson(data) as T; + } if (t == _i1.getType<_i3.Greeting?>()) { return (data != null ? _i3.Greeting.fromJson(data) : null) as T; } + if (t == _i1.getType<_i4.CreateQuoteRequest?>()) { + return (data != null ? _i4.CreateQuoteRequest.fromJson(data) : null) as T; + } + if (t == _i1.getType<_i5.Quote?>()) { + return (data != null ? _i5.Quote.fromJson(data) : null) as T; + } + if (t == _i1.getType?>()) { + return (data != null + ? (data as List).map((e) => deserialize(e)).toList() + : null) as T; + } + if (t == _i1.getType?>()) { + return (data != null + ? (data as List).map((e) => deserialize(e)).toList() + : null) as T; + } try { return _i2.Protocol().deserialize(data, t); } on _i1.DeserializationTypeNotFoundException catch (_) {} @@ -50,6 +76,12 @@ class Protocol extends _i1.SerializationManagerServer { if (data is _i3.Greeting) { return 'Greeting'; } + if (data is _i4.CreateQuoteRequest) { + return 'CreateQuoteRequest'; + } + if (data is _i5.Quote) { + return 'Quote'; + } className = _i2.Protocol().getClassNameForObject(data); if (className != null) { return 'serverpod.$className'; @@ -66,6 +98,12 @@ class Protocol extends _i1.SerializationManagerServer { if (dataClassName == 'Greeting') { return deserialize<_i3.Greeting>(data['data']); } + if (dataClassName == 'CreateQuoteRequest') { + return deserialize<_i4.CreateQuoteRequest>(data['data']); + } + if (dataClassName == 'Quote') { + return deserialize<_i5.Quote>(data['data']); + } if (dataClassName.startsWith('serverpod.')) { data['className'] = dataClassName.substring(10); return _i2.Protocol().deserializeByClassName(data); diff --git a/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml b/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml index 9a4113d..2f46503 100644 --- a/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml +++ b/wien_talks/wien_talks_server/lib/src/generated/protocol.yaml @@ -1,2 +1,4 @@ greeting: - hello: +recipe: + - postQuote: diff --git a/wien_talks/wien_talks_server/lib/src/generated/quotes/create_quote.dart b/wien_talks/wien_talks_server/lib/src/generated/quotes/create_quote.dart new file mode 100644 index 0000000..8b4a986 --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/generated/quotes/create_quote.dart @@ -0,0 +1,128 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod/serverpod.dart' as _i1; + +abstract class CreateQuoteRequest + implements _i1.SerializableModel, _i1.ProtocolSerialization { + CreateQuoteRequest._({ + required this.text, + this.authorName, + required this.lat, + required this.lng, + this.tags, + }); + + factory CreateQuoteRequest({ + required String text, + String? authorName, + required double lat, + required double lng, + List? tags, + }) = _CreateQuoteRequestImpl; + + factory CreateQuoteRequest.fromJson(Map jsonSerialization) { + return CreateQuoteRequest( + text: jsonSerialization['text'] as String, + authorName: jsonSerialization['authorName'] as String?, + lat: (jsonSerialization['lat'] as num).toDouble(), + lng: (jsonSerialization['lng'] as num).toDouble(), + tags: (jsonSerialization['tags'] as List?) + ?.map((e) => e as String) + .toList(), + ); + } + + String text; + + String? authorName; + + double lat; + + double lng; + + List? tags; + + /// Returns a shallow copy of this [CreateQuoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + CreateQuoteRequest copyWith({ + String? text, + String? authorName, + double? lat, + double? lng, + List? tags, + }); + @override + Map toJson() { + return { + 'text': text, + if (authorName != null) 'authorName': authorName, + 'lat': lat, + 'lng': lng, + if (tags != null) 'tags': tags?.toJson(), + }; + } + + @override + Map toJsonForProtocol() { + return { + 'text': text, + if (authorName != null) 'authorName': authorName, + 'lat': lat, + 'lng': lng, + if (tags != null) 'tags': tags?.toJson(), + }; + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _CreateQuoteRequestImpl extends CreateQuoteRequest { + _CreateQuoteRequestImpl({ + required String text, + String? authorName, + required double lat, + required double lng, + List? tags, + }) : super._( + text: text, + authorName: authorName, + lat: lat, + lng: lng, + tags: tags, + ); + + /// Returns a shallow copy of this [CreateQuoteRequest] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + CreateQuoteRequest copyWith({ + String? text, + Object? authorName = _Undefined, + double? lat, + double? lng, + Object? tags = _Undefined, + }) { + return CreateQuoteRequest( + text: text ?? this.text, + authorName: authorName is String? ? authorName : this.authorName, + lat: lat ?? this.lat, + lng: lng ?? this.lng, + tags: tags is List? ? tags : this.tags?.map((e0) => e0).toList(), + ); + } +} diff --git a/wien_talks/wien_talks_server/lib/src/generated/quotes/quote.dart b/wien_talks/wien_talks_server/lib/src/generated/quotes/quote.dart new file mode 100644 index 0000000..8e1ee3a --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/generated/quotes/quote.dart @@ -0,0 +1,213 @@ +/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ +/* To generate run: "serverpod generate" */ + +// ignore_for_file: implementation_imports +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: public_member_api_docs +// ignore_for_file: type_literal_in_constant_pattern +// ignore_for_file: use_super_parameters + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:serverpod/serverpod.dart' as _i1; + +abstract class Quote + implements _i1.SerializableModel, _i1.ProtocolSerialization { + Quote._({ + required this.id, + required this.userId, + required this.text, + this.authorName, + required this.lat, + required this.lng, + required this.geohash, + required this.createdAt, + required this.visibility, + required this.upvotes, + required this.downvotes, + this.tags, + }); + + factory Quote({ + required int id, + required int userId, + required String text, + String? authorName, + required double lat, + required double lng, + required String geohash, + required DateTime createdAt, + required int visibility, + required int upvotes, + required int downvotes, + List? tags, + }) = _QuoteImpl; + + factory Quote.fromJson(Map jsonSerialization) { + return Quote( + id: jsonSerialization['id'] as int, + userId: jsonSerialization['userId'] as int, + text: jsonSerialization['text'] as String, + authorName: jsonSerialization['authorName'] as String?, + lat: (jsonSerialization['lat'] as num).toDouble(), + lng: (jsonSerialization['lng'] as num).toDouble(), + geohash: jsonSerialization['geohash'] as String, + createdAt: + _i1.DateTimeJsonExtension.fromJson(jsonSerialization['createdAt']), + visibility: jsonSerialization['visibility'] as int, + upvotes: jsonSerialization['upvotes'] as int, + downvotes: jsonSerialization['downvotes'] as int, + tags: (jsonSerialization['tags'] as List?) + ?.map((e) => e as String) + .toList(), + ); + } + + int id; + + int userId; + + String text; + + String? authorName; + + double lat; + + double lng; + + String geohash; + + DateTime createdAt; + + int visibility; + + int upvotes; + + int downvotes; + + List? tags; + + /// Returns a shallow copy of this [Quote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + Quote copyWith({ + int? id, + int? userId, + String? text, + String? authorName, + double? lat, + double? lng, + String? geohash, + DateTime? createdAt, + int? visibility, + int? upvotes, + int? downvotes, + List? tags, + }); + @override + Map toJson() { + return { + 'id': id, + 'userId': userId, + 'text': text, + if (authorName != null) 'authorName': authorName, + 'lat': lat, + 'lng': lng, + 'geohash': geohash, + 'createdAt': createdAt.toJson(), + 'visibility': visibility, + 'upvotes': upvotes, + 'downvotes': downvotes, + if (tags != null) 'tags': tags?.toJson(), + }; + } + + @override + Map toJsonForProtocol() { + return { + 'id': id, + 'userId': userId, + 'text': text, + if (authorName != null) 'authorName': authorName, + 'lat': lat, + 'lng': lng, + 'geohash': geohash, + 'createdAt': createdAt.toJson(), + 'visibility': visibility, + 'upvotes': upvotes, + 'downvotes': downvotes, + if (tags != null) 'tags': tags?.toJson(), + }; + } + + @override + String toString() { + return _i1.SerializationManager.encode(this); + } +} + +class _Undefined {} + +class _QuoteImpl extends Quote { + _QuoteImpl({ + required int id, + required int userId, + required String text, + String? authorName, + required double lat, + required double lng, + required String geohash, + required DateTime createdAt, + required int visibility, + required int upvotes, + required int downvotes, + List? tags, + }) : super._( + id: id, + userId: userId, + text: text, + authorName: authorName, + lat: lat, + lng: lng, + geohash: geohash, + createdAt: createdAt, + visibility: visibility, + upvotes: upvotes, + downvotes: downvotes, + tags: tags, + ); + + /// Returns a shallow copy of this [Quote] + /// with some or all fields replaced by the given arguments. + @_i1.useResult + @override + Quote copyWith({ + int? id, + int? userId, + String? text, + Object? authorName = _Undefined, + double? lat, + double? lng, + String? geohash, + DateTime? createdAt, + int? visibility, + int? upvotes, + int? downvotes, + Object? tags = _Undefined, + }) { + return Quote( + id: id ?? this.id, + userId: userId ?? this.userId, + text: text ?? this.text, + authorName: authorName is String? ? authorName : this.authorName, + lat: lat ?? this.lat, + lng: lng ?? this.lng, + geohash: geohash ?? this.geohash, + createdAt: createdAt ?? this.createdAt, + visibility: visibility ?? this.visibility, + upvotes: upvotes ?? this.upvotes, + downvotes: downvotes ?? this.downvotes, + tags: tags is List? ? tags : this.tags?.map((e0) => e0).toList(), + ); + } +} diff --git a/wien_talks/wien_talks_server/lib/src/quotes/create_quote.spy.yaml b/wien_talks/wien_talks_server/lib/src/quotes/create_quote.spy.yaml new file mode 100644 index 0000000..799ba9d --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/quotes/create_quote.spy.yaml @@ -0,0 +1,7 @@ + class: CreateQuoteRequest + fields: + text: String + authorName: String? + lat: double + lng: double + tags: List? diff --git a/wien_talks/wien_talks_server/lib/src/quotes/location_endpoint.dart b/wien_talks/wien_talks_server/lib/src/quotes/location_endpoint.dart new file mode 100644 index 0000000..406eb7d --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/quotes/location_endpoint.dart @@ -0,0 +1,12 @@ +import 'dart:async'; + +import 'package:serverpod/serverpod.dart'; + +class RecipeEndpoint extends Endpoint { + Future postQuote(Session session, String quote) async { + // validate content + + // persist quote + return Future.value('none'); + } +} diff --git a/wien_talks/wien_talks_server/lib/src/quotes/quote.spy.yaml b/wien_talks/wien_talks_server/lib/src/quotes/quote.spy.yaml new file mode 100644 index 0000000..f84c340 --- /dev/null +++ b/wien_talks/wien_talks_server/lib/src/quotes/quote.spy.yaml @@ -0,0 +1,14 @@ +class: Quote +fields: + id: int + userId: int + text: String + authorName: String? + lat: double + lng: double + geohash: String + createdAt: DateTime + visibility: int + upvotes: int + downvotes: int + tags: List? diff --git a/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart b/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart index d9ec37d..02dbd91 100644 --- a/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart +++ b/wien_talks/wien_talks_server/test/integration/test_tools/serverpod_test_tools.dart @@ -102,6 +102,8 @@ void withServerpod( class TestEndpoints { late final _GreetingEndpoint greeting; + + late final _RecipeEndpoint recipe; } class _InternalTestEndpoints extends TestEndpoints @@ -115,6 +117,10 @@ class _InternalTestEndpoints extends TestEndpoints endpoints, serializationManager, ); + recipe = _RecipeEndpoint( + endpoints, + serializationManager, + ); } } @@ -157,3 +163,43 @@ class _GreetingEndpoint { }); } } + +class _RecipeEndpoint { + _RecipeEndpoint( + this._endpointDispatch, + this._serializationManager, + ); + + final _i2.EndpointDispatch _endpointDispatch; + + final _i2.SerializationManager _serializationManager; + + _i3.Future postQuote( + _i1.TestSessionBuilder sessionBuilder, + String quote, + ) async { + return _i1.callAwaitableFunctionAndHandleExceptions(() async { + var _localUniqueSession = + (sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild( + endpoint: 'recipe', + method: 'postQuote', + ); + try { + var _localCallContext = await _endpointDispatch.getMethodCallContext( + createSessionCallback: (_) => _localUniqueSession, + endpointPath: 'recipe', + methodName: 'postQuote', + parameters: _i1.testObjectToJson({'quote': quote}), + serializationManager: _serializationManager, + ); + var _localReturnValue = await (_localCallContext.method.call( + _localUniqueSession, + _localCallContext.arguments, + ) as _i3.Future); + return _localReturnValue; + } finally { + await _localUniqueSession.close(); + } + }); + } +}