Skip to content

Commit

Permalink
Merge pull request #2 from tomassasovsky/build/1.0.1+1-beta
Browse files Browse the repository at this point in the history
build: 1.0.1+1-beta
  • Loading branch information
tomassasovsky authored Mar 28, 2023
2 parents 259f2e6 + 7d9b40d commit a8c3f09
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.0.1+1-beta

* Added missing fields in the webhook resource data response
* Bumped `collection` to 1.17.1, `http_interceptor` to 1.0.2, `meta` to 1.9.1, `very_good_analysis` to 4.0.0+1
* Added `http` as a dependency, version 0.13.5

## 1.0.0+2-beta

* Added filter for WebhookResourceDataResponse values

## 1.0.0+1-beta

* Initial release
2 changes: 0 additions & 2 deletions lib/mati_rest_api.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
library mati_rest_api;

export 'src/mati_rest_api.dart';
export 'src/models/models.dart';
33 changes: 15 additions & 18 deletions lib/src/interceptors/token_interceptor.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'dart:convert';

import 'package:http_interceptor/http_interceptor.dart' as http;
import 'package:http/http.dart' as http;
import 'package:http_interceptor/http_interceptor.dart' as http_interceptor;
import 'package:mati_rest_api/mati_rest_api.dart';
import 'package:meta/meta.dart';

/// {@template environment_checker}
/// Checks the environment for this version of the app,
/// and sets the authority accordingly.
/// {@endtemplate}
class TokenInterceptor implements http.InterceptorContract {
class TokenInterceptor implements http_interceptor.InterceptorContract {
/// {@macro environment_checker}
TokenInterceptor({
required this.shouldUpdateToken,
Expand Down Expand Up @@ -38,31 +39,27 @@ class TokenInterceptor implements http.InterceptorContract {
final String clientSecret;

@override
Future<http.BaseRequest> interceptRequest({
required http.BaseRequest request,
Future<http_interceptor.RequestData> interceptRequest({
required http_interceptor.RequestData data,
}) async {
final shouldUpdate = shouldUpdateToken();
if (!shouldUpdate) {
return data;
}

final token = await updateToken();
if (token is MatiAuthenticationResponse) {
request.headers['Authorization'] = 'Bearer ${token.accessToken}';
data.headers['Authorization'] = 'Bearer ${token.accessToken}';
}

return request;
return data;
}

@override
Future<http.BaseResponse> interceptResponse({
required http.BaseResponse response,
Future<http_interceptor.ResponseData> interceptResponse({
required http_interceptor.ResponseData data,
}) async =>
response;

@override
Future<bool> shouldInterceptRequest() async {
final shouldUpdate = shouldUpdateToken();
return shouldUpdate;
}

@override
Future<bool> shouldInterceptResponse() async => false;
data;

/// Use your client_id and client_secret as your username
/// and password to get your access token.
Expand Down
5 changes: 3 additions & 2 deletions lib/src/mati_rest_api.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:http_interceptor/http_interceptor.dart' as http;
import 'package:http/http.dart' as http;
import 'package:http_interceptor/http_interceptor.dart' as http_interceptor;
import 'package:jwt_decoder/jwt_decoder.dart';
import 'package:mati_rest_api/mati_rest_api.dart';
import 'package:mati_rest_api/src/interceptors/token_interceptor.dart';
Expand All @@ -17,7 +18,7 @@ class MatiRestApi implements MatiRestApiBase {
required this.clientSecret,
http.Client? httpClient,
}) {
_httpClient = http.InterceptedClient.build(
_httpClient = http_interceptor.InterceptedClient.build(
interceptors: [
TokenInterceptor(
clientId: clientId,
Expand Down
11 changes: 6 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: mati_rest_api
description: A wrapper for the Metamap REST API.
version: 1.0.0+2-beta
version: 1.0.1+1-beta
homepage: https://github.com/tomassasovsky/mati_rest_api.dart

environment:
sdk: ">=2.17.0 <3.0.0"

dependencies:
collection: ^1.16.0
collection: ^1.17.1
equatable: ^2.0.5
http_interceptor: ^2.0.0-beta.6
http: ^0.13.5
http_interceptor: ^1.0.2
jwt_decoder: ^2.0.1
meta: ^1.8.0
meta: ^1.9.1
recase: ^4.1.0

dev_dependencies:
mocktail: ^0.3.0
test: ^1.21.6
very_good_analysis: ^3.1.0
very_good_analysis: ^4.0.0+1

0 comments on commit a8c3f09

Please sign in to comment.