Line data Source code
1 : import 'package:stream_feed_dart/src/core/api/files_api.dart'; 2 : import 'package:stream_feed_dart/src/core/api/images_api.dart'; 3 : import 'package:stream_feed_dart/src/core/http/stream_http_client.dart'; 4 : import 'package:stream_feed_dart/src/core/http/token.dart'; 5 : import 'package:stream_feed_dart/src/core/models/open_graph_data.dart'; 6 : import 'package:stream_feed_dart/src/core/util/extension.dart'; 7 : import 'package:stream_feed_dart/src/core/util/routes.dart'; 8 : 9 : import 'package:stream_feed_dart/src/core/api/batch_api.dart'; 10 : import 'package:stream_feed_dart/src/core/api/collections_api.dart'; 11 : import 'package:stream_feed_dart/src/core/api/feed_api.dart'; 12 : import 'package:stream_feed_dart/src/core/api/reactions_api.dart'; 13 : import 'package:stream_feed_dart/src/core/api/stream_api.dart'; 14 : import 'package:stream_feed_dart/src/core/api/users_api.dart'; 15 : 16 : class StreamApiImpl implements StreamApi { 17 2 : StreamApiImpl( 18 : String apiKey, { 19 : StreamHttpClient? client, 20 : StreamHttpClientOptions? options, 21 1 : }) : _client = client ?? StreamHttpClient(apiKey, options: options); 22 : 23 : final StreamHttpClient _client; 24 : 25 2 : @override 26 4 : BatchApi get batch => BatchApi(_client); 27 : 28 2 : @override 29 4 : ReactionsApi get reactions => ReactionsApi(_client); 30 : 31 2 : @override 32 4 : UsersApi get users => UsersApi(_client); 33 : 34 2 : @override 35 4 : CollectionsApi get collections => CollectionsApi(_client); 36 : 37 2 : @override 38 4 : FeedApi get feed => FeedApi(_client); 39 : 40 2 : @override 41 4 : FilesApi get files => FilesApi(_client); 42 : 43 2 : @override 44 4 : ImagesApi get images => ImagesApi(_client); 45 : 46 : @override 47 1 : Future<OpenGraphData> openGraph(Token token, String targetUrl) async { 48 2 : checkArgument(targetUrl.isNotEmpty, "TargetUrl can't be empty"); 49 3 : final result = await _client.get( 50 1 : Routes.openGraphUrl, 51 2 : headers: {'Authorization': '$token'}, 52 1 : queryParameters: {'url': targetUrl}, 53 : ); 54 : //TODO: I have no idea if this works just pleasing null safe warnings 55 2 : return OpenGraphData.fromJson(result.data as Map<String, dynamic>); 56 : } 57 : }