Skip to content

Commit

Permalink
Fix http version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Dugene committed Jun 13, 2020
1 parent 8105445 commit 5026b8b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 43 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.0.9

* Fix http dependency again

## 0.0.9

* Fix http dependency

## 0.0.8

* Force 0 on message counter null
Expand Down
29 changes: 9 additions & 20 deletions lib/services/http_service.dart
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
import 'package:http/http.dart';
import 'package:http_logger/http_logger.dart';
import 'package:http_middleware/http_with_middleware.dart';
import 'package:http/http.dart' as http;
import 'package:rocket_chat_connector_flutter/models/authentication.dart';
import 'package:rocket_chat_connector_flutter/models/filters/filter.dart';

class HttpService {
String _apiUrl;
dynamic _httpClient;

static Authentication authentication;

HttpService(String apiUrl) {
_apiUrl = apiUrl;
_httpClient = _getHttpClient();
}

Future<Response> getWithFilter(String uri, Filter filter) async =>
await _httpClient.get(_apiUrl + uri + '?' + _urlEncode(filter.toMap()),
Future<http.Response> getWithFilter(String uri, Filter filter) async =>
await http.get(_apiUrl + uri + '?' + _urlEncode(filter.toMap()),
headers: await _getHeaders());

Future<Response> get(String uri) async =>
await _httpClient.get(_apiUrl + uri, headers: await _getHeaders());
Future<http.Response> get(String uri) async =>
await http.get(_apiUrl + uri, headers: await _getHeaders());

Future<Response> post(String uri, String body) async => await _httpClient
Future<http.Response> post(String uri, String body) async => await http
.post(_apiUrl + uri, headers: await _getHeaders(), body: body);

Future<Response> put(String uri, String body) async => await _httpClient
Future<http.Response> put(String uri, String body) async => await http
.put(_apiUrl + uri, headers: await _getHeaders(), body: body);

Future<Response> delete(String uri) async =>
await _httpClient.delete(_apiUrl + uri, headers: await _getHeaders());
Future<http.Response> delete(String uri) async =>
await http.delete(_apiUrl + uri, headers: await _getHeaders());

Future<Map<String, String>> _getHeaders() async {
Map<String, String> header = {
Expand Down Expand Up @@ -60,10 +56,3 @@ String _urlEncode(Map object) {
}).join();
return url;
}

HttpWithMiddleware _getHttpClient() {
return HttpWithMiddleware.build(
requestTimeout: Duration(minutes: 3),
middlewares: [HttpLogger(logLevel: LogLevel.BODY)],
);
}
19 changes: 2 additions & 17 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,12 @@ packages:
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.3+17"
http_logger:
dependency: "direct main"
description:
name: http_logger
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
http_middleware:
dependency: "direct main"
description:
name: http_middleware
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "0.12.1"
http_parser:
dependency: transitive
description:
Expand Down Expand Up @@ -221,4 +207,3 @@ packages:
version: "3.5.0"
sdks:
dart: ">=2.4.0 <3.0.0"
flutter: ">=0.1.4 <2.0.0"
9 changes: 3 additions & 6 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: rocket_chat_connector_flutter
description: Flutter Rocket.chat connector. This library is developed to allow the use of a Rocket.chat server as a messaging system.
author: Sebastien Dugene <sebastien.dugene@gmail.com>
homepage: https://github.com/sdugene/rocket-chat-connector-flutter
version: 0.0.8
version: 0.0.10

environment:
sdk: ">=2.1.0 <3.0.0"
Expand All @@ -12,10 +11,8 @@ dependencies:
sdk: flutter
#https://pub.dev/packages/collection#-changelog-tab-
collection: ^1.14.11
#https://pub.dev/packages/http_middleware#-changelog-tab-
http_middleware: ^1.0.0
#https://pub.dev/packages/http_logger#-changelog-tab-
http_logger: ^1.0.0
#https://pub.dev/packages/http#-changelog-tab-
http: ^0.12.1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 5026b8b

Please sign in to comment.