Skip to content

Commit 281a20c

Browse files
committed
Improved sample code in readme
1 parent 4b112d5 commit 281a20c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ MyClient client = new MyClient(URI.create("http://example.com/"));
99
// GET /contacts
1010
List<Contact> contactList = client.getContacts().readAll();
1111

12-
// POST /contacts
13-
client.getContacts().create(new Contact("smith"));
12+
// POST /contacts -> /contacts/1337
13+
ContactEndpoint smith = client.getContacts().create(new Contact("Smith"));
14+
//ContactEndpoint smith = client.getContacts().get("1337");
1415

15-
// GET /contacts/smith
16-
Contact contact = client.getContacts().get("smith").read();
16+
// GET /contacts/1337
17+
Contact contact = smith.read();
1718

18-
// DELETE /contacts/smith
19-
client.getContacts().get("smith").delete();
19+
// PUT /contacts/1337/note
20+
smith.getNote().set(new Note("some note"));
2021

21-
// PUT /contacts/smith/note
22-
client.getContacts().get("smith").getNote().set(new Note("some note"));
22+
// GET /contacts/1337/note
23+
Note note = smith.getNote().read();
2324

24-
// GET /contacts/smith/note
25-
Note note = client.getContacts().get("smith").getNote().read();
25+
// DELETE /contacts/1337
26+
smith.delete();
2627
```
2728

2829
Read an **[Introduction](https://typedrest.net/introduction/)** to TypedRest or jump right in with the **[Getting started](https://typedrest.net/getting-started/java/)** guide.

0 commit comments

Comments
 (0)