public static TEntity SetSoundCloudClient <TEntity>(this TEntity entity, ISoundCloudClient soundCloudClient) where TEntity : Entity { entity.SoundCloudClient = soundCloudClient; return(entity); }
/// <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; }
public MainWindow(ISoundCloudClient client) { InitializeComponent(); _client = client; DataContext = new MainViewModel(_client); }
public MainViewModel(ISoundCloudClient client) { playList = new ExtendedPlayList(); track = new ExtendedTrack(); _userPlayListService = new UserPlayListService(client); ExtendedTracks = new ObservableCollection <ExtendedTrack>(); PlayLists = new ObservableCollection <ExtendedPlayList>(); }
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; }
/// <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); }
/// <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; } }
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); } }
/// <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 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; } }
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(); } }
protected ResourceBase(ISoundCloudClient soundCloudClient, string relativePath) { _soundCloudClient = soundCloudClient; _relativePath = relativePath; }
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) { }
public PlaylistResources(ISoundCloudClient soundCloudClient, string relativePath, string id) : base(soundCloudClient, string.Concat(relativePath, "/", id)) { }
public UserService(ISoundCloudClient client) { _client = client; }
public PlaylistsResource(ISoundCloudClient soundCloudClient, string relativePath) : base(soundCloudClient, string.Concat(relativePath, RelativePathFormat)) { }
public TracksResource(ISoundCloudClient soundCloudClient) : base(soundCloudClient, RelativePathFormat) { }
public MeConnectionsResource(ISoundCloudClient soundCloudClient, string relativePath) : base(soundCloudClient, string.Concat(relativePath, RelativePathFormat)) { }
public MeResources(ISoundCloudClient soundCloudClient) : base(soundCloudClient, RelativePathFormat) { }
protected EntityResourceBase(ISoundCloudClient soundCloudClient, string relativePath) : base(soundCloudClient, relativePath) { }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="soundCloudClient">A mocked soundcloud client.</param> internal SoundCloud(ISoundCloudClient soundCloudClient) : this(soundCloudClient, null) { }
public SoundCloudService(IConfiguration configuration, ISoundCloudClient client) { clientId = configuration["ClientId"]; this.client = client; }
protected ResourceBase(ISoundCloudClient soundCloudClient, string relativePath) { _soundCloudClient = soundCloudClient; _relativePath = relativePath; }
/// <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."); }
public UserFollowingResources(ISoundCloudClient soundCloudClient, string relativePath, string id) : base(soundCloudClient, string.Concat(relativePath, "/", id)) { }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="soundCloudClient">A mocked soundcloud client.</param> internal SoundCloud(ISoundCloudClient soundCloudClient) : this(soundCloudClient, null) { }
public UserTracksResource(ISoundCloudClient soundCloudClient, string relativePath) : base(soundCloudClient, string.Concat(relativePath, RelativePathFormat)) { }
public PlaylistsResource(ISoundCloudClient soundCloudClient) : base(soundCloudClient, RelativePathFormat) { }