Ejemplo n.º 1
0
        /// <summary>
        /// Initialize PlexAccount instance.
        /// </summary>
        /// <param name="plexAccountClient">IPlexAccountClient instance.</param>
        /// <param name="plexServerClient">IPlexServerClient instance.</param>
        /// <param name="plexLibraryClient">IPlexLibraryClient instance.</param>
        /// <param name="authToken">Plex Auth Token.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public PlexAccount(IPlexAccountClient plexAccountClient, IPlexServerClient plexServerClient,
                           IPlexLibraryClient plexLibraryClient, string authToken)
        {
            if (string.IsNullOrEmpty(authToken))
            {
                throw new ArgumentNullException(nameof(authToken));
            }

            this.plexAccountClient = plexAccountClient ?? throw new ArgumentNullException(nameof(plexAccountClient));
            this.plexServerClient  = plexServerClient ?? throw new ArgumentNullException(nameof(plexServerClient));
            this.plexLibraryClient = plexLibraryClient ?? throw new ArgumentNullException(nameof(plexLibraryClient));

            var account = plexAccountClient.GetPlexAccountAsync(authToken).Result;

            ObjectMapper.Mapper.Map(account, this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize PlexAccount instance.
        /// </summary>
        /// <param name="plexAccountClient">IPlexAccountClient instance.</param>
        /// <param name="plexServerClient">IPlexServerClient instance.</param>
        /// <param name="plexLibraryClient">IPlexLibraryClient instance.</param>
        /// <param name="username">Plex account username.</param>
        /// <param name="password">Plex account password.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public PlexAccount(IPlexAccountClient plexAccountClient, IPlexServerClient plexServerClient,
                           IPlexLibraryClient plexLibraryClient, string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentNullException(nameof(username));
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException(nameof(password));
            }

            this.plexAccountClient = plexAccountClient ?? throw new ArgumentNullException(nameof(plexAccountClient));
            this.plexServerClient  = plexServerClient ?? throw new ArgumentNullException(nameof(plexServerClient));
            this.plexLibraryClient = plexLibraryClient ?? throw new ArgumentNullException(nameof(plexLibraryClient));

            var account = plexAccountClient.GetPlexAccountAsync(username, password).Result;

            ObjectMapper.Mapper.Map(account, this);
        }