File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,21 @@ import 'package:json_api/src/document/resource_properties.dart';
2
2
3
3
/// A set of properties for a to-be-created resource which does not have the id yet.
4
4
class NewResource with ResourceProperties {
5
- NewResource (this .type, {this .id});
5
+ NewResource (this .type, {this .id, this .lid });
6
6
7
7
/// Resource type
8
8
final String type;
9
9
10
- /// Nullable. Resource id.
10
+ /// Resource id.
11
11
final String ? id;
12
12
13
+ /// Local resource id.
14
+ final String ? lid;
15
+
13
16
Map <String , Object > toJson () => {
14
17
'type' : type,
15
18
if (id != null ) 'id' : id! ,
19
+ if (lid != null ) 'lid' : lid! ,
16
20
if (attributes.isNotEmpty) 'attributes' : attributes,
17
21
if (relationships.isNotEmpty) 'relationships' : relationships,
18
22
if (meta.isNotEmpty) 'meta' : meta,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ void main() {
10
10
jsonEncode ({'type' : 'test_type' }));
11
11
12
12
expect (
13
- jsonEncode (NewResource ('test_type' )
13
+ jsonEncode (NewResource ('test_type' , id : 'test_id' , lid : 'test_lid' )
14
14
..meta['foo' ] = [42 ]
15
15
..attributes['color' ] = 'green'
16
16
..relationships['one' ] =
@@ -21,6 +21,8 @@ void main() {
21
21
..meta['many' ] = 1 )),
22
22
jsonEncode ({
23
23
'type' : 'test_type' ,
24
+ 'id' : 'test_id' ,
25
+ 'lid' : 'test_lid' ,
24
26
'attributes' : {'color' : 'green' },
25
27
'relationships' : {
26
28
'one' : {
You can’t perform that action at this time.
0 commit comments