Skip to content

Commit

Permalink
Merge 0612850 into cb512a7
Browse files Browse the repository at this point in the history
  • Loading branch information
lejard-h committed Mar 25, 2019
2 parents cb512a7 + 0612850 commit 6887922
Show file tree
Hide file tree
Showing 25 changed files with 925 additions and 293 deletions.
15 changes: 15 additions & 0 deletions chopper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 2.3.0

- ***Breaking Change***
`ChopperClient.errorConverter` is now taking an `ErrorConverter` as a parameter
```dart
abstract class ErrorConverter {
FutureOr<Response> convertError<ResultType, ItemType>(Response response);
}
```
- Remove deprecated `Chopper.service<Type>(Type)`
- Add `QueryMap` annotation
- Fix https://github.com/lejard-h/chopper/issues/28
- Fix https://github.com/lejard-h/chopper/issues/21
- Fix https://github.com/lejard-h/chopper/issues/37

## 2.2.0

- Fix converter issue on List
Expand Down
1 change: 1 addition & 0 deletions chopper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ final chopper = new ChopperClient(
## More example

- [Json serializable](https://github.com/lejard-h/chopper/blob/master/example/bin/main_json_serializable.dart)
- [Built Value](https://github.com/lejard-h/chopper/blob/master/example/bin/main_built_value.dart)
- [Jaguar Serializer](https://github.com/lejard-h/chopper/blob/master/example/bin/main_jaguar_serializer.dart)
- [Angular](https://github.com/lejard-h/chopper/blob/master/example/web/main.dart)

Expand Down
26 changes: 13 additions & 13 deletions chopper/example/definition.chopper.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 20 additions & 18 deletions chopper/lib/src/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import 'package:meta/meta.dart';
import 'request.dart';
import 'response.dart';

@immutable

/// Define an APi
/// [baseUrl] determine the prefix of every request in this api
/// [name] generate class name
@immutable
class ChopperApi {
final String baseUrl;

Expand All @@ -15,47 +14,55 @@ class ChopperApi {
});
}

@immutable

/// Define path parameter of an url
///
/// @Get(path: '/{id}')
/// Future<Response> fetch(@Path('id') String resourceId);
@immutable
class Path {
final String name;
const Path([this.name]);
}

@immutable

/// Define query parameters of a request
///
/// @Get(path: '/something')
/// Future<Response> fetch(@Query('id') String resourceId);
///
/// fetch('42');
/// // will request following path: /something?id=42
@immutable
class Query {
final String name;
const Query([this.name]);
}

/// Define query parameters of a request as Map<String, dynamic>
///
/// @Get(path: '/something')
/// Future<Response> fetch(@QueryMap() Map<String, dynamic> query);
///
/// fetch({"foo":"bar","list":[1,2]});
/// // will request following path: /something?foo=bar&list=1&list=2
@immutable
class QueryMap {
const QueryMap();
}

/// Declare Body of [POST], [PUT], [PATCH] request
///
/// @Post()
/// Future<Response> post(@Body() Map<String, dynamic> body);
@immutable
class Body {
const Body();
}

@immutable

/// Override header using method parameter
///
/// @Get()
/// Future<Response> fetch(@Header('foo') String headerFoo);
@immutable
class Header {
final String name;
const Header([this.name]);
Expand All @@ -70,44 +77,39 @@ class Method {
const Method(this.method, {this.path: "/", this.headers: const {}});
}

@immutable

/// Define a method as an Http GET request
@immutable
class Get extends Method {
const Get({String path: "/", Map<String, String> headers: const {}})
: super(HttpMethod.Get, path: path, headers: headers);
}

@immutable

/// Define a method as an Http POST request
/// use [Body] annotation to determine data to send
@immutable
class Post extends Method {
const Post({String path: "/", Map<String, String> headers: const {}})
: super(HttpMethod.Post, path: path, headers: headers);
}

@immutable

/// Define a method as an Http DELETE request
@immutable
class Delete extends Method {
const Delete({String path: "/", Map<String, String> headers: const {}})
: super(HttpMethod.Delete, path: path, headers: headers);
}

@immutable

/// Define a method as an Http PUT request
/// use [Body] annotation to determine data to send
@immutable
class Put extends Method {
const Put({String path: "/", Map<String, String> headers: const {}})
: super(HttpMethod.Put, path: path, headers: headers);
}

@immutable

/// Define a method as an Http PATCH request
/// use [Body] annotation to determine data to send
@immutable
class Patch extends Method {
const Patch({String path: "/", Map<String, String> headers: const {}})
: super(HttpMethod.Patch, path: path, headers: headers);
Expand Down

0 comments on commit 6887922

Please sign in to comment.