Skip to content

Commit dff491e

Browse files
Kevin JensenKevin Jensen
authored andcommitted
added new HomeUsers api
1 parent 48ade28 commit dff491e

7 files changed

Lines changed: 90 additions & 136 deletions

File tree

Source/Plex.Library/ApiModels/Accounts/PlexAccount.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ public async Task<ResourceContainer> Resources() =>
198198
public async Task<List<Friend>> Friends() =>
199199
await this.plexAccountClient.GetFriendsAsync(this.AuthToken);
200200

201+
// CreateHomeUser()
202+
// CreateExistingUser()
203+
// RemoveFriend()
204+
// RemoveHomeUser()
205+
// UpdateFriend()
206+
// GetUser(string username)
207+
201208
/// <summary>
202209
/// Return list of Movie and Show items in the user's Watchlist.
203210
/// Note: Objects returned are from Plex's online metadata service. You will need to lookup items on the
@@ -219,7 +226,7 @@ public async Task<List<Friend>> Friends() =>
219226
/// <returns>List of Movies or Shows</returns>
220227
public async Task<WatchlistMetadataContainer[]> Watchlist(string filter, string sort, SearchType? libraryType)
221228
{
222-
var watchlist = await this.plexAccountClient.GetWatchList(this.AuthToken, filter, sort, libraryType);
229+
var watchlist = await this.plexAccountClient.GetWatchListAsync(this.AuthToken, filter, sort, libraryType);
223230

224231
if (watchlist.Size > 0 && watchlist.MediaContainers.Any())
225232
{
@@ -239,13 +246,11 @@ public async Task<AnnouncementContainer> Announcements() =>
239246
await this.plexAccountClient.GetPlexAnnouncementsAsync(this.AuthToken);
240247

241248
/// <summary>
242-
/// Returns a list of all User objects connected to your account.
243-
/// This includes both friends and pending invites. You can reference the user.Friend to
244-
/// distinguish between the two.
249+
/// Returns a list of Home Users for Account
245250
/// </summary>
246251
/// <returns>UserContainer Object</returns>
247-
public async Task<UserContainer> Users() =>
248-
await this.plexAccountClient.GetUsers(this.AuthToken);
252+
public async Task<UserContainer> HomeUsers() =>
253+
await this.plexAccountClient.GetHomeUsersAsync(this.AuthToken);
249254

250255

251256

@@ -255,9 +260,9 @@ public async Task<UserContainer> Users() =>
255260
/// distinguish between the two.
256261
/// </summary>
257262
/// <returns>UserContainer Object</returns>
258-
public async Task<PlexAccount> GetPlexHomeAccountAsync(string userUUID)
263+
public async Task<PlexAccount> GetPlexHomeAccountAsync(string userUuid)
259264
{
260-
var account = await this.plexAccountClient.GetPlexHomeAccountAsync(this.AuthToken, userUUID);
265+
var account = await this.plexAccountClient.GetPlexHomeAccountAsync(this.AuthToken, userUuid);
261266
if (account == null)
262267
{
263268
return null;
@@ -275,22 +280,16 @@ public async Task<PlexAccount> GetPlexHomeAccountAsync(string userUUID)
275280
/// <param name="library">Opt out of Library statistics</param>
276281
/// <returns></returns>
277282
public async Task OptOut(bool playback, bool library) =>
278-
await this.plexAccountClient.OptOut(this.AuthToken, playback, library);
283+
await this.plexAccountClient.OptOutAsync(this.AuthToken, playback, library);
279284

280285
/// <summary>
281286
/// Get Account Devices
282287
/// </summary>
283288
/// <returns>List of Device objects</returns>
284289
public async Task<List<Device>> Devices() =>
285-
await this.plexAccountClient.GetDevices(this.AuthToken);
290+
await this.plexAccountClient.GetDevicesAsync(this.AuthToken);
286291

287292

288-
// CreateHomeUser()
289-
// CreateExistingUser()
290-
// RemoveFriend()
291-
// RemoveHomeUser()
292-
// UpdateFriend()
293-
// GetUser(string username)
294293

295294
// AddWebhook(string url);
296295
// DeleteWebhook(string url);

Source/Plex.ServerApi/Clients/Interfaces/IPlexAccountClient.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ public interface IPlexAccountClient
8888
Task<List<Friend>> GetFriendsAsync(string authToken);
8989

9090
/// <summary>
91-
/// Returns a list of all User objects connected to your account.
91+
/// Returns a list of User objects connected to your account.
9292
/// This includes both friends and pending invites. You can reference the User.Friend to
9393
/// distinguish between the two.
9494
/// </summary>
9595
/// <param name="authToken">Authentication Token.</param>
9696
/// <returns>List of Users</returns>
97-
Task<UserContainer> GetUsers(string authToken);
97+
Task<UserContainer> GetHomeUsersAsync(string authToken);
9898

9999
/// <summary>
100100
/// Opt in or out of sharing stuff with plex.
@@ -104,21 +104,21 @@ public interface IPlexAccountClient
104104
/// <param name="playback">Opt out of playback</param>
105105
/// <param name="library">Opt out of Library statistics</param>
106106
/// <returns></returns>
107-
Task OptOut(string authToken, bool playback, bool library);
107+
Task OptOutAsync(string authToken, bool playback, bool library);
108108

109109
/// <summary>
110110
/// Returns a list of all Device objects connected to the account.
111111
/// </summary>
112112
/// <param name="authToken">Authentication Token.</param>
113113
/// <returns></returns>
114-
Task<List<Device>> GetDevices(string authToken);
114+
Task<List<Device>> GetDevicesAsync(string authToken);
115115

116116
/// <summary>
117117
/// Link a device to Plex Account using Pin Auth
118118
/// </summary>
119119
/// <param name="pinCode"></param>
120120
/// <returns></returns>
121-
Task<object> LinkDeviceToAccountByPin(string pinCode);
121+
Task<object> LinkDeviceToAccountByPinAsync(string pinCode);
122122

123123
/// <summary>
124124
/// Switch to the account of another Home User
@@ -148,7 +148,7 @@ public interface IPlexAccountClient
148148
/// </param>
149149
/// <param name="searchType">Library Type (either 'movie' or 'show'). Empty string will return all items.</param>
150150
/// <returns>List of Movies or Shows</returns>
151-
Task<WatchlistContainer> GetWatchList(string authToken, string filter, string sort, SearchType? searchType);
151+
Task<WatchlistContainer> GetWatchListAsync(string authToken, string filter, string sort, SearchType? searchType);
152152

153153
/// <summary>
154154
/// Search for Movies and TV shows in Discover
@@ -157,46 +157,46 @@ public interface IPlexAccountClient
157157
/// <param name="query">Search Query</param>
158158
/// <param name="limit">Limit number of items to return. Default is 30</param>
159159
/// <returns>List of Discover objects</returns>
160-
Task<DiscoverSearchContainer> SearchDiscover(string authToken, string query, int limit = 30);
160+
Task<DiscoverSearchContainer> SearchDiscoverAsync(string authToken, string query, int limit = 30);
161161

162162
/// <summary>
163163
/// Returns True or False depending on if Item is on Watchlist
164164
/// </summary>
165165
/// <param name="authToken">Plex Auth Token</param>
166166
/// <param name="ratingKey">Item Rating Key</param>
167167
/// <returns></returns>
168-
Task<bool> OnWatchlist(string authToken,string ratingKey);
168+
Task<bool> OnWatchlistAsync(string authToken,string ratingKey);
169169

170170
/// <summary>
171171
///
172172
/// </summary>
173173
/// <param name="authToken">Plex Auth Token</param>
174174
/// <param name="ratingKey">Item Rating Key</param>
175175
/// <returns></returns>
176-
Task AddToWatchlist(string authToken, string ratingKey);
176+
Task AddToWatchlistAsync(string authToken, string ratingKey);
177177

178178
/// <summary>
179179
///
180180
/// </summary>
181181
/// <param name="authToken">Plex Auth Token</param>
182182
/// <param name="ratingKey">Item Rating Key</param>
183183
/// <returns></returns>
184-
Task RemoveFromWatchlist(string authToken, string ratingKey);
184+
Task RemoveFromWatchlistAsync(string authToken, string ratingKey);
185185

186186
/// <summary>
187187
/// Get Shared Items for Admin Account
188188
/// </summary>
189189
/// <param name="authToken">Plex Auth Token</param>
190190
/// <returns>List of Shared Items and the Users associated</returns>
191-
Task<List<SharedItemContainer>> GetSharedItems(string authToken);
191+
Task<List<SharedItemContainer>> GetSharedItemsAsync(string authToken);
192192

193193
/// <summary>
194194
/// Remove Shared Item for Admin Account
195195
/// </summary>
196196
/// <param name="authToken">Plex Auth Token</param>
197197
/// <param name="sharedItemId">Shared Item Identifier</param>
198198
/// <returns></returns>
199-
Task RemoveSharedItem(string authToken, int sharedItemId);
199+
Task RemoveSharedItemAsync(string authToken, int sharedItemId);
200200

201201
/// <summary>
202202
/// Add Shared items from Admin Account to another user
@@ -205,6 +205,6 @@ public interface IPlexAccountClient
205205
/// <param name="sharedUserId">User Id to share with</param>
206206
/// <param name="sharedItems">Items to share</param>
207207
/// <returns></returns>
208-
Task AddSharedItems(string authToken, int sharedUserId, List<SharedItemModelRequest> sharedItems);
208+
Task AddSharedItemsAsync(string authToken, int sharedUserId, List<SharedItemModelRequest> sharedItems);
209209
}
210210
}

Source/Plex.ServerApi/Clients/PlexAccountClient.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ public async Task<List<Friend>> GetFriendsAsync(string authToken)
196196
}
197197

198198
/// <inheritdoc/>
199-
public async Task<UserContainer> GetUsers(string authToken)
199+
public async Task<UserContainer> GetHomeUsersAsync(string authToken)
200200
{
201-
var apiRequest = new ApiRequestBuilder("https://plex.tv/api/users", string.Empty, HttpMethod.Get)
201+
var apiRequest = new ApiRequestBuilder("https://plex.tv/home/users", string.Empty, HttpMethod.Get)
202202
.AddPlexToken(authToken)
203203
.AddRequestHeaders(ClientUtilities.GetClientIdentifierHeader(this.clientOptions.ClientId))
204204
.AddRequestHeaders(ClientUtilities.GetClientMetaHeaders(this.clientOptions))
@@ -209,7 +209,7 @@ public async Task<UserContainer> GetUsers(string authToken)
209209
}
210210

211211
/// <inheritdoc/>
212-
public async Task OptOut(string authToken, bool playback, bool library)
212+
public async Task OptOutAsync(string authToken, bool playback, bool library)
213213
{
214214
var queryParams = new Dictionary<string, string>
215215
{
@@ -229,7 +229,7 @@ public async Task OptOut(string authToken, bool playback, bool library)
229229
}
230230

231231
/// <inheritdoc/>
232-
public async Task<List<Device>> GetDevices(string authToken)
232+
public async Task<List<Device>> GetDevicesAsync(string authToken)
233233
{
234234
var apiRequest =
235235
new ApiRequestBuilder("https://plex.tv/devices.json",string.Empty, HttpMethod.Get)
@@ -245,7 +245,7 @@ public async Task<List<Device>> GetDevices(string authToken)
245245
}
246246

247247
/// <inheritdoc/>
248-
public async Task<object> LinkDeviceToAccountByPin(string pinCode)
248+
public async Task<object> LinkDeviceToAccountByPinAsync(string pinCode)
249249
{
250250
var apiRequest =
251251
new ApiRequestBuilder("https://plex.tv/api/v2/pins/link", string.Empty,HttpMethod.Put)
@@ -259,7 +259,7 @@ public async Task<object> LinkDeviceToAccountByPin(string pinCode)
259259
}
260260

261261
/// <inheritdoc/>
262-
public async Task<WatchlistContainer> GetWatchList(string authToken, string filter, string sort, SearchType? searchType)
262+
public async Task<WatchlistContainer> GetWatchListAsync(string authToken, string filter, string sort, SearchType? searchType)
263263
{
264264
var queryParams = new Dictionary<string, string>
265265
{
@@ -295,7 +295,7 @@ public async Task<WatchlistContainer> GetWatchList(string authToken, string filt
295295
}
296296

297297
/// <inheritdoc/>
298-
public async Task<object> GetHistory(string authToken, int maxResults = 999999)
298+
public async Task<object> GetHistoryAsync(string authToken, int maxResults = 999999)
299299
{
300300
var queryParams = new Dictionary<string, string>
301301
{
@@ -317,7 +317,7 @@ public async Task<object> GetHistory(string authToken, int maxResults = 999999)
317317
}
318318

319319
/// <inheritdoc/>
320-
public async Task<DiscoverSearchContainer> SearchDiscover(string authToken, string query, int limit = 30)
320+
public async Task<DiscoverSearchContainer> SearchDiscoverAsync(string authToken, string query, int limit = 30)
321321
{
322322
var queryParams = new Dictionary<string, string>
323323
{
@@ -340,7 +340,7 @@ public async Task<DiscoverSearchContainer> SearchDiscover(string authToken, stri
340340
}
341341

342342
/// <inheritdoc/>
343-
public async Task<bool> OnWatchlist(string authToken, string ratingKey)
343+
public async Task<bool> OnWatchlistAsync(string authToken, string ratingKey)
344344
{
345345
var apiRequest =
346346
new ApiRequestBuilder($"https://metadata.provider.plex.tv/library/metadata/{ratingKey}/userState", string.Empty, HttpMethod.Get)
@@ -355,7 +355,7 @@ public async Task<bool> OnWatchlist(string authToken, string ratingKey)
355355
}
356356

357357
/// <inheritdoc/>
358-
public async Task AddToWatchlist(string authToken, string ratingKey)
358+
public async Task AddToWatchlistAsync(string authToken, string ratingKey)
359359
{
360360
if (string.IsNullOrEmpty(ratingKey))
361361
{
@@ -379,7 +379,7 @@ public async Task AddToWatchlist(string authToken, string ratingKey)
379379
}
380380

381381
/// <inheritdoc/>
382-
public async Task RemoveFromWatchlist(string authToken, string ratingKey)
382+
public async Task RemoveFromWatchlistAsync(string authToken, string ratingKey)
383383
{
384384

385385
if (string.IsNullOrEmpty(ratingKey))
@@ -404,7 +404,7 @@ public async Task RemoveFromWatchlist(string authToken, string ratingKey)
404404
}
405405

406406
/// <inheritdoc/>
407-
public async Task<List<SharedItemContainer>> GetSharedItems(string authToken)
407+
public async Task<List<SharedItemContainer>> GetSharedItemsAsync(string authToken)
408408
{
409409
var queryParams = new Dictionary<string, string>
410410
{
@@ -426,7 +426,7 @@ public async Task<List<SharedItemContainer>> GetSharedItems(string authToken)
426426
}
427427

428428
/// <inheritdoc/>
429-
public async Task RemoveSharedItem(string authToken, int sharedItemId)
429+
public async Task RemoveSharedItemAsync(string authToken, int sharedItemId)
430430
{
431431
var apiRequest =
432432
new ApiRequestBuilder($"https://plex.tv/api/v2/shared_sources/{sharedItemId}", string.Empty,
@@ -441,7 +441,7 @@ public async Task RemoveSharedItem(string authToken, int sharedItemId)
441441
}
442442

443443
/// <inheritdoc/>
444-
public async Task AddSharedItems(string authToken, int sharedUserId, List<SharedItemModelRequest> sharedItems)
444+
public async Task AddSharedItemsAsync(string authToken, int sharedUserId, List<SharedItemModelRequest> sharedItems)
445445
{
446446
var queryParams =
447447
new Dictionary<string, string>

0 commit comments

Comments
 (0)