Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fetch mods and vips over gql #651

Merged
merged 1 commit into from Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,19 @@
query fetchMods($channelLogin: String!, $first: Int = 10, $after: Cursor) {
user(login: $channelLogin) {
id
mods(first: $first, after: $after) {
edges {
cursor
grantedAt
node {
id
displayName
login
}
}
pageInfo {
hasNextPage
}
}
}
}
@@ -0,0 +1,19 @@
query fetchVips($channelLogin: String!, $first: Int = 10, $after: Cursor) {
user(login: $channelLogin) {
id
vips(first: $first, after: $after) {
edges {
cursor
grantedAt
node {
id
displayName
login
}
}
pageInfo {
hasNextPage
}
}
}
}
Expand Up @@ -250,6 +250,10 @@ public CommandFetchModComments fetchModComments(OAuth2Credential auth, String ch
return new CommandFetchModComments(getApolloClient(auth), channelId, targetId, after);
}

public CommandFetchMods fetchMods(OAuth2Credential auth, String channelLogin, String after, Integer limit) {
return new CommandFetchMods(getApolloClient(auth), channelLogin, after, limit);
}

public CommandArchivePoll archivePoll(OAuth2Credential auth, String pollId) {
return new CommandArchivePoll(getApolloClient(auth), pollId);
}
Expand Down Expand Up @@ -339,6 +343,10 @@ public CommandFetchVideoComments fetchVideoComments(OAuth2Credential auth, Strin
return new CommandFetchVideoComments(getApolloClient(auth), channelId, videoId, id, after, before, first, last);
}

public CommandFetchVips fetchVips(OAuth2Credential auth, String channelLogin, String after, Integer limit) {
return new CommandFetchVips(getApolloClient(auth), channelLogin, after, limit);
}

/**
* Follow a user
*
Expand Down
@@ -0,0 +1,49 @@
package com.github.twitch4j.graphql.command;

import com.apollographql.apollo.ApolloCall;
import com.apollographql.apollo.ApolloClient;
import com.github.twitch4j.graphql.internal.FetchModsQuery;

public class CommandFetchMods extends BaseCommand<FetchModsQuery.Data> {

/**
* The login name of the channel whose mod list is being queried
*/
private final String channelLogin;

/**
* Relay cursor for forward pagination (optional)
*/
private final String cursor;

/**
* The maximum number of nodes to return in a single call
*/
private final int limit;

/**
* Constructor
*
* @param apolloClient Apollo Client
* @param channelLogin The login name of the channel whose mod list is being queried
* @param cursor Relay cursor for forward pagination (optional)
* @param limit The maximum number of nodes to return in a single call
*/
public CommandFetchMods(ApolloClient apolloClient, String channelLogin, String cursor, Integer limit) {
super(apolloClient);
this.channelLogin = channelLogin;
this.cursor = cursor;
this.limit = limit != null ? limit : 100;
}

@Override
protected ApolloCall<FetchModsQuery.Data> getGraphQLCall() {
return apolloClient.query(
FetchModsQuery.builder()
.channelLogin(channelLogin)
.after(cursor)
.first(limit)
.build()
);
}
}
@@ -0,0 +1,49 @@
package com.github.twitch4j.graphql.command;

import com.apollographql.apollo.ApolloCall;
import com.apollographql.apollo.ApolloClient;
import com.github.twitch4j.graphql.internal.FetchVipsQuery;

public class CommandFetchVips extends BaseCommand<FetchVipsQuery.Data> {

/**
* The login name of the channel whose vip list is being queried
*/
private final String channelLogin;

/**
* Relay cursor for forward pagination (optional)
*/
private final String cursor;

/**
* The maximum number of nodes to return in a single call
*/
private final int limit;

/**
* Constructor
*
* @param apolloClient Apollo Client
* @param channelLogin The login name of the channel whose vip list is being queried
* @param cursor Relay cursor for forward pagination (optional)
* @param limit The maximum number of nodes to return in a single call
*/
public CommandFetchVips(ApolloClient apolloClient, String channelLogin, String cursor, Integer limit) {
super(apolloClient);
this.channelLogin = channelLogin;
this.cursor = cursor;
this.limit = limit != null ? limit : 100;
}

@Override
protected ApolloCall<FetchVipsQuery.Data> getGraphQLCall() {
return apolloClient.query(
FetchVipsQuery.builder()
.channelLogin(channelLogin)
.after(cursor)
.first(limit)
.build()
);
}
}