File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 11# [ JSON: API ] ( http://jsonapi.org ) v1.0 HTTP Client
22
3- This is a super simple implementation of a
3+ This is a super simple implementation of JSON: API Client.
4+
5+ ### Usage example
6+ ``` dart
7+ import 'package:json_api/json_api.dart';
8+ import 'package:json_api_document/json_api_document.dart';
9+
10+ void main() async {
11+ final client = JsonApiClient(baseUrl: 'http://localhost:8888');
12+ final response = await client.fetchResource('/example');
13+ print((response.document as DataDocument).data.resources.first.attributes); // Attributes{message: Hello world!}
14+ }
15+ ```
16+
17+ ### Supported methods
18+
19+ - ` addToMany `
20+ Adds the identifiers to the to-many relationship via POST request to the url.
21+ - ` createResource `
22+ Creates a new resource sending a POST request to the url.
23+ - ` deleteResource `
24+ Deletes the resource sending a DELETE request to the url.
25+ - ` deleteToMany `
26+ Deletes the identifiers from the to-many relationship via DELETE request to the url.
27+ - ` deleteToOne `
28+ Removes a to-one relationship sending PATCH request with "null" data to the url.
29+ - ` fetchRelationship `
30+ Fetches a Document containing identifier(s) from the given url.
31+ - ` fetchResource `
32+ Fetches a Document containing resource(s) from the given url.
33+ - ` setToMany `
34+ Updates (replaces!) a to-many relationship sending the identifiers via PATCH request to the url.
35+ - ` setToOne `
36+ Creates or updates a to-one relationship sending a corresponding identifier via PATCH request to the url.
37+ - ` updateResource `
38+ Updates the resource sending a PATCH request to the url.
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ author: "Alexey Karapetov <karapetov@gmail.com>"
22description : " JSON:API v1.0 (http://jsonapi.org) HTTP Client for Flutter, Server and Browsers"
33homepage : " https://github.com/f3ath/json-api-dart"
44name : " json_api"
5- version : " 0.0.1"
5+ version : " 0.0.1-dev6 "
66dependencies :
77 http : " ^0.12.0"
88 json_api_document : " ^0.3.9"
You can’t perform that action at this time.
0 commit comments