Skip to content

Commit

Permalink
version update
Browse files Browse the repository at this point in the history
  • Loading branch information
redouane59 committed Nov 6, 2021
1 parent 3823e45 commit 4003f42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,5 @@

<url>https://github.com/Redouane59/twittered</url>

<version>2.11-SNAPSHOT</version>
<version>2.11</version>
</project>
15 changes: 9 additions & 6 deletions src/main/java/io/github/redouane59/twitter/TwitterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public class TwitterClient implements ITwitterClientV1, ITwitterClientV2, ITwitt
private static final String BACKFILL_MINUTES = "backfill_minutes";
private static final String DATA = "data";
private static final String DELETED = "deleted";
private static final String IS_MEMBER = "is_member";
private static final String FOLLOWING = "following";
private static final String PINNED = "pinned";
private static final String[] DEFAULT_VALID_CREDENTIALS_FILE_NAMES = {"test-twitter-credentials.json",
"twitter-credentials.json"};
private URLHelper urlHelper = new URLHelper();
Expand Down Expand Up @@ -610,15 +613,15 @@ public boolean addListMember(final String listId, final String userId) {
JsonNode jsonNode =
getRequestHelperV1().postRequestWithBodyJson(url, null, TwitterClient.OBJECT_MAPPER.writeValueAsString(body), JsonNode.class)
.orElseThrow(NoSuchElementException::new);
return jsonNode.get(DATA).get("is_member").asBoolean();
return jsonNode.get(DATA).get(IS_MEMBER).asBoolean();
}

@Override
public boolean removeListMember(final String listId, final String userId) {
String url = getUrlHelper().getRemoveListMemberUrl(listId, userId);
JsonNode jsonNode = getRequestHelperV1().makeRequest(Verb.DELETE, url, new HashMap<>(), null, true, JsonNode.class)
.orElseThrow(NoSuchElementException::new);
return jsonNode.get(DATA).get("is_member").asBoolean();
return jsonNode.get(DATA).get(IS_MEMBER).asBoolean();
}

@SneakyThrows
Expand All @@ -628,15 +631,15 @@ public boolean pinList(final String listId) {
String body = "{\"list_id\": \"" + listId + "\"}";
JsonNode jsonNode = getRequestHelperV1().postRequestWithBodyJson(url, null, body, JsonNode.class)
.orElseThrow(NoSuchElementException::new);
return jsonNode.get(DATA).get("pinned").asBoolean();
return jsonNode.get(DATA).get(PINNED).asBoolean();
}

@Override
public boolean unpinList(final String listId) {
String url = getUrlHelper().getUnpinListUrl(getUserIdFromAccessToken(), listId);
JsonNode jsonNode = getRequestHelperV1().makeRequest(Verb.DELETE, url, new HashMap<>(), null, true, JsonNode.class)
.orElseThrow(NoSuchElementException::new);
return jsonNode.get(DATA).get("pinned").asBoolean();
return jsonNode.get(DATA).get(PINNED).asBoolean();

}

Expand All @@ -657,15 +660,15 @@ public boolean followList(final String listId) {
String body = "{\"list_id\": \"" + listId + "\"}";
JsonNode jsonNode = getRequestHelperV1().postRequestWithBodyJson(url, null, body, JsonNode.class)
.orElseThrow(NoSuchElementException::new);
return jsonNode.get(DATA).get("following").asBoolean();
return jsonNode.get(DATA).get(FOLLOWING).asBoolean();
}

@Override
public boolean unfollowList(final String listId) {
String url = getUrlHelper().getUnfollowListUrl(getUserIdFromAccessToken(), listId);
JsonNode jsonNode = getRequestHelperV1().makeRequest(Verb.DELETE, url, new HashMap<>(), null,
true, JsonNode.class).orElseThrow(NoSuchElementException::new);
return jsonNode.get(DATA).get("following").asBoolean();
return jsonNode.get(DATA).get(FOLLOWING).asBoolean();
}

@Override
Expand Down

0 comments on commit 4003f42

Please sign in to comment.