Skip to content

Commit

Permalink
chore: add more example HTTP calls
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed Jun 9, 2024
1 parent 840a0d1 commit 52ca289
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
7 changes: 5 additions & 2 deletions examples/alice_chopper/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ class _MyAppState extends State<MyApp> {
);

postService.getPosts();
postService.getPosts(userId: 2);
postService.createPost(post);
postService.getPost(1);
postService.updatePost(1, post.copyWith(id: 1));
postService.putPost(1, post.copyWith(id: 1));
postService.patchPost(1, post.copyWith(id: 1));
postService.deletePost(1);
postService.updatePost(123456, post.copyWith(id: 123456));
postService.putPost(123456, post.copyWith(id: 123456));
postService.patchPost(123456, post.copyWith(id: 123456));
postService.getPost(123456);
postService.deletePost(123456);
}
Expand Down

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

12 changes: 10 additions & 2 deletions examples/alice_chopper/lib/services/example_posts_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ abstract class ExamplePostsService extends ChopperService {
_$ExamplePostsService(client);

@Get(path: '/', timeout: Duration(seconds: 10))
Future<Response<List<ExamplePost>>> getPosts();
Future<Response<List<ExamplePost>>> getPosts({
@Query() int? userId,
});

@Get(path: '/{id}', timeout: Duration(seconds: 10))
Future<Response<ExamplePost?>> getPost(@Path() int id);
Expand All @@ -20,7 +22,13 @@ abstract class ExamplePostsService extends ChopperService {
Future<Response<ExamplePost?>> createPost(@Body() ExamplePost body);

@Put(path: '/{id}', timeout: Duration(seconds: 10))
Future<Response<ExamplePost?>> updatePost(
Future<Response<ExamplePost?>> putPost(
@Path() int id,
@Body() ExamplePost body,
);

@Patch(path: '/{id}', timeout: Duration(seconds: 10))
Future<Response<ExamplePost?>> patchPost(
@Path() int id,
@Body() ExamplePost body,
);
Expand Down

0 comments on commit 52ca289

Please sign in to comment.