Skip to content

Commit b7bf272

Browse files
committed
Updated the README.md
1 parent b9444b0 commit b7bf272

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,30 @@ final JavaShock shock = new JavaShock("TOKEN-HERE", "https://api.openshock.app")
4747
// If no URL is provided, the default URL is used.
4848
```
4949

50+
After creating the object, just use one of the available methods.
51+
Almost every method, returns a RestAction Object. To execute the request, you need to call the `#execute()` method.
52+
This method is blocking and will return the result.
53+
If you want to execute the request asynchronously, you can use the `#queue()` method.
54+
This method will return `void`, but can take a `Consumer` as a parameter, which will be called when the request is completed.
55+
5056
Everything from here on now is pretty self-explanatory. <br>
57+
58+
To get a Shocker by ID, use
59+
```java
60+
61+
// #getShocker will check if a shocker with this ID is cached,
62+
// if so, it will return the cached object.
63+
// If not, it will fetch the shocker from the API.
64+
65+
final RestAction<Shocker> shocker = shock.getShocker("ID").execute();
66+
// or
67+
shock.getShocker("ID").queue(shocker -> {
68+
// do something with the shocker
69+
});
70+
```
71+
Alternatively, you can use `#retrieveShocker(String)` to fetch a `Shocker` object directly from the api.
72+
Or, use `#getCachedShocker(String)` to get a cached `Shocker` object or null if not cached.
73+
74+
Almost everything is used like that. Shockers and Hubs (old: Devices) are cached upon creating the JavaShock Object.
75+
76+
<b>Note:</b> Not everything is implemented yet. If you are unsure, check the [JavaDocs](https://repo.joshicodes.de/javadoc/releases/de/joshicodes/JavaShock/latest). If not found, it is possible that the method is not implemented yet.

0 commit comments

Comments
 (0)