Skip to content

Commit 9b8a46a

Browse files
authored
Release 5.0.3 (#120)
1 parent 50111be commit 9b8a46a

File tree

5 files changed

+57
-23
lines changed

5 files changed

+57
-23
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [5.0.3] - 2021-05-19
8+
### Fixed
9+
- Missing "meta" arguments in RoutingClient
10+
711
## [5.0.2] - 2021-05-12
812
### Fixed
913
- PersistentHandler to implement HttpHandler
@@ -196,6 +200,7 @@ the Document model.
196200
### Added
197201
- Client: fetch resources, collections, related resources and relationships
198202

203+
[5.0.3]: https://github.com/f3ath/json-api-dart/compare/5.0.2...5.0.3
199204
[5.0.2]: https://github.com/f3ath/json-api-dart/compare/5.0.1...5.0.2
200205
[5.0.1]: https://github.com/f3ath/json-api-dart/compare/5.0.0...5.0.1
201206
[5.0.0]: https://github.com/f3ath/json-api-dart/compare/3.2.3...5.0.0

example/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The client and server examples are meant to run together.
2+
3+
- Open a new terminal window and run `dart server.dart`
4+
- While the server is running, open another window and run `dart client.dart`

lib/src/client/routing_client.dart

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class RoutingClient {
3030
String id,
3131
String relationship,
3232
List<Identifier> identifiers, {
33+
Map<String, Object?> meta = const {},
3334
Map<String, String> headers = const {},
3435
}) async {
3536
final response = await send(
3637
baseUri.relationship(type, id, relationship),
37-
Request.post(OutboundDataDocument.many(ToMany(identifiers)))
38+
Request.post(
39+
OutboundDataDocument.many(ToMany(identifiers)..meta.addAll(meta)))
3840
..headers.addAll(headers));
3941
return RelationshipUpdated.many(response.http, response.document);
4042
}
@@ -84,11 +86,13 @@ class RoutingClient {
8486
String id,
8587
String relationship,
8688
List<Identifier> identifiers, {
89+
Map<String, Object?> meta = const {},
8790
Map<String, String> headers = const {},
8891
}) async {
8992
final response = await send(
9093
baseUri.relationship(type, id, relationship),
91-
Request.delete(OutboundDataDocument.many(ToMany(identifiers)))
94+
Request.delete(
95+
OutboundDataDocument.many(ToMany(identifiers)..meta.addAll(meta)))
9296
..headers.addAll(headers));
9397

9498
return RelationshipUpdated.many(response.http, response.document);
@@ -235,12 +239,16 @@ class RoutingClient {
235239
response.http, response.document ?? (throw FormatException()));
236240
}
237241

238-
Future<ResourceUpdated> updateResource(String type, String id,
239-
{Map<String, Object?> attributes = const {},
240-
Map<String, Identifier> one = const {},
241-
Map<String, Iterable<Identifier>> many = const {},
242-
Map<String, Object?> meta = const {},
243-
Map<String, String> headers = const {}}) async {
242+
Future<ResourceUpdated> updateResource(
243+
String type,
244+
String id, {
245+
Map<String, Object?> attributes = const {},
246+
Map<String, Identifier> one = const {},
247+
Map<String, Iterable<Identifier>> many = const {},
248+
Map<String, Object?> meta = const {},
249+
Map<String, Object?> documentMeta = const {},
250+
Map<String, String> headers = const {},
251+
}) async {
244252
final response = await send(
245253
baseUri.resource(type, id),
246254
Request.patch(OutboundDataDocument.resource(Resource(type, id)
@@ -249,7 +257,8 @@ class RoutingClient {
249257
...one.map((key, value) => MapEntry(key, ToOne(value))),
250258
...many.map((key, value) => MapEntry(key, ToMany(value))),
251259
})
252-
..meta.addAll(meta)))
260+
..meta.addAll(meta))
261+
..meta.addAll(documentMeta))
253262
..headers.addAll(headers));
254263
return ResourceUpdated(response.http, response.document);
255264
}
@@ -262,6 +271,7 @@ class RoutingClient {
262271
Map<String, Identifier> one = const {},
263272
Map<String, Iterable<Identifier>> many = const {},
264273
Map<String, Object?> meta = const {},
274+
Map<String, Object?> documentMeta = const {},
265275
Map<String, String> headers = const {},
266276
}) async {
267277
final response = await send(
@@ -272,7 +282,8 @@ class RoutingClient {
272282
...one.map((key, value) => MapEntry(key, ToOne(value))),
273283
...many.map((key, value) => MapEntry(key, ToMany(value))),
274284
})
275-
..meta.addAll(meta)))
285+
..meta.addAll(meta))
286+
..meta.addAll(documentMeta))
276287
..headers.addAll(headers));
277288
return ResourceUpdated(response.http, response.document);
278289
}
@@ -282,11 +293,13 @@ class RoutingClient {
282293
String id,
283294
String relationship,
284295
Identifier identifier, {
296+
Map<String, Object?> meta = const {},
285297
Map<String, String> headers = const {},
286298
}) async {
287299
final response = await send(
288300
baseUri.relationship(type, id, relationship),
289-
Request.patch(OutboundDataDocument.one(ToOne(identifier)))
301+
Request.patch(
302+
OutboundDataDocument.one(ToOne(identifier)..meta.addAll(meta)))
290303
..headers.addAll(headers));
291304
return RelationshipUpdated.one(response.http, response.document);
292305
}
@@ -296,11 +309,13 @@ class RoutingClient {
296309
String id,
297310
String relationship,
298311
Iterable<Identifier> identifiers, {
312+
Map<String, Object?> meta = const {},
299313
Map<String, String> headers = const {},
300314
}) async {
301315
final response = await send(
302316
baseUri.relationship(type, id, relationship),
303-
Request.patch(OutboundDataDocument.many(ToMany(identifiers)))
317+
Request.patch(
318+
OutboundDataDocument.many(ToMany(identifiers)..meta.addAll(meta)))
304319
..headers.addAll(headers));
305320
return RelationshipUpdated.many(response.http, response.document);
306321
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: json_api
2-
version: 5.0.2
2+
version: 5.0.3
33
homepage: https://github.com/f3ath/json-api-dart
44
description: A framework-agnostic implementations of JSON:API Client and Server. Supports JSON:API v1.0 (https://jsonapi.org)
55
environment:

test/unit/client/client_test.dart

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ void main() {
339339
'tags': [Identifier('tags', '1'), Identifier('tags', '2')]
340340
}, meta: {
341341
'answer': 42
342+
}, documentMeta: {
343+
'hello': 'world'
342344
}, headers: {
343345
'foo': 'bar'
344346
});
@@ -371,7 +373,8 @@ void main() {
371373
}
372374
},
373375
'meta': {'answer': 42}
374-
}
376+
},
377+
'meta': {'hello': 'world'}
375378
});
376379
});
377380
});
@@ -418,6 +421,8 @@ void main() {
418421
'tags': [Identifier('tags', '1'), Identifier('tags', '2')]
419422
}, meta: {
420423
'answer': 42
424+
}, documentMeta: {
425+
'hello': 'world'
421426
}, headers: {
422427
'foo': 'bar'
423428
});
@@ -450,7 +455,8 @@ void main() {
450455
}
451456
},
452457
'meta': {'answer': 42}
453-
}
458+
},
459+
'meta': {'hello': 'world'}
454460
});
455461
});
456462
});
@@ -476,7 +482,7 @@ void main() {
476482
http.response = mock.one;
477483
final response = await client.replaceToOne(
478484
'articles', '1', 'author', Identifier('people', '42'),
479-
headers: {'foo': 'bar'});
485+
meta: {'hello': 'world'}, headers: {'foo': 'bar'});
480486
expect(response.relationship, isA<ToOne>());
481487
expect(http.request.method, 'patch');
482488
expect(http.request.uri.toString(), '/articles/1/relationships/author');
@@ -486,7 +492,8 @@ void main() {
486492
'foo': 'bar'
487493
});
488494
expect(jsonDecode(http.request.body), {
489-
'data': {'type': 'people', 'id': '42'}
495+
'data': {'type': 'people', 'id': '42'},
496+
'meta': {'hello': 'world'}
490497
});
491498
});
492499

