summaryrefslogtreecommitdiff
path: root/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
diff options
context:
space:
mode:
authorMavlushechka <mavlushechka@gmail.com>2022-10-04 00:42:16 +0500
committerMavlushechka <mavlushechka@gmail.com>2022-10-04 00:42:16 +0500
commiteb4815fdfc45e63c767f7bcec712613b8ebbbcd3 (patch)
treed449bf5e34286941a1a73e0706a590f8c429d7a2 /src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
parent840c5a4594c94b6b3e7962c9bea77a5662c39e48 (diff)
Replace spec parameters by ids of objects
Diffstat (limited to 'src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java')
-rw-r--r--src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java b/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
index 2305daf..25b9fe4 100644
--- a/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
+++ b/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
@@ -9,28 +9,32 @@ import java.util.List;
public class JSONPlaceholderAPIManager {
- public static Post getPost(String spec) throws IOException {
- return getObject(spec, Post.class);
+ private final static String postsSpec = "/posts";
+ private final static String usersSpec = "/users";
+
+
+ public static Post getPost(int id) throws IOException {
+ return getObject(postsSpec + "/" + id, Post.class);
}
- public static List<Post> getPosts(String spec) throws IOException {
- return getObjects(spec, Post.class);
+ public static List<Post> getPosts() throws IOException {
+ return getObjects(postsSpec, Post.class);
}
- public static Post postPost(String spec, Post post) throws IOException {
- return postObject(spec, post, Post.class);
+ public static Post postPost(Post post) throws IOException {
+ return postObject(postsSpec, post, Post.class);
}
- public static User getUser(String spec) throws IOException {
- return getObject(spec, User.class);
+ public static User getUser(int id) throws IOException {
+ return getObject(usersSpec + "/" + id, User.class);
}
- public static List<User> getUsers(String spec) throws IOException {
- return getObjects(spec, User.class);
+ public static List<User> getUsers() throws IOException {
+ return getObjects(usersSpec, User.class);
}
- public static User postUser(String spec, User user) throws IOException {
- return postObject(spec, user, User.class);
+ public static User postUser(User user) throws IOException {
+ return postObject(usersSpec, user, User.class);
}
private static <T> T getObject(String spec, Class<T> classOfObject) throws IOException {