public static TEntity SetSoundCloudClient <TEntity>(this TEntity entity,
                                                     ISoundCloudClient soundCloudClient)
     where TEntity : Entity
 {
     entity.SoundCloudClient = soundCloudClient;
     return(entity);
 }
Exemple #2
0
        /// <summary>
        /// Initialize SoundCloud API with the provided ClientID.
        /// </summary>
        protected async Task init()
        {
            client = SoundCloudClient.CreateUnauthorized(clientId);
            var entity = await client.Resolve.GetEntityAsync("https://soundcloud.com/" + username);

            user = entity as User;
        }
Exemple #3
0
        public MainWindow(ISoundCloudClient client)
        {
            InitializeComponent();

            _client     = client;
            DataContext = new MainViewModel(_client);
        }
Exemple #4
0
 public MainViewModel(ISoundCloudClient client)
 {
     playList             = new ExtendedPlayList();
     track                = new ExtendedTrack();
     _userPlayListService = new UserPlayListService(client);
     ExtendedTracks       = new ObservableCollection <ExtendedTrack>();
     PlayLists            = new ObservableCollection <ExtendedPlayList>();
 }
Exemple #5
0
        public SoundCloud(string username, string clientid)
        {
            this.username = username;
            client        = SoundCloudClient.CreateUnauthorized(clientid);
            var entity = client.Resolve.GetEntityAsync("https://soundcloud.com/" + username).GetAwaiter().GetResult();

            user = entity as User;
        }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="soundCloudClient">A mocked soundcloud client.</param>
        /// <param name="accessToken">The token that can be used to access protected resources.</param>
        internal SoundCloud(ISoundCloudClient soundCloudClient, string accessToken)
        {
            if (soundCloudClient == null) throw new ArgumentNullException("soundCloudClient");

            _soundCloudClient = soundCloudClient;

            if (string.IsNullOrEmpty(accessToken)) return;

            _soundCloudClient.OAuthToken = new OAuth2Token {access_token = accessToken};
        }
        public static IEnumerable <TEntity> SetSoundCloudClient <TEntity>(this IEnumerable <TEntity> entities,
                                                                          ISoundCloudClient soundCloudClient)
            where TEntity : Entity
        {
            entities = entities.ToList();
            foreach (var entity in entities)
            {
                entity.SetSoundCloudClient(soundCloudClient);
            }

            return(entities);
        }
Exemple #8
0
        /// <summary>
        /// Requests a pair of Access and RefreshToken based on the passed AccessToken.
        /// if successfull, initializes an authorized <see cref="SoundCloudClient"/>.
        /// </summary>
        /// <param name="accesstoken"></param>
        /// <returns></returns>
        public Result <SoundCloudAuthenticationStateEnum> Initialize(string accesstoken)
        {
            if (!string.IsNullOrEmpty(accesstoken))
            {
                _client = SoundCloudClient.CreateAuthorized(accesstoken);
                Logger.Info("Authorized client initialized");

                _messenger.Send(new SoundCloudAuthenticationMessage(SoundCloudAuthenticationStateEnum.LoggedInAuthenticated));
                return(new SuccessResult <SoundCloudAuthenticationStateEnum>(SoundCloudAuthenticationStateEnum.LoggedInAuthenticated));
            }

            return(Logout());
        }
 public static IEnumerable <TEntity> SetSoundCloudClient <TEntity>(this Task <IEnumerable <TEntity> > task,
                                                                   ISoundCloudClient soundCloudClient)
     where TEntity : Entity
 {
     try
     {
         return(task.Result.SetSoundCloudClient(soundCloudClient));
     }
     catch (AggregateException ex)
     {
         throw ex.InnerException;
     }
 }
Exemple #10
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            // CTRL FN F5
            // Top 40 playlist: 212109430

            ISoundCloudClient client = SoundCloudClient.CreateUnauthorized(CLIENT_KEY);

            Console.WriteLine("Created API client with ID " + CLIENT_KEY);

            Console.WriteLine("Fetching Top 40...");
            var playlist = await client.Playlists.GetAsync(212109430);

            foreach (var item in playlist.Tracks)
            {
                Console.WriteLine(item.Title);
            }
        }
Exemple #11
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="soundCloudClient">A mocked soundcloud client.</param>
        /// <param name="accessToken">The token that can be used to access protected resources.</param>
        internal SoundCloud(ISoundCloudClient soundCloudClient, string accessToken)
        {
            if (soundCloudClient == null)
            {
                throw new ArgumentNullException("soundCloudClient");
            }

            _soundCloudClient = soundCloudClient;

            if (string.IsNullOrEmpty(accessToken))
            {
                return;
            }

            _soundCloudClient.OAuthToken = new OAuth2Token {
                access_token = accessToken
            };
        }
