Skip to content

Commit b38bba2

Browse files
committed
More documentation
1 parent 28f5845 commit b38bba2

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
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.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ author: "Alexey Karapetov <karapetov@gmail.com>"
22
description: "JSON:API v1.0 (http://jsonapi.org) HTTP Client for Flutter, Server and Browsers"
33
homepage: "https://github.com/f3ath/json-api-dart"
44
name: "json_api"
5-
version: "0.0.1"
5+
version: "0.0.1-dev6"
66
dependencies:
77
http: "^0.12.0"
88
json_api_document: "^0.3.9"

0 commit comments

Comments
 (0)