IApiClient.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. using MediaBrowser.Model.Configuration;
  2. using MediaBrowser.Model.Dto;
  3. using MediaBrowser.Model.Entities;
  4. using MediaBrowser.Model.Globalization;
  5. using MediaBrowser.Model.Notifications;
  6. using MediaBrowser.Model.Plugins;
  7. using MediaBrowser.Model.Querying;
  8. using MediaBrowser.Model.Search;
  9. using MediaBrowser.Model.Serialization;
  10. using MediaBrowser.Model.Session;
  11. using MediaBrowser.Model.System;
  12. using MediaBrowser.Model.Tasks;
  13. using MediaBrowser.Model.Users;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.IO;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. namespace MediaBrowser.Model.ApiClient
  20. {
  21. /// <summary>
  22. /// Interface IApiClient
  23. /// </summary>
  24. public interface IApiClient : IDisposable
  25. {
  26. /// <summary>
  27. /// Occurs when [server location changed].
  28. /// </summary>
  29. event EventHandler ServerLocationChanged;
  30. /// <summary>
  31. /// Occurs when [HTTP response received].
  32. /// </summary>
  33. event EventHandler<HttpResponseEventArgs> HttpResponseReceived;
  34. string GetApiUrl(string handler);
  35. /// <summary>
  36. /// Gets the async.
  37. /// </summary>
  38. /// <typeparam name="T"></typeparam>
  39. /// <param name="url">The URL.</param>
  40. /// <param name="cancellationToken">The cancellation token.</param>
  41. /// <returns>Task{``0}.</returns>
  42. Task<T> GetAsync<T>(string url, CancellationToken cancellationToken)
  43. where T : class;
  44. /// <summary>
  45. /// Gets the critic reviews.
  46. /// </summary>
  47. /// <param name="itemId">The item id.</param>
  48. /// <param name="cancellationToken">The cancellation token.</param>
  49. /// <param name="startIndex">The start index.</param>
  50. /// <param name="limit">The limit.</param>
  51. /// <returns>Task{ItemReviewsResult}.</returns>
  52. Task<ItemReviewsResult> GetCriticReviews(string itemId, CancellationToken cancellationToken, int? startIndex = null, int? limit = null);
  53. /// <summary>
  54. /// Gets the theme songs async.
  55. /// </summary>
  56. /// <param name="userId">The user id.</param>
  57. /// <param name="itemId">The item id.</param>
  58. /// <param name="inheritFromParents">if set to <c>true</c> [inherit from parents].</param>
  59. /// <param name="cancellationToken">The cancellation token.</param>
  60. /// <returns>Task{ThemeMediaResult}.</returns>
  61. Task<ThemeMediaResult> GetThemeSongsAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken);
  62. /// <summary>
  63. /// Gets the search hints async.
  64. /// </summary>
  65. /// <param name="userId">The user id.</param>
  66. /// <param name="searchTerm">The search term.</param>
  67. /// <param name="startIndex">The start index.</param>
  68. /// <param name="limit">The limit.</param>
  69. /// <returns>Task{SearchHintResult}.</returns>
  70. Task<SearchHintResult> GetSearchHintsAsync(string userId, string searchTerm, int? startIndex = null,
  71. int? limit = null);
  72. /// <summary>
  73. /// Gets the theme videos async.
  74. /// </summary>
  75. /// <param name="userId">The user id.</param>
  76. /// <param name="itemId">The item id.</param>
  77. /// <param name="inheritFromParents">if set to <c>true</c> [inherit from parents].</param>
  78. /// <param name="cancellationToken">The cancellation token.</param>
  79. /// <returns>Task{ThemeMediaResult}.</returns>
  80. Task<ThemeMediaResult> GetThemeVideosAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken);
  81. /// <summary>
  82. /// Gets all theme media async.
  83. /// </summary>
  84. /// <param name="userId">The user id.</param>
  85. /// <param name="itemId">The item id.</param>
  86. /// <param name="inheritFromParents">if set to <c>true</c> [inherit from parents].</param>
  87. /// <param name="cancellationToken">The cancellation token.</param>
  88. /// <returns>Task{AllThemeMediaResult}.</returns>
  89. Task<AllThemeMediaResult> GetAllThemeMediaAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken);
  90. /// <summary>
  91. /// Marks the notifications read.
  92. /// </summary>
  93. /// <param name="userId">The user id.</param>
  94. /// <param name="notificationIdList">The notification id list.</param>
  95. /// <param name="isRead">if set to <c>true</c> [is read].</param>
  96. /// <returns>Task.</returns>
  97. Task MarkNotificationsRead(string userId, IEnumerable<Guid> notificationIdList, bool isRead);
  98. /// <summary>
  99. /// Updates the notification.
  100. /// </summary>
  101. /// <param name="notification">The notification.</param>
  102. /// <returns>Task.</returns>
  103. Task UpdateNotification(Notification notification);
  104. /// <summary>
  105. /// Adds the notification.
  106. /// </summary>
  107. /// <param name="notification">The notification.</param>
  108. /// <returns>Task{Notification}.</returns>
  109. Task<Notification> AddNotification(Notification notification);
  110. /// <summary>
  111. /// Gets the notifications summary.
  112. /// </summary>
  113. /// <param name="userId">The user id.</param>
  114. /// <returns>Task{NotificationsSummary}.</returns>
  115. Task<NotificationsSummary> GetNotificationsSummary(string userId);
  116. /// <summary>
  117. /// Gets the notifications async.
  118. /// </summary>
  119. /// <param name="query">The query.</param>
  120. /// <returns>Task{NotificationResult}.</returns>
  121. Task<NotificationResult> GetNotificationsAsync(NotificationQuery query);
  122. /// <summary>
  123. /// Gets an image stream based on a url
  124. /// </summary>
  125. /// <param name="url">The URL.</param>
  126. /// <param name="cancellationToken">The cancellation token.</param>
  127. /// <returns>Task{Stream}.</returns>
  128. /// <exception cref="ArgumentNullException">url</exception>
  129. Task<Stream> GetImageStreamAsync(string url, CancellationToken cancellationToken);
  130. /// <summary>
  131. /// Gets a BaseItem
  132. /// </summary>
  133. /// <param name="id">The id.</param>
  134. /// <param name="userId">The user id.</param>
  135. /// <returns>Task{BaseItemDto}.</returns>
  136. /// <exception cref="ArgumentNullException">id</exception>
  137. Task<BaseItemDto> GetItemAsync(string id, string userId);
  138. /// <summary>
  139. /// Gets the intros async.
  140. /// </summary>
  141. /// <param name="itemId">The item id.</param>
  142. /// <param name="userId">The user id.</param>
  143. /// <returns>Task{System.String[]}.</returns>
  144. /// <exception cref="ArgumentNullException">id</exception>
  145. Task<string[]> GetIntrosAsync(string itemId, string userId);
  146. /// <summary>
  147. /// Gets a BaseItem
  148. /// </summary>
  149. /// <param name="userId">The user id.</param>
  150. /// <returns>Task{BaseItemDto}.</returns>
  151. /// <exception cref="ArgumentNullException">userId</exception>
  152. Task<BaseItemDto> GetRootFolderAsync(string userId);
  153. /// <summary>
  154. /// Gets the users async.
  155. /// </summary>
  156. /// <param name="query">The query.</param>
  157. /// <returns>Task{UserDto[]}.</returns>
  158. Task<UserDto[]> GetUsersAsync(UserQuery query);
  159. /// <summary>
  160. /// Gets the public users async.
  161. /// </summary>
  162. /// <param name="cancellationToken">The cancellation token.</param>
  163. /// <returns>Task{UserDto[]}.</returns>
  164. Task<UserDto[]> GetPublicUsersAsync(CancellationToken cancellationToken);
  165. /// <summary>
  166. /// Gets active client sessions.
  167. /// </summary>
  168. /// <returns>Task{SessionInfoDto[]}.</returns>
  169. Task<SessionInfoDto[]> GetClientSessionsAsync(SessionQuery query);
  170. /// <summary>
  171. /// Gets the item counts async.
  172. /// </summary>
  173. /// <param name="userId">The user id.</param>
  174. /// <returns>Task{ItemCounts}.</returns>
  175. Task<ItemCounts> GetItemCountsAsync(string userId);
  176. /// <summary>
  177. /// Queries for items
  178. /// </summary>
  179. /// <param name="query">The query.</param>
  180. /// <returns>Task{ItemsResult}.</returns>
  181. /// <exception cref="ArgumentNullException">query</exception>
  182. Task<ItemsResult> GetItemsAsync(ItemQuery query);
  183. /// <summary>
  184. /// Gets the instant mix from song async.
  185. /// </summary>
  186. /// <param name="query">The query.</param>
  187. /// <returns>Task{ItemsResult}.</returns>
  188. Task<ItemsResult> GetInstantMixFromSongAsync(SimilarItemsQuery query);
  189. /// <summary>
  190. /// Gets the instant mix from album async.
  191. /// </summary>
  192. /// <param name="query">The query.</param>
  193. /// <returns>Task{ItemsResult}.</returns>
  194. Task<ItemsResult> GetInstantMixFromAlbumAsync(SimilarItemsQuery query);
  195. /// <summary>
  196. /// Gets the instant mix from artist async.
  197. /// </summary>
  198. /// <param name="query">The query.</param>
  199. /// <returns>Task{ItemsResult}.</returns>
  200. Task<ItemsResult> GetInstantMixFromArtistAsync(SimilarItemsByNameQuery query);
  201. /// <summary>
  202. /// Gets the instant mix from music genre async.
  203. /// </summary>
  204. /// <param name="query">The query.</param>
  205. /// <returns>Task{ItemsResult}.</returns>
  206. Task<ItemsResult> GetInstantMixFromMusicGenreAsync(SimilarItemsByNameQuery query);
  207. /// <summary>
  208. /// Gets the similar movies async.
  209. /// </summary>
  210. /// <param name="query">The query.</param>
  211. /// <returns>Task{ItemsResult}.</returns>
  212. Task<ItemsResult> GetSimilarMoviesAsync(SimilarItemsQuery query);
  213. /// <summary>
  214. /// Gets the similar trailers async.
  215. /// </summary>
  216. /// <param name="query">The query.</param>
  217. /// <returns>Task{ItemsResult}.</returns>
  218. Task<ItemsResult> GetSimilarTrailersAsync(SimilarItemsQuery query);
  219. /// <summary>
  220. /// Gets the similar series async.
  221. /// </summary>
  222. /// <param name="query">The query.</param>
  223. /// <returns>Task{ItemsResult}.</returns>
  224. Task<ItemsResult> GetSimilarSeriesAsync(SimilarItemsQuery query);
  225. /// <summary>
  226. /// Gets the similar albums async.
  227. /// </summary>
  228. /// <param name="query">The query.</param>
  229. /// <returns>Task{ItemsResult}.</returns>
  230. Task<ItemsResult> GetSimilarAlbumsAsync(SimilarItemsQuery query);
  231. /// <summary>
  232. /// Gets the similar games async.
  233. /// </summary>
  234. /// <param name="query">The query.</param>
  235. /// <returns>Task{ItemsResult}.</returns>
  236. Task<ItemsResult> GetSimilarGamesAsync(SimilarItemsQuery query);
  237. /// <summary>
  238. /// Gets the people async.
  239. /// </summary>
  240. /// <param name="query">The query.</param>
  241. /// <returns>Task{ItemsResult}.</returns>
  242. /// <exception cref="ArgumentNullException">userId</exception>
  243. Task<ItemsResult> GetPeopleAsync(PersonsQuery query);
  244. /// <summary>
  245. /// Gets the artists.
  246. /// </summary>
  247. /// <param name="query">The query.</param>
  248. /// <returns>Task{ItemsResult}.</returns>
  249. /// <exception cref="ArgumentNullException">userId</exception>
  250. Task<ItemsResult> GetArtistsAsync(ArtistsQuery query);
  251. /// <summary>
  252. /// Gets a studio
  253. /// </summary>
  254. /// <param name="name">The name.</param>
  255. /// <param name="userId">The user id.</param>
  256. /// <returns>Task{BaseItemDto}.</returns>
  257. /// <exception cref="ArgumentNullException">userId</exception>
  258. Task<BaseItemDto> GetStudioAsync(string name, string userId);
  259. /// <summary>
  260. /// Gets the next up async.
  261. /// </summary>
  262. /// <param name="query">The query.</param>
  263. /// <returns>Task{ItemsResult}.</returns>
  264. Task<ItemsResult> GetNextUpAsync(NextUpQuery query);
  265. /// <summary>
  266. /// Gets a genre
  267. /// </summary>
  268. /// <param name="name">The name.</param>
  269. /// <param name="userId">The user id.</param>
  270. /// <returns>Task{BaseItemDto}.</returns>
  271. /// <exception cref="ArgumentNullException">userId</exception>
  272. Task<BaseItemDto> GetGenreAsync(string name, string userId);
  273. /// <summary>
  274. /// Gets the genres async.
  275. /// </summary>
  276. /// <param name="query">The query.</param>
  277. /// <returns>Task{ItemsResult}.</returns>
  278. Task<ItemsResult> GetGenresAsync(ItemsByNameQuery query);
  279. /// <summary>
  280. /// Gets the music genres async.
  281. /// </summary>
  282. /// <param name="query">The query.</param>
  283. /// <returns>Task{ItemsResult}.</returns>
  284. Task<ItemsResult> GetMusicGenresAsync(ItemsByNameQuery query);
  285. /// <summary>
  286. /// Gets the game genres async.
  287. /// </summary>
  288. /// <param name="query">The query.</param>
  289. /// <returns>Task{ItemsResult}.</returns>
  290. Task<ItemsResult> GetGameGenresAsync(ItemsByNameQuery query);
  291. /// <summary>
  292. /// Gets the studios async.
  293. /// </summary>
  294. /// <param name="query">The query.</param>
  295. /// <returns>Task{ItemsResult}.</returns>
  296. Task<ItemsResult> GetStudiosAsync(ItemsByNameQuery query);
  297. /// <summary>
  298. /// Gets the music genre async.
  299. /// </summary>
  300. /// <param name="name">The name.</param>
  301. /// <param name="userId">The user id.</param>
  302. /// <returns>Task{BaseItemDto}.</returns>
  303. Task<BaseItemDto> GetMusicGenreAsync(string name, string userId);
  304. /// <summary>
  305. /// Gets the game genre async.
  306. /// </summary>
  307. /// <param name="name">The name.</param>
  308. /// <param name="userId">The user id.</param>
  309. /// <returns>Task{BaseItemDto}.</returns>
  310. Task<BaseItemDto> GetGameGenreAsync(string name, string userId);
  311. /// <summary>
  312. /// Gets the artist async.
  313. /// </summary>
  314. /// <param name="name">The name.</param>
  315. /// <param name="userId">The user id.</param>
  316. /// <returns>Task{BaseItemDto}.</returns>
  317. /// <exception cref="ArgumentNullException">name</exception>
  318. Task<BaseItemDto> GetArtistAsync(string name, string userId);
  319. /// <summary>
  320. /// Restarts the server.
  321. /// </summary>
  322. /// <returns>Task.</returns>
  323. Task RestartServerAsync();
  324. /// <summary>
  325. /// Gets the system status async.
  326. /// </summary>
  327. /// <returns>Task{SystemInfo}.</returns>
  328. Task<SystemInfo> GetSystemInfoAsync();
  329. /// <summary>
  330. /// Gets a person
  331. /// </summary>
  332. /// <param name="name">The name.</param>
  333. /// <param name="userId">The user id.</param>
  334. /// <returns>Task{BaseItemDto}.</returns>
  335. /// <exception cref="ArgumentNullException">userId</exception>
  336. Task<BaseItemDto> GetPersonAsync(string name, string userId);
  337. /// <summary>
  338. /// Gets a list of plugins installed on the server
  339. /// </summary>
  340. /// <returns>Task{PluginInfo[]}.</returns>
  341. Task<PluginInfo[]> GetInstalledPluginsAsync();
  342. /// <summary>
  343. /// Gets the current server configuration
  344. /// </summary>
  345. /// <returns>Task{ServerConfiguration}.</returns>
  346. Task<ServerConfiguration> GetServerConfigurationAsync();
  347. /// <summary>
  348. /// Gets the scheduled tasks.
  349. /// </summary>
  350. /// <returns>Task{TaskInfo[]}.</returns>
  351. Task<TaskInfo[]> GetScheduledTasksAsync();
  352. /// <summary>
  353. /// Gets the scheduled task async.
  354. /// </summary>
  355. /// <param name="id">The id.</param>
  356. /// <returns>Task{TaskInfo}.</returns>
  357. /// <exception cref="ArgumentNullException">id</exception>
  358. Task<TaskInfo> GetScheduledTaskAsync(Guid id);
  359. /// <summary>
  360. /// Gets a user by id
  361. /// </summary>
  362. /// <param name="id">The id.</param>
  363. /// <returns>Task{UserDto}.</returns>
  364. /// <exception cref="ArgumentNullException">id</exception>
  365. Task<UserDto> GetUserAsync(string id);
  366. /// <summary>
  367. /// Gets the parental ratings async.
  368. /// </summary>
  369. /// <returns>Task{List{ParentalRating}}.</returns>
  370. Task<List<ParentalRating>> GetParentalRatingsAsync();
  371. /// <summary>
  372. /// Gets local trailers for an item
  373. /// </summary>
  374. /// <param name="userId">The user id.</param>
  375. /// <param name="itemId">The item id.</param>
  376. /// <returns>Task{ItemsResult}.</returns>
  377. /// <exception cref="ArgumentNullException">query</exception>
  378. Task<BaseItemDto[]> GetLocalTrailersAsync(string userId, string itemId);
  379. /// <summary>
  380. /// Gets special features for an item
  381. /// </summary>
  382. /// <param name="userId">The user id.</param>
  383. /// <param name="itemId">The item id.</param>
  384. /// <returns>Task{BaseItemDto[]}.</returns>
  385. /// <exception cref="ArgumentNullException">userId</exception>
  386. Task<BaseItemDto[]> GetSpecialFeaturesAsync(string userId, string itemId);
  387. /// <summary>
  388. /// Gets the cultures async.
  389. /// </summary>
  390. /// <returns>Task{CultureDto[]}.</returns>
  391. Task<CultureDto[]> GetCulturesAsync();
  392. /// <summary>
  393. /// Gets the countries async.
  394. /// </summary>
  395. /// <returns>Task{CountryInfo[]}.</returns>
  396. Task<CountryInfo[]> GetCountriesAsync();
  397. /// <summary>
  398. /// Marks the played async.
  399. /// </summary>
  400. /// <param name="itemId">The item id.</param>
  401. /// <param name="userId">The user id.</param>
  402. /// <param name="datePlayed">The date played.</param>
  403. /// <returns>Task{UserItemDataDto}.</returns>
  404. Task<UserItemDataDto> MarkPlayedAsync(string itemId, string userId, DateTime? datePlayed);
  405. /// <summary>
  406. /// Marks the unplayed async.
  407. /// </summary>
  408. /// <param name="itemId">The item id.</param>
  409. /// <param name="userId">The user id.</param>
  410. /// <returns>Task{UserItemDataDto}.</returns>
  411. Task<UserItemDataDto> MarkUnplayedAsync(string itemId, string userId);
  412. /// <summary>
  413. /// Updates the favorite status async.
  414. /// </summary>
  415. /// <param name="itemId">The item id.</param>
  416. /// <param name="userId">The user id.</param>
  417. /// <param name="isFavorite">if set to <c>true</c> [is favorite].</param>
  418. /// <returns>Task.</returns>
  419. /// <exception cref="ArgumentNullException">itemId</exception>
  420. Task<UserItemDataDto> UpdateFavoriteStatusAsync(string itemId, string userId, bool isFavorite);
  421. /// <summary>
  422. /// Reports to the server that the user has begun playing an item
  423. /// </summary>
  424. /// <param name="itemId">The item id.</param>
  425. /// <param name="userId">The user id.</param>
  426. /// <returns>Task{UserItemDataDto}.</returns>
  427. /// <exception cref="ArgumentNullException">itemId</exception>
  428. Task ReportPlaybackStartAsync(string itemId, string userId);
  429. /// <summary>
  430. /// Reports playback progress to the server
  431. /// </summary>
  432. /// <param name="itemId">The item id.</param>
  433. /// <param name="userId">The user id.</param>
  434. /// <param name="positionTicks">The position ticks.</param>
  435. /// <param name="isPaused">if set to <c>true</c> [is paused].</param>
  436. /// <param name="isMuted">if set to <c>true</c> [is muted].</param>
  437. /// <returns>Task{UserItemDataDto}.</returns>
  438. /// <exception cref="ArgumentNullException">itemId</exception>
  439. Task ReportPlaybackProgressAsync(string itemId, string userId, long? positionTicks, bool isPaused, bool isMuted);
  440. /// <summary>
  441. /// Reports to the server that the user has stopped playing an item
  442. /// </summary>
  443. /// <param name="itemId">The item id.</param>
  444. /// <param name="userId">The user id.</param>
  445. /// <param name="positionTicks">The position ticks.</param>
  446. /// <returns>Task{UserItemDataDto}.</returns>
  447. /// <exception cref="ArgumentNullException">itemId</exception>
  448. Task ReportPlaybackStoppedAsync(string itemId, string userId, long? positionTicks);
  449. /// <summary>
  450. /// Instructs antoher client to browse to a library item.
  451. /// </summary>
  452. /// <param name="sessionId">The session id.</param>
  453. /// <param name="itemId">The id of the item to browse to.</param>
  454. /// <param name="itemName">The name of the item to browse to.</param>
  455. /// <param name="itemType">The type of the item to browse to.</param>
  456. /// <param name="context">Optional ui context (movies, music, tv, games, etc). The client is free to ignore this.</param>
  457. /// <returns>Task.</returns>
  458. Task SendBrowseCommandAsync(string sessionId, string itemId, string itemName, string itemType, string context);
  459. /// <summary>
  460. /// Sends the playstate command async.
  461. /// </summary>
  462. /// <param name="sessionId">The session id.</param>
  463. /// <param name="request">The request.</param>
  464. /// <returns>Task.</returns>
  465. Task SendPlaystateCommandAsync(string sessionId, PlaystateRequest request);
  466. /// <summary>
  467. /// Sends the play command async.
  468. /// </summary>
  469. /// <param name="sessionId">The session id.</param>
  470. /// <param name="request">The request.</param>
  471. /// <returns>Task.</returns>
  472. /// <exception cref="ArgumentNullException">sessionId
  473. /// or
  474. /// request</exception>
  475. Task SendPlayCommandAsync(string sessionId, PlayRequest request);
  476. /// <summary>
  477. /// Sends a system command to the client
  478. /// </summary>
  479. /// <param name="sessionId">The session id.</param>
  480. /// <param name="command">The command.</param>
  481. /// <returns>Task.</returns>
  482. Task SendSystemCommandAsync(string sessionId, SystemCommand command);
  483. /// <summary>
  484. /// Instructs the client to display a message to the user
  485. /// </summary>
  486. /// <param name="sessionId">The session id.</param>
  487. /// <param name="command">The command.</param>
  488. /// <returns>Task.</returns>
  489. Task SendMessageCommandAsync(string sessionId, MessageCommand command);
  490. /// <summary>
  491. /// Clears a user's rating for an item
  492. /// </summary>
  493. /// <param name="itemId">The item id.</param>
  494. /// <param name="userId">The user id.</param>
  495. /// <returns>Task{UserItemDataDto}.</returns>
  496. /// <exception cref="ArgumentNullException">itemId</exception>
  497. Task<UserItemDataDto> ClearUserItemRatingAsync(string itemId, string userId);
  498. /// <summary>
  499. /// Updates a user's rating for an item, based on likes or dislikes
  500. /// </summary>
  501. /// <param name="itemId">The item id.</param>
  502. /// <param name="userId">The user id.</param>
  503. /// <param name="likes">if set to <c>true</c> [likes].</param>
  504. /// <returns>Task.</returns>
  505. /// <exception cref="ArgumentNullException">itemId</exception>
  506. Task<UserItemDataDto> UpdateUserItemRatingAsync(string itemId, string userId, bool likes);
  507. /// <summary>
  508. /// Authenticates a user and returns the result
  509. /// </summary>
  510. /// <param name="username">The username.</param>
  511. /// <param name="sha1Hash">The sha1 hash.</param>
  512. /// <returns>Task.</returns>
  513. /// <exception cref="ArgumentNullException">userId</exception>
  514. Task<AuthenticationResult> AuthenticateUserAsync(string username, byte[] sha1Hash);
  515. /// <summary>
  516. /// Updates the server configuration async.
  517. /// </summary>
  518. /// <param name="configuration">The configuration.</param>
  519. /// <returns>Task.</returns>
  520. /// <exception cref="ArgumentNullException">configuration</exception>
  521. Task UpdateServerConfigurationAsync(ServerConfiguration configuration);
  522. /// <summary>
  523. /// Updates the scheduled task triggers.
  524. /// </summary>
  525. /// <param name="id">The id.</param>
  526. /// <param name="triggers">The triggers.</param>
  527. /// <returns>Task{RequestResult}.</returns>
  528. /// <exception cref="ArgumentNullException">id</exception>
  529. Task UpdateScheduledTaskTriggersAsync(Guid id, TaskTriggerInfo[] triggers);
  530. /// <summary>
  531. /// Gets the display preferences.
  532. /// </summary>
  533. /// <param name="id">The id.</param>
  534. /// <param name="userId">The user id.</param>
  535. /// <param name="client">The client.</param>
  536. /// <param name="cancellationToken">The cancellation token.</param>
  537. /// <returns>Task{BaseItemDto}.</returns>
  538. Task<DisplayPreferences> GetDisplayPreferencesAsync(string id, string userId, string client, CancellationToken cancellationToken);
  539. /// <summary>
  540. /// Updates display preferences for a user
  541. /// </summary>
  542. /// <param name="displayPreferences">The display preferences.</param>
  543. /// <param name="userId">The user id.</param>
  544. /// <param name="client">The client.</param>
  545. /// <param name="cancellationToken">The cancellation token.</param>
  546. /// <returns>Task{DisplayPreferences}.</returns>
  547. /// <exception cref="System.ArgumentNullException">userId</exception>
  548. Task UpdateDisplayPreferencesAsync(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken);
  549. /// <summary>
  550. /// Posts a set of data to a url, and deserializes the return stream into T
  551. /// </summary>
  552. /// <typeparam name="T"></typeparam>
  553. /// <param name="url">The URL.</param>
  554. /// <param name="args">The args.</param>
  555. /// <returns>Task{``0}.</returns>
  556. Task<T> PostAsync<T>(string url, Dictionary<string, string> args)
  557. where T : class;
  558. /// <summary>
  559. /// This is a helper around getting a stream from the server that contains serialized data
  560. /// </summary>
  561. /// <param name="url">The URL.</param>
  562. /// <returns>Task{Stream}.</returns>
  563. Task<Stream> GetSerializedStreamAsync(string url);
  564. /// <summary>
  565. /// Gets the json serializer.
  566. /// </summary>
  567. /// <value>The json serializer.</value>
  568. IJsonSerializer JsonSerializer { get; set; }
  569. /// <summary>
  570. /// Gets or sets the server host name (myserver or 192.168.x.x)
  571. /// </summary>
  572. /// <value>The name of the server host.</value>
  573. string ServerHostName { get; set; }
  574. /// <summary>
  575. /// Gets or sets the port number used by the API
  576. /// </summary>
  577. /// <value>The server API port.</value>
  578. int ServerApiPort { get; set; }
  579. /// <summary>
  580. /// Gets or sets the type of the client.
  581. /// </summary>
  582. /// <value>The type of the client.</value>
  583. string ClientName { get; set; }
  584. /// <summary>
  585. /// Gets or sets the name of the device.
  586. /// </summary>
  587. /// <value>The name of the device.</value>
  588. string DeviceName { get; set; }
  589. /// <summary>
  590. /// Gets or sets the device id.
  591. /// </summary>
  592. /// <value>The device id.</value>
  593. string DeviceId { get; set; }
  594. /// <summary>
  595. /// Gets or sets the current user id.
  596. /// </summary>
  597. /// <value>The current user id.</value>
  598. string CurrentUserId { get; set; }
  599. /// <summary>
  600. /// Gets the image URL.
  601. /// </summary>
  602. /// <param name="item">The item.</param>
  603. /// <param name="options">The options.</param>
  604. /// <returns>System.String.</returns>
  605. /// <exception cref="ArgumentNullException">item</exception>
  606. string GetImageUrl(BaseItemDto item, ImageOptions options);
  607. /// <summary>
  608. /// Gets an image url that can be used to download an image from the api
  609. /// </summary>
  610. /// <param name="itemId">The Id of the item</param>
  611. /// <param name="options">The options.</param>
  612. /// <returns>System.String.</returns>
  613. /// <exception cref="ArgumentNullException">itemId</exception>
  614. string GetImageUrl(string itemId, ImageOptions options);
  615. /// <summary>
  616. /// Gets the user image URL.
  617. /// </summary>
  618. /// <param name="user">The user.</param>
  619. /// <param name="options">The options.</param>
  620. /// <returns>System.String.</returns>
  621. /// <exception cref="ArgumentNullException">user</exception>
  622. string GetUserImageUrl(UserDto user, ImageOptions options);
  623. /// <summary>
  624. /// Gets an image url that can be used to download an image from the api
  625. /// </summary>
  626. /// <param name="userId">The Id of the user</param>
  627. /// <param name="options">The options.</param>
  628. /// <returns>System.String.</returns>
  629. /// <exception cref="ArgumentNullException">userId</exception>
  630. string GetUserImageUrl(string userId, ImageOptions options);
  631. /// <summary>
  632. /// Gets the person image URL.
  633. /// </summary>
  634. /// <param name="item">The item.</param>
  635. /// <param name="options">The options.</param>
  636. /// <returns>System.String.</returns>
  637. /// <exception cref="ArgumentNullException">item</exception>
  638. string GetPersonImageUrl(BaseItemPerson item, ImageOptions options);
  639. /// <summary>
  640. /// Gets an image url that can be used to download an image from the api
  641. /// </summary>
  642. /// <param name="name">The name of the person</param>
  643. /// <param name="options">The options.</param>
  644. /// <returns>System.String.</returns>
  645. /// <exception cref="ArgumentNullException">name</exception>
  646. string GetPersonImageUrl(string name, ImageOptions options);
  647. /// <summary>
  648. /// Gets the year image URL.
  649. /// </summary>
  650. /// <param name="item">The item.</param>
  651. /// <param name="options">The options.</param>
  652. /// <returns>System.String.</returns>
  653. /// <exception cref="ArgumentNullException">item</exception>
  654. string GetYearImageUrl(BaseItemDto item, ImageOptions options);
  655. /// <summary>
  656. /// Gets an image url that can be used to download an image from the api
  657. /// </summary>
  658. /// <param name="year">The year.</param>
  659. /// <param name="options">The options.</param>
  660. /// <returns>System.String.</returns>
  661. string GetYearImageUrl(int year, ImageOptions options);
  662. /// <summary>
  663. /// Gets an image url that can be used to download an image from the api
  664. /// </summary>
  665. /// <param name="name">The name.</param>
  666. /// <param name="options">The options.</param>
  667. /// <returns>System.String.</returns>
  668. /// <exception cref="ArgumentNullException">name</exception>
  669. string GetGenreImageUrl(string name, ImageOptions options);
  670. /// <summary>
  671. /// Gets the music genre image URL.
  672. /// </summary>
  673. /// <param name="name">The name.</param>
  674. /// <param name="options">The options.</param>
  675. /// <returns>System.String.</returns>
  676. string GetMusicGenreImageUrl(string name, ImageOptions options);
  677. /// <summary>
  678. /// Gets the game genre image URL.
  679. /// </summary>
  680. /// <param name="name">The name.</param>
  681. /// <param name="options">The options.</param>
  682. /// <returns>System.String.</returns>
  683. string GetGameGenreImageUrl(string name, ImageOptions options);
  684. /// <summary>
  685. /// Gets an image url that can be used to download an image from the api
  686. /// </summary>
  687. /// <param name="name">The name.</param>
  688. /// <param name="options">The options.</param>
  689. /// <returns>System.String.</returns>
  690. /// <exception cref="ArgumentNullException">name</exception>
  691. string GetStudioImageUrl(string name, ImageOptions options);
  692. /// <summary>
  693. /// Gets the artist image URL.
  694. /// </summary>
  695. /// <param name="name">The name.</param>
  696. /// <param name="options">The options.</param>
  697. /// <returns>System.String.</returns>
  698. /// <exception cref="ArgumentNullException">name</exception>
  699. string GetArtistImageUrl(string name, ImageOptions options);
  700. /// <summary>
  701. /// This is a helper to get a list of backdrop url's from a given ApiBaseItemWrapper. If the actual item does not have any backdrops it will return backdrops from the first parent that does.
  702. /// </summary>
  703. /// <param name="item">A given item.</param>
  704. /// <param name="options">The options.</param>
  705. /// <returns>System.String[][].</returns>
  706. /// <exception cref="ArgumentNullException">item</exception>
  707. string[] GetBackdropImageUrls(BaseItemDto item, ImageOptions options);
  708. /// <summary>
  709. /// This is a helper to get the logo image url from a given ApiBaseItemWrapper. If the actual item does not have a logo, it will return the logo from the first parent that does, or null.
  710. /// </summary>
  711. /// <param name="item">A given item.</param>
  712. /// <param name="options">The options.</param>
  713. /// <returns>System.String.</returns>
  714. /// <exception cref="ArgumentNullException">item</exception>
  715. string GetLogoImageUrl(BaseItemDto item, ImageOptions options);
  716. /// <summary>
  717. /// Gets the art image URL.
  718. /// </summary>
  719. /// <param name="item">The item.</param>
  720. /// <param name="options">The options.</param>
  721. /// <returns>System.String.</returns>
  722. string GetArtImageUrl(BaseItemDto item, ImageOptions options);
  723. /// <summary>
  724. /// Gets the url needed to stream an audio file
  725. /// </summary>
  726. /// <param name="options">The options.</param>
  727. /// <returns>System.String.</returns>
  728. /// <exception cref="ArgumentNullException">options</exception>
  729. string GetAudioStreamUrl(StreamOptions options);
  730. /// <summary>
  731. /// Gets the url needed to stream a video file
  732. /// </summary>
  733. /// <param name="options">The options.</param>
  734. /// <returns>System.String.</returns>
  735. /// <exception cref="ArgumentNullException">options</exception>
  736. string GetVideoStreamUrl(VideoStreamOptions options);
  737. /// <summary>
  738. /// Formulates a url for streaming audio using the HLS protocol
  739. /// </summary>
  740. /// <param name="options">The options.</param>
  741. /// <returns>System.String.</returns>
  742. /// <exception cref="ArgumentNullException">options</exception>
  743. string GetHlsAudioStreamUrl(StreamOptions options);
  744. /// <summary>
  745. /// Formulates a url for streaming video using the HLS protocol
  746. /// </summary>
  747. /// <param name="options">The options.</param>
  748. /// <returns>System.String.</returns>
  749. /// <exception cref="ArgumentNullException">options</exception>
  750. string GetHlsVideoStreamUrl(VideoStreamOptions options);
  751. }
  752. }