@@ -583,7 +590,7 @@ void main() {
583590
http.response = mock.many;
584591
final response = await client.deleteFromMany(
585592
'articles', '1', 'tags', [Identifier('tags', '1')],
586-
headers: {'foo': 'bar'});
593+
meta: {'hello': 'world'}, headers: {'foo': 'bar'});
587594
expect(response.relationship, isA<ToMany>());
588595
expect(http.request.method, 'delete');
589596
expect(http.request.uri.toString(), '/articles/1/relationships/tags');
@@ -595,7 +602,8 @@ void main() {
595602
expect(jsonDecode(http.request.body), {
596603
'data': [
597604
{'type': 'tags', 'id': '1'}
598-
]
605+
],
606+
'meta': {'hello': 'world'}
599607
});
600608
});
601609

@@ -643,7 +651,7 @@ void main() {
643651
http.response = mock.many;
644652
final response = await client.replaceToMany(
645653
'articles', '1', 'tags', [Identifier('tags', '1')],
646-
headers: {'foo': 'bar'});
654+
meta: {'hello': 'world'}, headers: {'foo': 'bar'});
647655
expect(response.relationship, isA<ToMany>());
648656
expect(http.request.method, 'patch');
649657
expect(http.request.uri.toString(), '/articles/1/relationships/tags');
@@ -655,7 +663,8 @@ void main() {
655663
expect(jsonDecode(http.request.body), {
656664
'data': [
657665
{'type': 'tags', 'id': '1'}
658-
]
666+
],
667+
'meta': {'hello': 'world'}
659668
});
660669
});
661670

@@ -703,7 +712,7 @@ void main() {
703712
http.response = mock.many;
704713
final response = await client.addMany(
705714
'articles', '1', 'tags', [Identifier('tags', '1')],
706-
headers: {'foo': 'bar'});
715+
meta: {'hello': 'world'}, headers: {'foo': 'bar'});
707716
expect(response.relationship, isA<ToMany>());
708717
expect(http.request.method, 'post');
709718
expect(http.request.uri.toString(), '/articles/1/relationships/tags');
@@ -715,7 +724,8 @@ void main() {
715724
expect(jsonDecode(http.request.body), {
716725
'data': [
717726
{'type': 'tags', 'id': '1'}
718-
]
727+
],
728+
'meta': {'hello': 'world'}
719729
});
720730
});
721731

0 commit comments

Comments
 (0)