14
14
using TwitchLib . Api . Helix . Models . Moderation . GetModerators ;
15
15
using TwitchLib . Api . Helix . Models . Streams . GetStreams ;
16
16
using TwitchLib . Api . Helix . Models . Users . GetUsers ;
17
+ using TwitchLib . Api . Interfaces ;
17
18
18
19
using Stream = TwitchLib . Api . Helix . Models . Streams . GetStreams . Stream ;
19
20
@@ -73,7 +74,7 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires)
73
74
74
75
/// <inheritdoc />
75
76
public async Task < TwitchAccessToken ? > CreateAccessToken ( string code , CancellationToken token = new ( ) ) {
76
- TwitchAPI api = GetApi ( ) ;
77
+ ITwitchAPI api = GetApi ( ) ;
77
78
AuthCodeResponse ? response = await api . Auth . GetAccessTokenFromCodeAsync ( code , ClientSecret , ClientRedirect ) ;
78
79
if ( null == response ) {
79
80
return null ;
@@ -90,7 +91,7 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires)
90
91
/// <inheritdoc />
91
92
public async Task < TwitchAccessToken ? > RefreshAccessToken ( CancellationToken token = new ( ) ) {
92
93
try {
93
- TwitchAPI api = GetApi ( ) ;
94
+ ITwitchAPI api = GetApi ( ) ;
94
95
RefreshResponse ? response = await api . Auth . RefreshAuthTokenAsync ( OAuth ? . RefreshToken , ClientSecret , ClientId ) ;
95
96
if ( null == response ) {
96
97
return null ;
@@ -116,7 +117,7 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires)
116
117
/// <inheritdoc />
117
118
public async Task < ( string ? id , string ? username ) > GetUser ( CancellationToken token = new ( ) ) {
118
119
return await Retry . Execute ( async ( ) => {
119
- TwitchAPI api = GetApi ( ) ;
120
+ ITwitchAPI api = GetApi ( ) ;
120
121
GetUsersResponse ? response = await api . Helix . Users . GetUsersAsync ( ) ;
121
122
if ( null == response ) {
122
123
return ( null , null ) ;
@@ -130,7 +131,7 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires)
130
131
/// <inheritdoc />
131
132
public async Task < string ? > GetUserEmail ( CancellationToken token = new ( ) ) {
132
133
return await Retry . Execute ( async ( ) => {
133
- TwitchAPI api = GetApi ( ) ;
134
+ ITwitchAPI api = GetApi ( ) ;
134
135
GetUsersResponse ? response = await api . Helix . Users . GetUsersAsync ( ) ;
135
136
if ( null == response ) {
136
137
return null ;
@@ -175,7 +176,7 @@ public async Task<IEnumerable<TwitchModeratedChannel>> GetUserModChannels(string
175
176
public async Task < IEnumerable < BannedUser > > BanChannelUsers ( string channelId , string botId ,
176
177
IEnumerable < ( string Id , string Username ) > users , string reason , CancellationToken token = new ( ) ) {
177
178
return await Retry . Execute ( async ( ) => {
178
- TwitchAPI api = GetApi ( ) ;
179
+ ITwitchAPI api = GetApi ( ) ;
179
180
180
181
var bannedUsers = new List < BannedUser > ( ) ;
181
182
foreach ( ( string Id , string Username ) user in users ) {
@@ -209,7 +210,7 @@ public async Task<IEnumerable<BannedUser>> BanChannelUsers(string channelId, str
209
210
public async Task < IEnumerable < Chatter > > GetChannelUsers ( string channelId , string botId ,
210
211
CancellationToken token = new ( ) ) {
211
212
return await Retry . Execute ( async ( ) => {
212
- TwitchAPI api = GetApi ( ) ;
213
+ ITwitchAPI api = GetApi ( ) ;
213
214
var chatters = new List < Chatter > ( ) ;
214
215
string ? cursor = null ;
215
216
int total = 0 ;
@@ -231,7 +232,7 @@ public async Task<IEnumerable<Chatter>> GetChannelUsers(string channelId, string
231
232
232
233
/// <inheritdoc />
233
234
public async Task < IEnumerable < string > > GetChannelsLive ( IEnumerable < string > userIds ) {
234
- TwitchAPI api = GetApi ( ) ;
235
+ ITwitchAPI api = GetApi ( ) ;
235
236
236
237
// We can only query 100 at a time, so throttle the search.
237
238
var liveUsers = new List < Stream > ( ) ;
@@ -256,7 +257,7 @@ public async Task<IEnumerable<string>> GetChannelsLive(IEnumerable<string> userI
256
257
/// <inheritdoc />
257
258
public async Task < IEnumerable < Moderator > > GetChannelMods ( string channelId , CancellationToken token = new ( ) ) {
258
259
return await Retry . Execute ( async ( ) => {
259
- TwitchAPI api = GetApi ( ) ;
260
+ ITwitchAPI api = GetApi ( ) ;
260
261
261
262
var results = new List < Moderator > ( ) ;
262
263
GetModeratorsResponse ? response = null ;
@@ -283,7 +284,7 @@ public async Task<IEnumerable<string>> GetChannelsLive(IEnumerable<string> userI
283
284
/// <inheritdoc />
284
285
public async Task < bool > AddChannelMod ( string channelId , string userId , CancellationToken token = new ( ) ) {
285
286
return await Retry . Execute ( async ( ) => {
286
- TwitchAPI api = GetApi ( ) ;
287
+ ITwitchAPI api = GetApi ( ) ;
287
288
await api . Helix . Moderation . AddChannelModeratorAsync ( channelId , userId ) ;
288
289
return true ;
289
290
} , Retries , token ) ;
@@ -293,7 +294,7 @@ public async Task<IEnumerable<string>> GetChannelsLive(IEnumerable<string> userI
293
294
/// Gets a new instance of the <see cref="TwitchAPI" />.
294
295
/// </summary>
295
296
/// <returns>A new instance of the <see cref="TwitchAPI" />.</returns>
296
- private TwitchAPI GetApi ( ) {
297
+ protected ITwitchAPI GetApi ( ) {
297
298
var api = new TwitchAPI {
298
299
Settings = {
299
300
ClientId = ClientId ,
0 commit comments