mirror of
https://github.com/timokz/flutter-vienna-hackathon-25.git
synced 2025-11-08 23:44:19 +01:00
Compare commits
No commits in common. "33c98019bbab9987df5c2864ca130752ee1a14a4" and "1ef6e06329581097b9888c377d599aa61f250697" have entirely different histories.
33c98019bb
...
1ef6e06329
9 changed files with 221 additions and 237 deletions
|
|
@ -23,13 +23,6 @@ class EndpointQuote extends _i1.EndpointRef {
|
||||||
@override
|
@override
|
||||||
String get name => 'quote';
|
String get name => 'quote';
|
||||||
|
|
||||||
_i2.Future<_i3.Quote> createQuote(_i4.CreateQuoteRequest req) =>
|
|
||||||
caller.callServerEndpoint<_i3.Quote>(
|
|
||||||
'quote',
|
|
||||||
'createQuote',
|
|
||||||
{'req': req},
|
|
||||||
);
|
|
||||||
|
|
||||||
_i2.Future<void> updateQuote(_i3.Quote quote) =>
|
_i2.Future<void> updateQuote(_i3.Quote quote) =>
|
||||||
caller.callServerEndpoint<void>(
|
caller.callServerEndpoint<void>(
|
||||||
'quote',
|
'quote',
|
||||||
|
|
@ -37,11 +30,33 @@ class EndpointQuote extends _i1.EndpointRef {
|
||||||
{'quote': quote},
|
{'quote': quote},
|
||||||
);
|
);
|
||||||
|
|
||||||
_i2.Future<List<_i3.Quote>> getAllQuotes({required int limit}) =>
|
_i2.Stream<_i3.Quote> quoteUpdates() =>
|
||||||
|
caller.callStreamingServerEndpoint<_i2.Stream<_i3.Quote>, _i3.Quote>(
|
||||||
|
'quote',
|
||||||
|
'quoteUpdates',
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
_i2.Future<_i3.Quote> createQuote(_i4.CreateQuoteRequest req) =>
|
||||||
|
caller.callServerEndpoint<_i3.Quote>(
|
||||||
|
'quote',
|
||||||
|
'createQuote',
|
||||||
|
{'req': req},
|
||||||
|
);
|
||||||
|
|
||||||
|
_i2.Future<_i3.Quote> getQuoteById(int id) =>
|
||||||
|
caller.callServerEndpoint<_i3.Quote>(
|
||||||
|
'quote',
|
||||||
|
'getQuoteById',
|
||||||
|
{'id': id},
|
||||||
|
);
|
||||||
|
|
||||||
|
_i2.Future<List<_i3.Quote>> getAllQuotes() =>
|
||||||
caller.callServerEndpoint<List<_i3.Quote>>(
|
caller.callServerEndpoint<List<_i3.Quote>>(
|
||||||
'quote',
|
'quote',
|
||||||
'getAllQuotes',
|
'getAllQuotes',
|
||||||
{'limit': limit},
|
{},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import 'package:wien_talks_flutter/helper/funmap_mgr.dart';
|
||||||
import 'package:wien_talks_flutter/helper/go_router.dart';
|
import 'package:wien_talks_flutter/helper/go_router.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
FunmapMgr().configure();
|
FunmapMgr();
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:wien_talks_flutter/show_latest_news_widget.dart';
|
|
||||||
import 'package:wien_talks_flutter/widgets/heading_text.dart';
|
|
||||||
import 'package:wien_talks_flutter/widgets/screen_widget.dart';
|
|
||||||
|
|
||||||
class NewsScreen extends StatelessWidget {
|
|
||||||
const NewsScreen({
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ScreenWidget(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
HeadingText(text: "Latest news"),
|
|
||||||
ShowLatestNewsWidget(),
|
|
||||||
SizedBox(
|
|
||||||
height: 30,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
context.pushNamed("create_event");
|
|
||||||
},
|
|
||||||
child: Text("Submit your own event")),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,87 +1,24 @@
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:wien_talks_client/wien_talks_client.dart';
|
import 'package:wien_talks_flutter/widgets/heading_text.dart';
|
||||||
import 'package:wien_talks_flutter/helper/funmap_mgr.dart';
|
|
||||||
|
|
||||||
class ShowLatestNewsWidget extends StatefulWidget {
|
import 'helper/funmap_mgr.dart';
|
||||||
|
|
||||||
|
class ShowLatestNewsWidget extends StatelessWidget {
|
||||||
const ShowLatestNewsWidget({super.key});
|
const ShowLatestNewsWidget({super.key});
|
||||||
@override
|
|
||||||
State<ShowLatestNewsWidget> createState() => _ShowLatestNewsWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ShowLatestNewsWidgetState extends State<ShowLatestNewsWidget> {
|
|
||||||
final _controller = StreamController<List<Quote>>.broadcast();
|
|
||||||
Timer? _timer;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_reload();
|
|
||||||
_timer = Timer.periodic(const Duration(seconds: 30), (_) => _reload());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _reload() async {
|
|
||||||
try {
|
|
||||||
final quotes = await FunmapMgr().client.quote.getAllQuotes(limit: 200);
|
|
||||||
_controller.add(quotes);
|
|
||||||
} catch (e, st) {
|
|
||||||
_controller.addError(e, st);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_timer?.cancel();
|
|
||||||
_controller.close();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RefreshIndicator(
|
return StreamBuilder(
|
||||||
onRefresh: _reload,
|
stream: FunmapMgr().client.quote.stream,
|
||||||
child: StreamBuilder<List<Quote>>(
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
stream: _controller.stream,
|
return Column(
|
||||||
initialData: const <Quote>[],
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
builder: (context, snap) {
|
children: [
|
||||||
if (snap.hasError) {
|
HeadingText(text: "Latest news"),
|
||||||
return ListView(
|
if (snapshot.hasError) Text('Error: ${snapshot.error}'),
|
||||||
children: [
|
Text(snapshot.data ?? "Be the first to submit amazing news!", style: TextStyle(fontSize: 20, color: Theme.of(context).colorScheme.error)),
|
||||||
Padding(
|
],
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Text('Error: ${snap.error}'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final quotes = snap.data ?? const <Quote>[];
|
|
||||||
if (quotes.isEmpty) {
|
|
||||||
return ListView(
|
|
||||||
children: const [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(16),
|
|
||||||
child: Text('No quotes yet. Pull to refresh.'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return ListView.separated(
|
|
||||||
itemCount: quotes.length,
|
|
||||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
|
||||||
itemBuilder: (context, i) {
|
|
||||||
final q = quotes[i];
|
|
||||||
return ListTile(
|
|
||||||
title: Text(q.text),
|
|
||||||
subtitle: Text([
|
|
||||||
if ((q.authorName ?? '').isNotEmpty) q.authorName!,
|
|
||||||
q.createdAt.toLocal().toString(),
|
|
||||||
].where((e) => e.isNotEmpty).join(' · ')),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'package:serverpod/serverpod.dart' as _i1;
|
import 'package:serverpod/serverpod.dart' as _i1;
|
||||||
import '../quotes/quotes_endpoint.dart' as _i2;
|
import '../quotes/quotes_endpoint.dart' as _i2;
|
||||||
|
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i3;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
||||||
as _i3;
|
as _i4;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i4;
|
|
||||||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i5;
|
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i5;
|
||||||
|
|
||||||
class Endpoints extends _i1.EndpointDispatch {
|
class Endpoints extends _i1.EndpointDispatch {
|
||||||
|
|
@ -31,30 +31,12 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
name: 'quote',
|
name: 'quote',
|
||||||
endpoint: endpoints['quote']!,
|
endpoint: endpoints['quote']!,
|
||||||
methodConnectors: {
|
methodConnectors: {
|
||||||
'createQuote': _i1.MethodConnector(
|
|
||||||
name: 'createQuote',
|
|
||||||
params: {
|
|
||||||
'req': _i1.ParameterDescription(
|
|
||||||
name: 'req',
|
|
||||||
type: _i1.getType<_i3.CreateQuoteRequest>(),
|
|
||||||
nullable: false,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
call: (
|
|
||||||
_i1.Session session,
|
|
||||||
Map<String, dynamic> params,
|
|
||||||
) async =>
|
|
||||||
(endpoints['quote'] as _i2.QuoteEndpoint).createQuote(
|
|
||||||
session,
|
|
||||||
params['req'],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'updateQuote': _i1.MethodConnector(
|
'updateQuote': _i1.MethodConnector(
|
||||||
name: 'updateQuote',
|
name: 'updateQuote',
|
||||||
params: {
|
params: {
|
||||||
'quote': _i1.ParameterDescription(
|
'quote': _i1.ParameterDescription(
|
||||||
name: 'quote',
|
name: 'quote',
|
||||||
type: _i1.getType<_i4.Quote>(),
|
type: _i1.getType<_i3.Quote>(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -67,11 +49,29 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
params['quote'],
|
params['quote'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'getAllQuotes': _i1.MethodConnector(
|
'createQuote': _i1.MethodConnector(
|
||||||
name: 'getAllQuotes',
|
name: 'createQuote',
|
||||||
params: {
|
params: {
|
||||||
'limit': _i1.ParameterDescription(
|
'req': _i1.ParameterDescription(
|
||||||
name: 'limit',
|
name: 'req',
|
||||||
|
type: _i1.getType<_i4.CreateQuoteRequest>(),
|
||||||
|
nullable: false,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
call: (
|
||||||
|
_i1.Session session,
|
||||||
|
Map<String, dynamic> params,
|
||||||
|
) async =>
|
||||||
|
(endpoints['quote'] as _i2.QuoteEndpoint).createQuote(
|
||||||
|
session,
|
||||||
|
params['req'],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'getQuoteById': _i1.MethodConnector(
|
||||||
|
name: 'getQuoteById',
|
||||||
|
params: {
|
||||||
|
'id': _i1.ParameterDescription(
|
||||||
|
name: 'id',
|
||||||
type: _i1.getType<int>(),
|
type: _i1.getType<int>(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
)
|
)
|
||||||
|
|
@ -80,11 +80,32 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['quote'] as _i2.QuoteEndpoint).getAllQuotes(
|
(endpoints['quote'] as _i2.QuoteEndpoint).getQuoteById(
|
||||||
session,
|
session,
|
||||||
limit: params['limit'],
|
params['id'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
'getAllQuotes': _i1.MethodConnector(
|
||||||
|
name: 'getAllQuotes',
|
||||||
|
params: {},
|
||||||
|
call: (
|
||||||
|
_i1.Session session,
|
||||||
|
Map<String, dynamic> params,
|
||||||
|
) async =>
|
||||||
|
(endpoints['quote'] as _i2.QuoteEndpoint).getAllQuotes(session),
|
||||||
|
),
|
||||||
|
'quoteUpdates': _i1.MethodStreamConnector(
|
||||||
|
name: 'quoteUpdates',
|
||||||
|
params: {},
|
||||||
|
streamParams: {},
|
||||||
|
returnType: _i1.MethodStreamReturnType.streamType,
|
||||||
|
call: (
|
||||||
|
_i1.Session session,
|
||||||
|
Map<String, dynamic> params,
|
||||||
|
Map<String, Stream> streamParams,
|
||||||
|
) =>
|
||||||
|
(endpoints['quote'] as _i2.QuoteEndpoint).quoteUpdates(session),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
modules['serverpod_auth'] = _i5.Endpoints()..initializeEndpoints(server);
|
modules['serverpod_auth'] = _i5.Endpoints()..initializeEndpoints(server);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
quote:
|
quote:
|
||||||
- createQuote:
|
|
||||||
- updateQuote:
|
- updateQuote:
|
||||||
|
- quoteUpdates:
|
||||||
|
- createQuote:
|
||||||
|
- getQuoteById:
|
||||||
- getAllQuotes:
|
- getAllQuotes:
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,34 @@
|
||||||
// lib/src/endpoints/quote_endpoint.dart
|
import 'dart:math';
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:serverpod/serverpod.dart';
|
import 'package:serverpod/serverpod.dart';
|
||||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
import 'package:wien_talks_server/src/generated/protocol.dart';
|
||||||
import 'package:wien_talks_server/src/quotes/quote_util.dart';
|
import 'package:wien_talks_server/src/quotes/quote_util.dart';
|
||||||
|
|
||||||
class ShowLatestNewsWidget extends Endpoint {
|
class QuoteEndpoint extends Endpoint {
|
||||||
static const _channelQuoteUpdates = 'quote-updates';
|
static const _channelQuoteUpdates = 'quote-updates';
|
||||||
|
|
||||||
|
Future<void> updateQuote(Session session, Quote quote) async {
|
||||||
|
await Quote.db.updateRow(session, quote);
|
||||||
|
await session.messages.postMessage(_channelQuoteUpdates, quote);
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<Quote> quoteUpdates(Session session) async* {
|
||||||
|
var updateStream =
|
||||||
|
session.messages.createStream<Quote>(_channelQuoteUpdates);
|
||||||
|
|
||||||
|
await for (var quote in updateStream) {
|
||||||
|
yield quote;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<Quote> createQuote(Session session, CreateQuoteRequest req) async {
|
Future<Quote> createQuote(Session session, CreateQuoteRequest req) async {
|
||||||
final authInfo = await session.authenticated;
|
final authInfo = await session.authenticated;
|
||||||
final userId = authInfo?.userId;
|
final userId = Random().nextInt(100);
|
||||||
|
|
||||||
final text = validateQuote(req);
|
String text = validateQuote(req);
|
||||||
|
|
||||||
final toInsert = Quote(
|
final quote = Quote(
|
||||||
id: 0,
|
userId: userId,
|
||||||
userId: userId ?? 12,
|
|
||||||
text: text,
|
text: text,
|
||||||
authorName: req.authorName,
|
authorName: req.authorName,
|
||||||
lat: req.lat,
|
lat: req.lat,
|
||||||
|
|
@ -27,61 +39,36 @@ class ShowLatestNewsWidget extends Endpoint {
|
||||||
downvotes: 0,
|
downvotes: 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
final inserted = await session.db.insertRow<Quote>(toInsert);
|
final inserted = await session.db.insertRow<Quote>(quote);
|
||||||
await session.messages.postMessage(_channelQuoteUpdates, inserted);
|
await session.messages.postMessage(_channelQuoteUpdates, quote);
|
||||||
|
|
||||||
return inserted;
|
return inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateQuote(Session session, Quote quote) async {
|
Future<Quote> getQuoteById(Session session, int id) async {
|
||||||
await Quote.db.updateRow(session, quote);
|
final quote = await Quote.db.findById(session, id);
|
||||||
await session.messages.postMessage(_channelQuoteUpdates, quote);
|
if (quote != null) {
|
||||||
|
return quote;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw Exception('Quote not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Quote>> getAllQuotes(Session session, {int limit = 200}) async {
|
Future<List<Quote>> getAllQuotes(Session session) async {
|
||||||
final quoteList = await Quote.db.find(session);
|
final quotes = await Quote.db.find(session);
|
||||||
return quoteList;
|
return quotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Stream<Quote>> streamAllQuotes(StreamingSession session,
|
Stream streamAllQuotes(
|
||||||
{int limit = 200}) async {
|
StreamingSession session, {
|
||||||
|
int limit = 200,
|
||||||
|
}) async* {
|
||||||
if (limit <= 0 || limit > 500) limit = 200;
|
if (limit <= 0 || limit > 500) limit = 200;
|
||||||
|
|
||||||
final controller = StreamController<Quote>();
|
final quoteStream = session.messages.createStream<Quote>('quotes');
|
||||||
final live = session.messages.createStream<Quote>(_channelQuoteUpdates);
|
|
||||||
final liveSub = live.listen(
|
|
||||||
(q) {
|
|
||||||
if (q.visibility == 0) controller.add(q);
|
|
||||||
},
|
|
||||||
onError: controller.addError,
|
|
||||||
onDone: () {
|
|
||||||
if (!controller.isClosed) controller.close();
|
|
||||||
},
|
|
||||||
cancelOnError: false,
|
|
||||||
);
|
|
||||||
|
|
||||||
() async* {
|
await for (final Quote quote in quoteStream) {
|
||||||
try {
|
yield quote;
|
||||||
final snapshot = await Quote.db.find(
|
}
|
||||||
session,
|
|
||||||
where: (t) => t.visibility.equals(0),
|
|
||||||
orderBy: (t) => t.createdAt,
|
|
||||||
orderDescending: true,
|
|
||||||
limit: limit,
|
|
||||||
);
|
|
||||||
|
|
||||||
for (final q in snapshot.reversed) {
|
|
||||||
controller.add(q);
|
|
||||||
}
|
|
||||||
} catch (e, st) {
|
|
||||||
controller.addError(e, st);
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
await session.close().then((_) async {
|
|
||||||
await liveSub.cancel();
|
|
||||||
await controller.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
return controller.stream;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,35 +130,6 @@ class _QuoteEndpoint {
|
||||||
|
|
||||||
final _i2.SerializationManager _serializationManager;
|
final _i2.SerializationManager _serializationManager;
|
||||||
|
|
||||||
_i3.Future<_i4.Quote> createQuote(
|
|
||||||
_i1.TestSessionBuilder sessionBuilder,
|
|
||||||
_i5.CreateQuoteRequest req,
|
|
||||||
) async {
|
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
|
||||||
var _localUniqueSession =
|
|
||||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
|
||||||
endpoint: 'quote',
|
|
||||||
method: 'createQuote',
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
|
||||||
createSessionCallback: (_) => _localUniqueSession,
|
|
||||||
endpointPath: 'quote',
|
|
||||||
methodName: 'createQuote',
|
|
||||||
parameters: _i1.testObjectToJson({'req': req}),
|
|
||||||
serializationManager: _serializationManager,
|
|
||||||
);
|
|
||||||
var _localReturnValue = await (_localCallContext.method.call(
|
|
||||||
_localUniqueSession,
|
|
||||||
_localCallContext.arguments,
|
|
||||||
) as _i3.Future<_i4.Quote>);
|
|
||||||
return _localReturnValue;
|
|
||||||
} finally {
|
|
||||||
await _localUniqueSession.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_i3.Future<void> updateQuote(
|
_i3.Future<void> updateQuote(
|
||||||
_i1.TestSessionBuilder sessionBuilder,
|
_i1.TestSessionBuilder sessionBuilder,
|
||||||
_i4.Quote quote,
|
_i4.Quote quote,
|
||||||
|
|
@ -188,10 +159,95 @@ class _QuoteEndpoint {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_i3.Stream<_i4.Quote> quoteUpdates(_i1.TestSessionBuilder sessionBuilder) {
|
||||||
|
var _localTestStreamManager = _i1.TestStreamManager<_i4.Quote>();
|
||||||
|
_i1.callStreamFunctionAndHandleExceptions(
|
||||||
|
() async {
|
||||||
|
var _localUniqueSession =
|
||||||
|
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||||
|
endpoint: 'quote',
|
||||||
|
method: 'quoteUpdates',
|
||||||
|
);
|
||||||
|
var _localCallContext =
|
||||||
|
await _endpointDispatch.getMethodStreamCallContext(
|
||||||
|
createSessionCallback: (_) => _localUniqueSession,
|
||||||
|
endpointPath: 'quote',
|
||||||
|
methodName: 'quoteUpdates',
|
||||||
|
arguments: {},
|
||||||
|
requestedInputStreams: [],
|
||||||
|
serializationManager: _serializationManager,
|
||||||
|
);
|
||||||
|
await _localTestStreamManager.callStreamMethod(
|
||||||
|
_localCallContext,
|
||||||
|
_localUniqueSession,
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
_localTestStreamManager.outputStreamController,
|
||||||
|
);
|
||||||
|
return _localTestStreamManager.outputStreamController.stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
_i3.Future<_i4.Quote> createQuote(
|
||||||
|
_i1.TestSessionBuilder sessionBuilder,
|
||||||
|
_i5.CreateQuoteRequest req,
|
||||||
|
) async {
|
||||||
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
|
var _localUniqueSession =
|
||||||
|
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||||
|
endpoint: 'quote',
|
||||||
|
method: 'createQuote',
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||||
|
createSessionCallback: (_) => _localUniqueSession,
|
||||||
|
endpointPath: 'quote',
|
||||||
|
methodName: 'createQuote',
|
||||||
|
parameters: _i1.testObjectToJson({'req': req}),
|
||||||
|
serializationManager: _serializationManager,
|
||||||
|
);
|
||||||
|
var _localReturnValue = await (_localCallContext.method.call(
|
||||||
|
_localUniqueSession,
|
||||||
|
_localCallContext.arguments,
|
||||||
|
) as _i3.Future<_i4.Quote>);
|
||||||
|
return _localReturnValue;
|
||||||
|
} finally {
|
||||||
|
await _localUniqueSession.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_i3.Future<_i4.Quote> getQuoteById(
|
||||||
|
_i1.TestSessionBuilder sessionBuilder,
|
||||||
|
int id,
|
||||||
|
) async {
|
||||||
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
|
var _localUniqueSession =
|
||||||
|
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||||
|
endpoint: 'quote',
|
||||||
|
method: 'getQuoteById',
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||||
|
createSessionCallback: (_) => _localUniqueSession,
|
||||||
|
endpointPath: 'quote',
|
||||||
|
methodName: 'getQuoteById',
|
||||||
|
parameters: _i1.testObjectToJson({'id': id}),
|
||||||
|
serializationManager: _serializationManager,
|
||||||
|
);
|
||||||
|
var _localReturnValue = await (_localCallContext.method.call(
|
||||||
|
_localUniqueSession,
|
||||||
|
_localCallContext.arguments,
|
||||||
|
) as _i3.Future<_i4.Quote>);
|
||||||
|
return _localReturnValue;
|
||||||
|
} finally {
|
||||||
|
await _localUniqueSession.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_i3.Future<List<_i4.Quote>> getAllQuotes(
|
_i3.Future<List<_i4.Quote>> getAllQuotes(
|
||||||
_i1.TestSessionBuilder sessionBuilder, {
|
_i1.TestSessionBuilder sessionBuilder) async {
|
||||||
required int limit,
|
|
||||||
}) async {
|
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||||
|
|
@ -203,7 +259,7 @@ class _QuoteEndpoint {
|
||||||
createSessionCallback: (_) => _localUniqueSession,
|
createSessionCallback: (_) => _localUniqueSession,
|
||||||
endpointPath: 'quote',
|
endpointPath: 'quote',
|
||||||
methodName: 'getAllQuotes',
|
methodName: 'getAllQuotes',
|
||||||
parameters: _i1.testObjectToJson({'limit': limit}),
|
parameters: _i1.testObjectToJson({}),
|
||||||
serializationManager: _serializationManager,
|
serializationManager: _serializationManager,
|
||||||
);
|
);
|
||||||
var _localReturnValue = await (_localCallContext.method.call(
|
var _localReturnValue = await (_localCallContext.method.call(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue