Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gql fetch unban requests (#525)
- Loading branch information
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchUnbanRequests.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
query fetchUnbanRequests($channelLogin: String!, $after: Cursor, $first: Int = 25, $order: UnbanRequestsSortOrder = NEWEST, $status: UnbanRequestStatus = PENDING, $userId: ID) { | ||
channel(name: $channelLogin) { | ||
id | ||
unbanRequests(after: $after, first: $first, options: {order: $order, status: $status, userID: $userId}) { | ||
edges { | ||
cursor | ||
node { | ||
createdAt | ||
id | ||
requester { | ||
id | ||
login | ||
displayName | ||
profileImageURL(width: 50) | ||
} | ||
requesterMessage | ||
resolvedAt | ||
resolvedBy { | ||
id | ||
login | ||
displayName | ||
} | ||
resolverMessage | ||
status | ||
} | ||
} | ||
pageInfo { | ||
hasNextPage | ||
} | ||
totalCount(status: $status) | ||
} | ||
unbanRequestsSettings { | ||
cooldownMinutes | ||
isEnabled | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchUnbanRequests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.github.twitch4j.graphql.command; | ||
|
||
import com.apollographql.apollo.ApolloCall; | ||
import com.apollographql.apollo.ApolloClient; | ||
import com.github.twitch4j.graphql.internal.FetchUnbanRequestsQuery; | ||
import com.github.twitch4j.graphql.internal.type.UnbanRequestStatus; | ||
import com.github.twitch4j.graphql.internal.type.UnbanRequestsSortOrder; | ||
import lombok.NonNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CommandFetchUnbanRequests extends BaseCommand<FetchUnbanRequestsQuery.Data> { | ||
|
||
private final String channelLogin; | ||
private final String cursor; | ||
private final Integer limit; | ||
private final UnbanRequestsSortOrder order; | ||
private final UnbanRequestStatus status; | ||
private final String userId; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param apolloClient Required: Apollo Client | ||
* @param channelLogin Required: The name of the channel where the ban took place | ||
* @param cursor Optional: Cursor for forward pagination | ||
* @param limit Optional: The number of elements to request in a single query (default: 25) | ||
* @param order Optional: Whether unban requests should be returned by most recent or oldest (default: NEWEST) | ||
* @param status Optional: The status of unban requests to query from (default: PENDING) | ||
* @param userId Optional: Whether the unban request of a specific user should be queried | ||
*/ | ||
public CommandFetchUnbanRequests(@NonNull ApolloClient apolloClient, @NonNull String channelLogin, @Nullable String cursor, @Nullable Integer limit, @Nullable UnbanRequestsSortOrder order, @Nullable UnbanRequestStatus status, @Nullable String userId) { | ||
super(apolloClient); | ||
this.channelLogin = channelLogin; | ||
this.cursor = cursor; | ||
this.limit = limit; | ||
this.order = order == null ? UnbanRequestsSortOrder.NEWEST : order; | ||
this.status = status == null ? UnbanRequestStatus.PENDING : status; | ||
this.userId = userId; | ||
} | ||
|
||
@Override | ||
protected ApolloCall<FetchUnbanRequestsQuery.Data> getGraphQLCall() { | ||
return apolloClient.query( | ||
FetchUnbanRequestsQuery.builder() | ||
.channelLogin(channelLogin) | ||
.after(cursor) | ||
.first(limit) | ||
.order(order) | ||
.status(status) | ||
.userId(userId) | ||
.build() | ||
); | ||
} | ||
|
||
} |