Exemple #12
0
        public Result <SoundCloudAuthenticationStateEnum> Logout()
        {
            var result = _clientInfoRepository.Get();

            if (!result.IsSuccess)
            {
                _messenger.Send(new SoundCloudAuthenticationMessage(SoundCloudAuthenticationStateEnum.LoggedOut));
                _client = null;

                Logger.Info("SoundCloudClientInfo missing. No Client initialization");

                return(new ErrorResult <SoundCloudAuthenticationStateEnum>(Localization.Messages.CouldNotInitializeSoundCloudClient));
            }

            _client = SoundCloudClient.CreateUnauthorized(result.Data.ClientId);
            Logger.Info("Unauthorized client initialized");

            _messenger.Send(new SoundCloudAuthenticationMessage(SoundCloudAuthenticationStateEnum.LoggedInUnauthenticated));
            return(new SuccessResult <SoundCloudAuthenticationStateEnum>(SoundCloudAuthenticationStateEnum.LoggedInUnauthenticated));
        }
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();

            var settingsJson = File.ReadAllText(Environment.CurrentDirectory + (IsUnix() ? "/" : @"\") + "settings.json", Encoding.UTF8);

            settings = new JsonSerializer().Deserialize <Settings>(settingsJson);

            ISoundCloudConnector soundCloudConnector = new SoundCloudConnector();

            soundCloudClient = soundCloudConnector.DirectConnect(settings.ClientId, settings.ClientSecret, settings.UserName, settings.Password);

            settings.TestUserId  = settings.TestUserId ?? soundCloudClient.Me.GetUser().Id;
            settings.TestTrackId = settings.TestTrackId ?? soundCloudClient.Me.GetTracks()[0].Id;
            if (string.IsNullOrEmpty(settings.TestGroupId))
            {
                var me = soundCloudClient.Me.GetUser();
                settings.TestGroupId = soundCloudClient.Me.GetGroups().First(x => x.Creator.Id == me.Id).Id;
            }
        }
Exemple #14
0
        public async void InitializeUser(string login, string password)
        {
            if (!string.IsNullOrWhiteSpace(login) && !string.IsNullOrWhiteSpace(password))
            {
                try
                {
                    var auth = await SoundCloudOAuth.FromPassword(clientId, clientSecret, login, password);

                    _client    = SoundCloud.Api.SoundCloudClient.CreateAuthorized(auth.AccessToken);
                    mainWindow = new MainWindow(_client);
                    mainWindow.Show();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Invalid credentials: " + e.Message);
                }
            }
            else
            {
                ErrorWindow errorWindow = new ErrorWindow();
                errorWindow.Show();
            }
        }
Exemple #15
0
 protected ResourceBase(ISoundCloudClient soundCloudClient, string relativePath)
 {
     _soundCloudClient = soundCloudClient;
     _relativePath     = relativePath;
 }
Exemple #16
0
 public GroupMembersResource(ISoundCloudClient soundCloudClient, string relativePath)
     : base(soundCloudClient, string.Concat(relativePath, RelativePathFormat))
 {
 }
 public MeConnectionResources(ISoundCloudClient soundCloudClient, string relativePath, string id)
     : base(soundCloudClient, string.Concat(relativePath, "/", id))
 {
 }
 public UserResourcesBase(ISoundCloudClient soundCloudClient, string relativePath)
     : base(soundCloudClient, relativePath)
 {
 }
Exemple #19
0
 public PlaylistResources(ISoundCloudClient soundCloudClient, string relativePath, string id)
     : base(soundCloudClient, string.Concat(relativePath, "/", id))
 {
 }
Exemple #20
0
 public UserService(ISoundCloudClient client)
 {
     _client = client;
 }
 public PlaylistsResource(ISoundCloudClient soundCloudClient, string relativePath)
     : base(soundCloudClient, string.Concat(relativePath, RelativePathFormat))
 {
 }
Exemple #22
0
 public TracksResource(ISoundCloudClient soundCloudClient)
     : base(soundCloudClient, RelativePathFormat)
 {
 }
Exemple #23
0
 public MeConnectionsResource(ISoundCloudClient soundCloudClient, string relativePath)
     : base(soundCloudClient, string.Concat(relativePath, RelativePathFormat))
 {
 }
Exemple #24
0
 public MeResources(ISoundCloudClient soundCloudClient)
     : base(soundCloudClient, RelativePathFormat)
 {
 }
 protected EntityResourceBase(ISoundCloudClient soundCloudClient, string relativePath)
     : base(soundCloudClient, relativePath)
 {
 }
Exemple #26
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="soundCloudClient">A mocked soundcloud client.</param>
 internal SoundCloud(ISoundCloudClient soundCloudClient)
     : this(soundCloudClient, null)
 {
 }
Exemple #27
0
 public SoundCloudService(IConfiguration configuration, ISoundCloudClient client)
 {
     clientId    = configuration["ClientId"];
     this.client = client;
 }
Exemple #28
0
 protected ResourceBase(ISoundCloudClient soundCloudClient, string relativePath)
 {
     _soundCloudClient = soundCloudClient;
     _relativePath = relativePath;
 }
Exemple #29
0
 /// <summary>
 /// Class constructor initializes API connection with our
 /// CLIENT_KEY, and saves that key for the rest of our queries.
 /// </summary>
 public CloudAPI()
 {
     client = SoundCloudClient.CreateUnauthorized(CLIENT_KEY);
     Debug.WriteLine("INF: CloudAPI instantiated.");
 }
Exemple #30
0
 public UserFollowingResources(ISoundCloudClient soundCloudClient, string relativePath, string id)
     : base(soundCloudClient, string.Concat(relativePath, "/", id))
 {
 }
Exemple #31
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="soundCloudClient">A mocked soundcloud client.</param>
 internal SoundCloud(ISoundCloudClient soundCloudClient)
     : this(soundCloudClient, null)
 {
 }
Exemple #32
0
 public UserTracksResource(ISoundCloudClient soundCloudClient, string relativePath)
     : base(soundCloudClient, string.Concat(relativePath, RelativePathFormat))
 {
 }
 public PlaylistsResource(ISoundCloudClient soundCloudClient)
     : base(soundCloudClient, RelativePathFormat)
 {
 }