Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor AliceChopperAdapter #191

Merged
merged 27 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5e52a3d
chore: refactor `AliceChopperAdapter`
techouse Jun 8, 2024
4b69344
fix: use fold instead of map + reduce
techouse Jun 8, 2024
e2b88bb
fix: AliceChopperAdapter
techouse Jun 8, 2024
27a27a5
Merge branch 'jhomlala:master' into chore/remove-deprecated-alice-tok…
techouse Jun 8, 2024
895336a
chore: log Alice error on HTTP errors
techouse Jun 8, 2024
a197e62
chore: update alice_chopper example
techouse Jun 8, 2024
d1a5f99
chore: remove unused import
techouse Jun 8, 2024
442e7a5
chore: add more example calls
techouse Jun 8, 2024
aa7d459
chore: add more error logging
techouse Jun 8, 2024
95e1c43
chore: remove unused import
techouse Jun 8, 2024
b14be7d
chore: update alice_chopper example
techouse Jun 9, 2024
840a0d1
chore: add content-type and accept interceptors to example
techouse Jun 9, 2024
52ca289
chore: add more example HTTP calls
techouse Jun 9, 2024
15c317f
refactor: rename Post to Article to avoid name clash with Chopper's P…
techouse Jun 9, 2024
17a6c07
refactor: add const constructors where possible
techouse Jun 9, 2024
5e3537e
refactor: extract ArticlesService out of the caller method
techouse Jun 9, 2024
111ae08
chore: add more example models
techouse Jun 9, 2024
6564caf
chore: use flutter_lints for linting
techouse Jun 9, 2024
a66be07
chore: add more Chopper services
techouse Jun 9, 2024
2a9c1c2
chore: add more Chopper service routes
techouse Jun 9, 2024
da3afa1
chore: add more test calls
techouse Jun 9, 2024
554b341
chore: better error handling in AliceChopperAdapter
techouse Jun 9, 2024
e50ceea
chore: rename lat / lng to latitude / longitude
techouse Jun 9, 2024
d16e8b2
chore: better error handling
techouse Jun 9, 2024
0dac640
fix: add alice_token back
techouse Jun 9, 2024
fda3903
chore: add broken model examples to trigger error handling
techouse Jun 9, 2024
8732199
chore: use Uuid v4 as the alice_token to make it completely unique
techouse Jun 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions examples/alice_chopper/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
1include: package:very_good_analysis/analysis_options.yaml
analyzer:
exclude:
- "lib/generated_plugin_registrant.dart"
- "**.g.dart"
- "**.chopper.dart"
- "**.mocks.dart"
- "**.gen.dart"

include: package:flutter_lints/flutter.yaml

linter:
rules:
public_member_api_docs: false
flutter_style_todos: false
avoid_final_parameters: false
sort_constructors_first: false
avoid_function_literals_in_foreach_calls: false
avoid_positional_boolean_parameters: false
use_if_null_to_convert_nulls_to_bools: false
use_build_context_synchronously: false
prefer_constructors_over_static_methods: false
use_setters_to_change_properties: false
avoid_print: false
sort_pub_dependencies: false
#library_annotations: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'dart:async' show FutureOr;
import 'dart:io' show ContentType, HttpHeaders;

import 'package:chopper/chopper.dart';

class JsonContentTypeInterceptor implements Interceptor {
@override
FutureOr<Response<BodyType>> intercept<BodyType>(Chain<BodyType> chain) =>
switch (chain.request.method) {
HttpMethod.Post || HttpMethod.Put || HttpMethod.Patch => chain.proceed(
applyHeader(
chain.request,
HttpHeaders.contentTypeHeader,
ContentType.json.mimeType,
),
),
_ => chain.proceed(chain.request),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'dart:async' show FutureOr;
import 'dart:io' show ContentType, HttpHeaders;

import 'package:chopper/chopper.dart';

class JsonHeadersInterceptor implements Interceptor {
@override
FutureOr<Response<BodyType>> intercept<BodyType>(Chain<BodyType> chain) =>
chain.proceed(
applyHeader(
chain.request,
HttpHeaders.acceptHeader,
ContentType.json.mimeType,
),
);
}
Loading
Loading