├── .gitignore
├── CodingChick.BeatsMusicAPI
├── .nuget
│ ├── NuGet.Config
│ ├── NuGet.exe
│ └── NuGet.targets
├── CodingChick.BeatsMusic.WPFSample
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── BeatsPlayer
│ │ └── BeatsMusicPlayer.html
│ ├── CodingChick.BeatsMusic.WPFSample.csproj
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── SoundManager
│ │ ├── HTMLAudioPlayer.html
│ │ ├── UpgradeBrowserToIE11.reg
│ │ ├── script
│ │ │ ├── soundmanager2-jsmin.js
│ │ │ ├── soundmanager2-nodebug-jsmin.js
│ │ │ ├── soundmanager2-nodebug.js
│ │ │ └── soundmanager2.js
│ │ ├── src
│ │ │ ├── SoundManager2.as
│ │ │ ├── SoundManager2_AS3.as
│ │ │ ├── SoundManager2_SMSound_AS3.as
│ │ │ ├── make-flash8.bat
│ │ │ ├── make-flash8.sh
│ │ │ ├── make-flash9.bat
│ │ │ └── make-flash9.sh
│ │ └── swf
│ │ │ ├── soundmanager2.swf
│ │ │ ├── soundmanager2_debug.swf
│ │ │ ├── soundmanager2_flash9.swf
│ │ │ ├── soundmanager2_flash9_debug.swf
│ │ │ └── soundmanager2_flash_xdomain.zip
│ ├── WindowExtensions.cs
│ └── packages.config
├── CodingChick.BeatsMusicAPI.Core
│ ├── Base
│ │ ├── Authorization.cs
│ │ ├── BeatsHttpData.cs
│ │ ├── BeatsMusicManager.cs
│ │ ├── HttpBeatsMusicEngine.cs
│ │ ├── HttpClientAccessor.cs
│ │ ├── IBeatsHttpData.cs
│ │ ├── IBeatsMusicManager.cs
│ │ ├── IHttpBeatsMusicEngine.cs
│ │ ├── IHttpClientAccessor.cs
│ │ ├── IJsonBeatsMusicEngine.cs
│ │ ├── JsonBeatsMusicEngine.cs
│ │ └── JsonHelpers
│ │ │ ├── BaseDataConverter.cs
│ │ │ ├── JsonCreationConverter.cs
│ │ │ └── UnderscoreResolver.cs
│ ├── BeatsMusicClient.cs
│ ├── CodingChick.BeatsMusicAPI.Core.csproj
│ ├── Data
│ │ ├── Activities
│ │ │ └── ActivityData.cs
│ │ ├── Albums
│ │ │ ├── AlbumData.cs
│ │ │ └── AlbumRefs.cs
│ │ ├── Artists
│ │ │ ├── ArtistData.cs
│ │ │ └── ArtistRefs.cs
│ │ ├── Audio
│ │ │ ├── AudioData.cs
│ │ │ └── AudioRefs.cs
│ │ ├── BaseData.cs
│ │ ├── Content
│ │ │ ├── ContentData.cs
│ │ │ └── ContentRefs.cs
│ │ ├── Genres
│ │ │ └── GenreData.cs
│ │ ├── Info.cs
│ │ ├── Me
│ │ │ └── MeData.cs
│ │ ├── MultipleRootObject.cs
│ │ ├── Player
│ │ │ └── PlayerCode.html
│ │ ├── Playlists
│ │ │ ├── PlaylistData.cs
│ │ │ └── PlaylistsRefs.cs
│ │ ├── Ratings
│ │ │ └── RatingData.cs
│ │ ├── RefTypeInfo.cs
│ │ ├── Reviews
│ │ │ └── ReviewData.cs
│ │ ├── RootObject.cs
│ │ ├── Search
│ │ │ ├── Related.cs
│ │ │ └── SearchData.cs
│ │ ├── SingleRootObject.cs
│ │ ├── Tracks
│ │ │ ├── TrackData.cs
│ │ │ └── TrackRefs.cs
│ │ └── Users
│ │ │ └── UserData.cs
│ ├── Endpoints
│ │ ├── ActivitiesEndpoint.cs
│ │ ├── AlbumsEndpoint.cs
│ │ ├── ArtistsEndpoint.cs
│ │ ├── AudioEndpoint.cs
│ │ ├── BaseEndpoint.cs
│ │ ├── DataFilters
│ │ │ └── StreamabilityFilters.cs
│ │ ├── Enums
│ │ │ ├── AccessPrivilege.cs
│ │ │ ├── AlbumRefType.cs
│ │ │ ├── AlbumsOrderBy.cs
│ │ │ ├── ArtistOrderBy.cs
│ │ │ ├── FollowType.cs
│ │ │ ├── ImageSize.cs
│ │ │ ├── PlaylistRefType.cs
│ │ │ ├── PlaylistsOrderBy.cs
│ │ │ ├── Rating.cs
│ │ │ ├── ResponseType.cs
│ │ │ ├── TracksOrderByData.cs
│ │ │ └── TracksRefType.cs
│ │ ├── FollowEndpoint.cs
│ │ ├── GenreEndpoint.cs
│ │ ├── HighlightsEndpoint.cs
│ │ ├── ImagesEndpoint.cs
│ │ ├── MeEndoint.cs
│ │ ├── PlaylistsEndpoint.cs
│ │ ├── RatingsEndpoint.cs
│ │ ├── SearchEndpoint.cs
│ │ └── TracksEndpoint.cs
│ ├── Helpers
│ │ ├── EnumHelper.cs
│ │ ├── FileHelper.cs
│ │ ├── HttpUtilityHelper.cs
│ │ ├── ParamValueAttribute.cs
│ │ └── ParamValueAttributeHelper.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── app.config
│ └── packages.config
├── CodingChick.BeatsMusicAPI.Tests
│ ├── ArtistsTests.cs
│ ├── AudioTests.cs
│ ├── BaseTest.cs
│ ├── CodingChick.BeatsMusicAPI.Tests.csproj
│ ├── FollowTests.cs
│ ├── GenreTests.cs
│ ├── HightlightsTests.cs
│ ├── ImagesTests.cs
│ ├── PlaylistTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RatingTests.cs
│ ├── SearchTests.cs
│ ├── TracksTest.cs
│ ├── app.config
│ └── packages.config
├── CodingChick.BeatsMusicAPI.sln
└── UpgradeLog.htm
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Rr]elease/
19 | x64/
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | *.meta
24 | *.obj
25 | *.pch
26 | *.pdb
27 | *.pgc
28 | *.pgd
29 | *.rsp
30 | *.sbr
31 | *.tlb
32 | *.tli
33 | *.tlh
34 | *.tmp
35 | *.log
36 | *.vspscc
37 | *.vssscc
38 | .builds
39 |
40 | # Visual C++ cache files
41 | ipch/
42 | *.aps
43 | *.ncb
44 | *.opensdf
45 | *.sdf
46 |
47 | # Visual Studio profiler
48 | *.psess
49 | *.vsp
50 | *.vspx
51 |
52 | # Guidance Automation Toolkit
53 | *.gpState
54 |
55 | # ReSharper is a .NET coding add-in
56 | _ReSharper*
57 |
58 | # NCrunch
59 | *.ncrunch*
60 | .*crunch*.local.xml
61 |
62 | # Installshield output folder
63 | [Ee]xpress
64 |
65 | # DocProject is a documentation generator add-in
66 | DocProject/buildhelp/
67 | DocProject/Help/*.HxT
68 | DocProject/Help/*.HxC
69 | DocProject/Help/*.hhc
70 | DocProject/Help/*.hhk
71 | DocProject/Help/*.hhp
72 | DocProject/Help/Html2
73 | DocProject/Help/html
74 |
75 | # Click-Once directory
76 | publish
77 |
78 | # Publish Web Output
79 | *.Publish.xml
80 |
81 | # NuGet Packages Directory
82 | packages
83 |
84 | # Windows Azure Build Output
85 | csx
86 | *.build.csdef
87 |
88 | # Windows Store app package directory
89 | AppPackages/
90 |
91 | # Others
92 | [Bb]in
93 | [Oo]bj
94 | sql
95 | TestResults
96 | [Tt]est[Rr]esult*
97 | *.Cache
98 | ClientBin
99 | [Ss]tyle[Cc]op.*
100 | ~$*
101 | *.dbmdl
102 | Generated_Code #added for RIA/Silverlight projects
103 |
104 | # Backup & report files from converting an old project file to a newer
105 | # Visual Studio version. Backup files are not needed, because we have git ;-)
106 | _UpgradeReport_Files/
107 | Backup*/
108 | UpgradeLog*.XML
109 | CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Tests/BaseTest.cs
110 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coding-chick/BeatsMusicCSharp/148aff4d992e75f30b4e91b83e394c1bc76b5d4f/CodingChick.BeatsMusicAPI/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 |
41 |
42 |
43 |
44 |
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | packages.config
51 |
52 |
53 |
54 |
55 |
56 |
57 | $(NuGetToolsPath)\NuGet.exe
58 | @(PackageSource)
59 |
60 | "$(NuGetExePath)"
61 | mono --runtime=v4.0.30319 $(NuGetExePath)
62 |
63 | $(TargetDir.Trim('\\'))
64 |
65 | -RequireConsent
66 | -NonInteractive
67 |
68 | "$(SolutionDir) "
69 | "$(SolutionDir)"
70 |
71 |
72 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
73 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
74 |
75 |
76 |
77 | RestorePackages;
78 | $(BuildDependsOn);
79 |
80 |
81 |
82 |
83 | $(BuildDependsOn);
84 | BuildPackage;
85 |
86 |
87 |
88 |
89 |
90 |
91 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
113 |
115 |
116 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace CodingChick.BeatsMusic.WPFSample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/BeatsPlayer/BeatsMusicPlayer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | My Beats Music Player
4 |
5 |
6 |
7 |
48 |
49 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.Specialized;
4 | using System.Diagnostics;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Net;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Web;
11 | using System.Windows;
12 | using System.Windows.Controls;
13 | using System.Windows.Data;
14 | using System.Windows.Documents;
15 | using System.Windows.Input;
16 | using System.Windows.Media;
17 | using System.Windows.Media.Imaging;
18 | using System.Windows.Navigation;
19 | using System.Windows.Shapes;
20 | using CodingChick.BeatsMusicAPI.Core;
21 | using CodingChick.BeatsMusicAPI.Core.Base;
22 | using CodingChick.BeatsMusicAPI.Core.Data;
23 | using CodingChick.BeatsMusicAPI.Core.Data.Audio;
24 | using CodingChick.BeatsMusicAPI.Core.Data.Me;
25 | using CodingChick.BeatsMusicAPI.Core.Data.Playlists;
26 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
27 | using CodingChick.BeatsMusicAPI.Core.Endpoints.DataFilters;
28 | using CodingChick.BeatsMusicAPI.Core.Endpoints.Enums;
29 |
30 | namespace CodingChick.BeatsMusic.WPFSample
31 | {
32 | ///
33 | /// Interaction logic for MainWindow.xaml
34 | ///
35 | public partial class MainWindow : Window
36 | {
37 | private BeatsMusicClient client;
38 |
39 | public MainWindow()
40 | {
41 | InitializeComponent();
42 | this.StretchToMaximum();
43 |
44 | // *** Fill your Beats Music app details here! ***
45 | //this.ClientId = "";
46 | //this.ClientSecret = "";
47 | //this.RedirectUrl = "";
48 |
49 | // Create the beats music API client that will call all services, can be called with ClientSecret for enhanced long term security,
50 | // or without for short term limited security. More infomation on types of security @ https://developer.beatsmusic.com/docs/read/getting_started/Client_Side_Applications
51 | // and https://developer.beatsmusic.com/docs/read/getting_started/Web_Server_Applications
52 | client = new BeatsMusicClient(ClientId, RedirectUrl);
53 |
54 | // Get the address the web browser needs to navigate for OAuth 2.0 protocol authentication.
55 | var addressString = client.UriAddressToNavigateForPermissions();
56 | // Navigate to the BeatsMusic OAuth page.
57 | BeatsMusicWebBrowser.Source = new Uri(addressString);
58 | BeatsMusicWebBrowser.Navigating += BeatsMusicWebBrowser_Navigating;
59 | }
60 |
61 | public string ClientId { get; set; }
62 | public string ClientSecret { get; set; }
63 | public string RedirectUrl { get; set; }
64 |
65 | public async void BeatsMusicWebBrowser_Navigating(object sender, NavigatingCancelEventArgs e)
66 | {
67 | // A check that the OAuth page has redirected to the redirected url provided.
68 | //if (e.Uri != null && e.Uri.AbsoluteUri.Contains("insert part of redirected url here"))
69 | if (e.Uri != null && e.Uri.AbsoluteUri.Contains("codingchick"))
70 | {
71 | NameValueCollection queryStringParams = HttpUtility.ParseQueryString(e.Uri.Query);
72 |
73 | // The first (commented) if statement is the key required for Client Side application (lower security),
74 | // the second (uncommented) if is for Web Server applications (higher security).
75 |
76 | if (queryStringParams.AllKeys.Contains("access_token"))
77 | //if (queryStringParams.AllKeys.Contains("code"))
78 | {
79 | BeatsMusicWebBrowser.NavigateToString(@"");
80 |
81 | // The first (commented) if statement is the key required for Client Side application (lower security),
82 | // the second (uncommented) if is for Web Server applications (higher security).
83 |
84 | client.SetClientAccessTokenFromRedirectUri(queryStringParams.GetValues("access_token").FirstOrDefault(), int.Parse(queryStringParams.GetValues("expires_in").FirstOrDefault()));
85 | //client.ServerCode = queryStringParams.GetValues("code").FirstOrDefault();
86 |
87 | // This is an example of calling the BeatsMusic API, this call will get an information about the user currently logged into this app.
88 | SingleRootObject meResult = await client.Me.GetMeInfo();
89 |
90 | var search = await client.Search.SearchByArtist("Cat Stevens");
91 |
92 | //***************************************************************************************************************
93 | // This is an example of using streaming, this call will get an audio track info required for streaming.
94 | // Calling this method with the aquire set to true just to make sure this works every time.
95 | // more info @https://developer.beatsmusic.com/docs/read/audio/Playback
96 | SingleRootObject trackResult = await client.Audio.GetAudioStreamingInfo("tr61032803", Bitrate.Highest, true);
97 |
98 |
99 | // To demonstrate how the information can be used, I'm using an OS web music player- SoundManager 2 (from @http://www.schillmania.com/projects/soundmanager2/) to play this file.
100 | // The files required and the HTML file are included in this project under the SoundManager directory.
101 | // SoundManager directory is hosted on local iis due to security issues with flash, js and soundmanager when running the local file.
102 | // If SoundManager retunes an exception try refreshing the page and/or update the WebBrowser version to a newer IE version by running the UpgradeBrowserToIE11.reg file included.
103 | //BeatsMusicWebBrowser.Navigate(new Uri(String.Format("http://localhost:8081/soundManager/SoundManager/HTMLAudioPlayer.html?&trackId={0}&trackUrl={1}&serverUrl={2}",
104 | // trackResult.Data.Refs.Track.Id, trackResult.Data.Resource, trackResult.Data.Location)));
105 |
106 | //***************************************************************************************************************
107 | // Alternatly, you can use the BeatsMusic default web player, and play a track with it (@https://developer.beatsmusic.com/docs/read/web_playback_api/Getting_Started)
108 | // you can obtain the base js code from the C# BeatsMusicClient, or get the parameters from the client seperetly and write your own js.
109 | string beatsPlayer = await client.GetBeatsMusicPlayerCode("tr61032803");
110 |
111 | // You can save the string to file, navigate, play etc.
112 | }
113 | }
114 | }
115 |
116 | }
117 |
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("CodingChick.BeatsMusic.WPFSample")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("CodingChick.BeatsMusic.WPFSample")]
15 | [assembly: AssemblyCopyright("Copyright © 2014")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18449
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace CodingChick.BeatsMusic.WPFSample.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CodingChick.BeatsMusic.WPFSample.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18449
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace CodingChick.BeatsMusic.WPFSample.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/HTMLAudioPlayer.html:
--------------------------------------------------------------------------------
1 |
2 |
26 |
27 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/UpgradeBrowserToIE11.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
4 | "CodingChick.BeatsMusic.WPFSample.exe"=dword:2af9
5 |
6 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
7 | "CodingChick.BeatsMusic.WPFSample.exe"=dword:2af9
8 |
9 | [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
10 | "CodingChick.BeatsMusic.WPFSample.vshost.exe"=dword:2af9
11 |
12 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
13 | "CodingChick.BeatsMusic.WPFSample.vshost.exe"=dword:2af9
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/src/make-flash8.bat:
--------------------------------------------------------------------------------
1 | @REM this builds the soundmanager 2 SWF from source
2 |
3 | mtasc -swf ../swf/soundmanager2_debug.swf -main -header 16:16:30 SoundManager2.as -version 8
4 | @pause
5 |
6 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/src/make-flash8.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | /Applications/mtasc/mtasc -swf ../swf/soundmanager2_debug.swf -main -header 16:16:30 SoundManager2.as -version 8
3 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/src/make-flash9.bat:
--------------------------------------------------------------------------------
1 | @REM this builds the soundmanager 2 SWF from source
2 | @REM using mxmlc from the Adobe open-source Flex SDK
3 |
4 | c:\progra~1\flexsdk\bin\mxmlc -debug=true -use-network=false -static-link-runtime-shared-libraries=true -optimize=true -o ../swf/soundmanager2_flash9_debug.swf -file-specs SoundManager2_AS3.as
5 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/src/make-flash9.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | /Applications/flexsdk/bin/mxmlc -debug=true -static-link-runtime-shared-libraries=true -optimize=true -o ../swf/soundmanager2_flash9_debug.swf -file-specs SoundManager2_AS3.as
3 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coding-chick/BeatsMusicCSharp/148aff4d992e75f30b4e91b83e394c1bc76b5d4f/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2.swf
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_debug.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coding-chick/BeatsMusicCSharp/148aff4d992e75f30b4e91b83e394c1bc76b5d4f/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_debug.swf
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_flash9.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coding-chick/BeatsMusicCSharp/148aff4d992e75f30b4e91b83e394c1bc76b5d4f/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_flash9.swf
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_flash9_debug.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coding-chick/BeatsMusicCSharp/148aff4d992e75f30b4e91b83e394c1bc76b5d4f/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_flash9_debug.swf
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_flash_xdomain.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/coding-chick/BeatsMusicCSharp/148aff4d992e75f30b4e91b83e394c1bc76b5d4f/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/SoundManager/swf/soundmanager2_flash_xdomain.zip
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/WindowExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace CodingChick.BeatsMusic.WPFSample
4 | {
5 | public static class WindowExtensions
6 | {
7 | public static void StretchToMaximum(this Window current)
8 | {
9 | current.WindowState = WindowState.Maximized;
10 | current.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
11 | current.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
12 | current.WindowStyle = WindowStyle.None;
13 | current.AllowsTransparency = false;
14 | current.ResizeMode = ResizeMode.CanResize;
15 | }
16 |
17 |
18 | public static void Navigate(this Window current, Window next)
19 | {
20 | Application.Current.MainWindow = next;
21 | next.Show();
22 | current.Close();
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusic.WPFSample/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/Authorization.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net.Http;
4 | using System.Runtime.CompilerServices;
5 | using System.Threading.Tasks;
6 | using CodingChick.BeatsMusicAPI.Core.Endpoints.Enums;
7 | using CodingChick.BeatsMusicAPI.Core.Helpers;
8 | using Newtonsoft.Json;
9 |
10 | namespace CodingChick.BeatsMusicAPI.Core.Base
11 | {
12 | internal class Authorization
13 | {
14 | private readonly ResponseType _responseType;
15 | private readonly string _redirectUri;
16 | private readonly string _clientId;
17 |
18 | public Authorization(string redirectUri, string clientId)
19 | {
20 | _redirectUri = redirectUri;
21 | _clientId = clientId;
22 | }
23 |
24 | public ResponseType ResponseType { get; set; }
25 |
26 | public string ClientId
27 | {
28 | get { return _clientId; }
29 | }
30 |
31 | public string RedirectUri
32 | {
33 | get { return _redirectUri; }
34 | }
35 |
36 | public int ExpiresAt { get; set; }
37 |
38 | public DateTime ExpiresAtWasSet { get; set; }
39 |
40 | public string ClientSecret { get; set; }
41 |
42 | public string AuthorizatioUri { get { return "oauth2/authorize?"; } }
43 |
44 | public string TokenUri { get { return "/oauth2/token"; } }
45 |
46 |
47 | public string ReadOnlyAccessToken { get; set; }
48 |
49 | public string ReadWriteAccessToken { get; set; }
50 |
51 | public string Code { get; set; }
52 |
53 |
54 | public List> CreateAuthorizatioUriParams(ResponseType responseType)
55 | {
56 | var responseTypeString = ParamValueAttributeHelper.GetParamValueOfEnumAttribute(responseType);
57 |
58 | List> authParams = new List>()
59 | {
60 | new KeyValuePair("response_type", responseTypeString),
61 | new KeyValuePair("redirect_uri", RedirectUri),
62 | new KeyValuePair("client_id", ClientId)
63 | };
64 |
65 | return authParams;
66 | }
67 |
68 |
69 | public KeyValuePair[] GetAuthorizationTokenParams()
70 | {
71 | //TODO: make sure ClientSecret is not null
72 |
73 | return new[]
74 | {
75 | new KeyValuePair("client_secret", ClientSecret),
76 | new KeyValuePair("client_id", ClientId),
77 | new KeyValuePair("redirect_uri", RedirectUri),
78 | new KeyValuePair("code", Code)
79 | };
80 | }
81 |
82 | public async Task ParseAccessToken(HttpContent response)
83 | {
84 | var dataResponse = await response.ReadAsStringAsync();
85 |
86 | var parsedDataResponse = JsonConvert.DeserializeObject(dataResponse);
87 |
88 | if (parsedDataResponse.Code.ToLower() == "ok")
89 | {
90 | ReadWriteAccessToken = parsedDataResponse.Result.AccessToken;
91 | SetExpiresAt(parsedDataResponse.Result.ExpiresIn);
92 |
93 | return true;
94 | }
95 | return false;
96 | }
97 |
98 | public void SetExpiresAt(int expiresAt)
99 | {
100 | ExpiresAt = expiresAt;
101 | ExpiresAtWasSet = DateTime.Now;
102 | }
103 |
104 | public bool NeedToRenewAccessToken
105 | {
106 | get
107 | {
108 | return DateTime.Now > ExpiresAtWasSet.AddSeconds(Convert.ToDouble(ExpiresAt)).AddSeconds(-30);
109 | }
110 | }
111 |
112 | }
113 |
114 |
115 | public class AuthorizationResult
116 | {
117 | [JsonProperty("return_type")]
118 | public string ReturnType { get; set; }
119 | [JsonProperty("access_token")]
120 | public string AccessToken { get; set; }
121 | [JsonProperty("token_type")]
122 | public string TokenType { get; set; }
123 | [JsonProperty("expires_in")]
124 | public int ExpiresIn { get; set; }
125 | [JsonProperty("refresh_token")]
126 | public string RefreshToken { get; set; }
127 | [JsonProperty("scope")]
128 | public string Scope { get; set; }
129 | [JsonProperty("state")]
130 | public object State { get; set; }
131 | [JsonProperty("uri")]
132 | public object Uri { get; set; }
133 | [JsonProperty("extended")]
134 | public object Extended { get; set; }
135 | }
136 |
137 | [JsonObject("RootObject")]
138 | public class AuthorizationRootObject
139 | {
140 | [JsonProperty("jsonrpc")]
141 | public string Jsonrpc { get; set; }
142 | [JsonProperty("result")]
143 | public AuthorizationResult Result { get; set; }
144 | [JsonProperty("id")]
145 | public int Id { get; set; }
146 | [JsonProperty("code")]
147 | public string Code { get; set; }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/BeatsHttpData.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Net.Http;
3 | using System.Threading.Tasks;
4 | using CodingChick.BeatsMusicAPI.Core.Data;
5 | using CodingChick.BeatsMusicAPI.Core.Data.Me;
6 | using Newtonsoft.Json;
7 |
8 | namespace CodingChick.BeatsMusicAPI.Core.Base
9 | {
10 | internal class BeatsHttpData : IBeatsHttpData
11 | {
12 | private readonly IHttpBeatsMusicEngine _httpBeatsMusicEngine;
13 |
14 | public BeatsHttpData(IHttpBeatsMusicEngine httpBeatsMusicEngine)
15 | {
16 | _httpBeatsMusicEngine = httpBeatsMusicEngine;
17 | }
18 |
19 | public async Task> GetMultipleParsedResult(string methodName,
20 | List> methodParams, bool useToken = false)
21 | {
22 | string dataResponse = await GetDataResponse(methodName, methodParams, useToken);
23 |
24 | MultipleRootObject parsedDataResponse = ParsedMultipleDataResponse(dataResponse);
25 | return parsedDataResponse;
26 | }
27 |
28 | public async Task> GetSingleParsedResult(string methodName,
29 | List> methodParams, bool useToken = false)
30 | {
31 | string dataResponse = await GetDataResponse(methodName, methodParams, useToken);
32 |
33 | // This is a very annoying fix to make sure API calls are consistent and all return "data", and since "me" api is different in returning "result" I made sure all return the same.
34 | if (typeof (T) == typeof (MeData))
35 | {
36 | dataResponse = dataResponse.Replace("result", "data");
37 | }
38 |
39 | SingleRootObject parsedDataResponse = ParsedSingleDataResponse(dataResponse);
40 |
41 | return parsedDataResponse;
42 | }
43 |
44 | public async Task> PostData(string methodName,
45 | List> dataParams)
46 | {
47 | if (dataParams == null)
48 | dataParams = new List>();
49 |
50 | HttpContent httpResponse = await _httpBeatsMusicEngine.PostAsync(methodName, dataParams);
51 | string dataResponse = await httpResponse.ReadAsStringAsync();
52 |
53 | return ParsedSingleDataResponse(dataResponse);
54 | }
55 |
56 | public async Task> PutData(string methodName,
57 | List> dataParams, bool addCredentials = true)
58 | {
59 | if (dataParams == null)
60 | dataParams = new List>();
61 |
62 | HttpContent httpResponse = await _httpBeatsMusicEngine.PutAsync(methodName, dataParams, addCredentials);
63 | string dataResponse = await httpResponse.ReadAsStringAsync();
64 |
65 | return ParsedSingleDataResponse(dataResponse);
66 | }
67 |
68 | public async Task DeleteData(string methodName, List> dataParams)
69 | {
70 | if (dataParams == null)
71 | dataParams = new List>();
72 |
73 | HttpContent httpResponse = await _httpBeatsMusicEngine.DeleteAsync(methodName, dataParams);
74 | string dataResponse = await httpResponse.ReadAsStringAsync();
75 |
76 | if (dataResponse.ToLower().Contains("ok"))
77 | return true;
78 | return false;
79 | }
80 |
81 | private MultipleRootObject ParsedMultipleDataResponse(string dataResponse)
82 | {
83 | var parsedDataResponse = JsonConvert.DeserializeObject>(dataResponse);
84 | return parsedDataResponse;
85 | }
86 |
87 | public async Task> GetMultipleParsedResultWithConverter(string methodName,
88 | List> methodParams, bool useToken = false)
89 | {
90 | string dataResponse = await GetDataResponse(methodName, methodParams, useToken);
91 |
92 | var parsedDataResponse = JsonConvert.DeserializeObject>(dataResponse,
93 | new BaseDataConverter());
94 |
95 | return parsedDataResponse;
96 | }
97 |
98 | private SingleRootObject ParsedSingleDataResponse(string dataResponse)
99 | {
100 | var parsedDataResponse = JsonConvert.DeserializeObject>(dataResponse);
101 | return parsedDataResponse;
102 | }
103 |
104 | private async Task GetDataResponse(string methodName, List> methodParams,
105 | bool useToken = false)
106 | {
107 | if (methodParams == null)
108 | methodParams = new List>();
109 |
110 | HttpContent contentResult;
111 | if (useToken)
112 | contentResult = await _httpBeatsMusicEngine.GetAsyncWithToken(methodName, methodParams);
113 | else
114 | contentResult = await _httpBeatsMusicEngine.GetAsyncNoToken(methodName, methodParams);
115 |
116 | string dataResponse = await contentResult.ReadAsStringAsync();
117 | return dataResponse;
118 | }
119 |
120 |
121 | public async Task PostData(string methodName, List> dataParams)
122 | {
123 | if (dataParams == null)
124 | dataParams = new List>();
125 |
126 | HttpContent httpResponse = await _httpBeatsMusicEngine.PostAsync(methodName, dataParams);
127 | string dataResponse = await httpResponse.ReadAsStringAsync();
128 |
129 | if (dataResponse.ToLower().Contains("ok"))
130 | return true;
131 | return false;
132 | }
133 | }
134 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/BeatsMusicManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net.Http;
4 | using System.Net.Http.Headers;
5 | using System.Threading.Tasks;
6 | using CodingChick.BeatsMusicAPI.Core.Data;
7 |
8 | namespace CodingChick.BeatsMusicAPI.Core.Base
9 | {
10 | internal class BeatsMusicManager : IBeatsMusicManager
11 | {
12 | private readonly IHttpBeatsMusicEngine _httpBeatsMusicEngine;
13 | private readonly IJsonBeatsMusicEngine _jsonBeatsMusicEngine;
14 |
15 | public BeatsMusicManager(IHttpBeatsMusicEngine httpBeatsMusicEngine, IJsonBeatsMusicEngine jsonBeatsMusicEngine)
16 | {
17 | _httpBeatsMusicEngine = httpBeatsMusicEngine;
18 | _jsonBeatsMusicEngine = jsonBeatsMusicEngine;
19 | }
20 |
21 | public async Task> GetMultipleParsedResult(string methodName,
22 | List> methodParams, bool useToken = false)
23 | {
24 | var dataResponse = await GetDataResponse(methodName, methodParams, useToken);
25 | var parsedDataResponse = _jsonBeatsMusicEngine.ParseMultipleDataResponse(dataResponse);
26 | return parsedDataResponse;
27 | }
28 |
29 | public async Task> GetSingleParsedResult(string methodName,
30 | List> methodParams, bool useToken = false)
31 | {
32 | var dataResponse = await GetDataResponse(methodName, methodParams, useToken);
33 | var parsedDataResponse = _jsonBeatsMusicEngine.ParseSingleDataResponse(dataResponse);
34 | return parsedDataResponse;
35 | }
36 |
37 | public async Task> PostData(string methodName,
38 | List> dataParams)
39 | {
40 | if (dataParams == null)
41 | dataParams = new List>();
42 |
43 | var httpResponse = await _httpBeatsMusicEngine.PostAsync(methodName, dataParams);
44 | var dataResponse = await httpResponse.ReadAsStringAsync();
45 |
46 | return _jsonBeatsMusicEngine.ParseSingleDataResponse(dataResponse);
47 | }
48 |
49 | public async Task> PutData(string methodName,
50 | List> dataParams, bool addCredentials = true)
51 | {
52 | if (dataParams == null)
53 | dataParams = new List>();
54 |
55 | var httpResponse = await _httpBeatsMusicEngine.PutAsync(methodName, dataParams, addCredentials);
56 | var dataResponse = await httpResponse.ReadAsStringAsync();
57 |
58 | return _jsonBeatsMusicEngine.ParseSingleDataResponse(dataResponse);
59 | }
60 |
61 | public async Task DeleteData(string methodName, List> dataParams)
62 | {
63 | if (dataParams == null)
64 | dataParams = new List>();
65 |
66 | var httpResponse = await _httpBeatsMusicEngine.DeleteAsync(methodName, dataParams);
67 | var dataResponse = await httpResponse.ReadAsStringAsync();
68 |
69 | if (dataResponse.ToLower().Contains("ok"))
70 | return true;
71 | return false;
72 | }
73 |
74 | public async Task> GetMultipleParsedResultWithConverter(string methodName,
75 | List> methodParams, bool useToken = false)
76 | {
77 | var dataResponse = await GetDataResponse(methodName, methodParams, useToken);
78 | var parsedDataResponse =
79 | _jsonBeatsMusicEngine.ParseMultipleDataResponseWithConverter(dataResponse);
80 | return parsedDataResponse;
81 | }
82 |
83 | public async Task GetDataUri(string methodName, List> methodParams,
84 | bool useToken)
85 | {
86 | var dataResponse =
87 | await _httpBeatsMusicEngine.GetHeaderAsyncWithNoToken(methodName, methodParams);
88 | return dataResponse.Location;
89 | }
90 |
91 | private async Task GetDataResponse(string methodName, List> methodParams,
92 | bool useToken = false)
93 | {
94 | if (methodParams == null)
95 | methodParams = new List>();
96 |
97 | HttpContent contentResult;
98 | if (useToken)
99 | contentResult = await _httpBeatsMusicEngine.GetAsyncWithToken(methodName, methodParams);
100 | else
101 | contentResult = await _httpBeatsMusicEngine.GetAsyncNoToken(methodName, methodParams);
102 |
103 | var dataResponse = await contentResult.ReadAsStringAsync();
104 | return dataResponse;
105 | }
106 |
107 |
108 | public async Task PostData(string methodName, List> dataParams)
109 | {
110 | if (dataParams == null)
111 | dataParams = new List>();
112 |
113 | var httpResponse = await _httpBeatsMusicEngine.PostAsync(methodName, dataParams);
114 | var dataResponse = await httpResponse.ReadAsStringAsync();
115 |
116 | if (dataResponse.ToLower().Contains("ok"))
117 | return true;
118 | return false;
119 | }
120 |
121 | public async Task PutData(string methodName, List> dataParams,
122 | bool addCredentials = true)
123 | {
124 | if (dataParams == null)
125 | dataParams = new List>();
126 |
127 | var httpResponse = await _httpBeatsMusicEngine.PutAsync(methodName, dataParams, addCredentials);
128 | var dataResponse = await httpResponse.ReadAsStringAsync();
129 |
130 | if (dataResponse.ToLower().Contains("ok"))
131 | return true;
132 | return false;
133 | }
134 | }
135 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/HttpBeatsMusicEngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net.Http;
4 | using System.Net.Http.Headers;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using CodingChick.BeatsMusicAPI.Core.Endpoints.Enums;
8 | using CodingChick.BeatsMusicAPI.Core.Helpers;
9 |
10 | namespace CodingChick.BeatsMusicAPI.Core.Base
11 | {
12 | //TODO: add assersions, lots of assersions
13 | internal class HttpBeatsMusicEngine : IHttpBeatsMusicEngine
14 | {
15 | private readonly IHttpClientAccessor _clientAccessor;
16 | private readonly Authorization _authorization;
17 |
18 |
19 | public string BaseApiAddress
20 | {
21 | get
22 | {
23 | return "https://partner.api.beatsmusic.com/";
24 | }
25 | }
26 |
27 | public string MethodsApiAddress
28 | {
29 | get { return BaseApiAddress + "v1/api/"; }
30 | }
31 |
32 | public HttpBeatsMusicEngine(IHttpClientAccessor clientAccessor, Authorization authorization)
33 | {
34 | _clientAccessor = clientAccessor;
35 | _authorization = authorization;
36 | }
37 |
38 | public async Task GetAsyncNoToken(string method, List> queryParams)
39 | {
40 | queryParams.Add(new KeyValuePair("client_id", _authorization.ClientId));
41 |
42 | var result = await GetAsync(method, queryParams);
43 |
44 | return result;
45 | }
46 |
47 | public async Task GetAsyncWithToken(string method, List> queryParams)
48 | {
49 | await AddAccessTokenToCall(queryParams);
50 |
51 | var result = await GetAsync(method, queryParams);
52 |
53 | return result;
54 | }
55 |
56 | public async Task GetHeaderAsyncWithNoToken(string method,
57 | List> queryParams)
58 | {
59 | queryParams.Add(new KeyValuePair("client_id", _authorization.ClientId));
60 |
61 | var result = await GetHeaderAsync(method, queryParams);
62 |
63 | return result;
64 |
65 | }
66 |
67 | public async Task GetHeadAsyncWithToken(string method,
68 | List> queryParams)
69 | {
70 | await AddAccessTokenToCall(queryParams);
71 |
72 | var result = await GetHeaderAsync(method, queryParams);
73 |
74 | return result;
75 |
76 | }
77 |
78 | public async Task PostAsync(string method, List> dataParams)
79 | {
80 | await AddAccessTokenToCall(dataParams);
81 | var fullAddress = HttpUtilityHelper.CreateFullAddess(MethodsApiAddress, method, dataParams);
82 | var httpContent = new StringContent(string.Empty);
83 |
84 | var result = await _clientAccessor.PostAsync(fullAddress, httpContent);
85 | return result;
86 | }
87 |
88 | public async Task PutAsync(string method, List> dataParams, bool addCredentials = true)
89 | {
90 | if (addCredentials)
91 | await AddAccessTokenToCall(dataParams);
92 | var fullAddress = HttpUtilityHelper.CreateFullAddess(MethodsApiAddress, method, dataParams);
93 | var httpContent = new StringContent(string.Empty);
94 |
95 | var result = await _clientAccessor.PutAsync(fullAddress, httpContent);
96 | return result;
97 | }
98 |
99 | public async Task DeleteAsync(string method, List> dataParams)
100 | {
101 | await AddAccessTokenToCall(dataParams);
102 | var fullAddress = HttpUtilityHelper.CreateFullAddess(MethodsApiAddress, method, dataParams);
103 |
104 | var result = await _clientAccessor.DeleteAsync(fullAddress);
105 | return result;
106 | }
107 |
108 |
109 | public string UriAddressToNavigateForPermissions(ResponseType responseType)
110 | {
111 | _authorization.ResponseType = responseType;
112 | var authParams = _authorization.CreateAuthorizatioUriParams(responseType);
113 | return BaseApiAddress + _authorization.AuthorizatioUri + HttpUtilityHelper.ToQueryString(authParams);
114 | }
115 |
116 | private async Task GetAsync(string method, List> queryParams)
117 | {
118 | var finalAddress = HttpUtilityHelper.CreateFullAddess(MethodsApiAddress, method, queryParams);
119 | var result = await _clientAccessor.GetAsync(finalAddress);
120 | return result;
121 | }
122 |
123 | private async Task GetHeaderAsync(string method,
124 | List> queryParams)
125 | {
126 | var finalAddress = HttpUtilityHelper.CreateFullAddess(MethodsApiAddress, method, queryParams);
127 | var result = await _clientAccessor.GetHeaderAsync(finalAddress);
128 | return result;
129 | }
130 |
131 | private async Task AddAccessTokenToCall(List> dataParams)
132 | {
133 | if (_authorization.ReadOnlyAccessToken != null)
134 | dataParams.Add(new KeyValuePair("access_token", _authorization.ReadOnlyAccessToken));
135 | else
136 | {
137 | if (_authorization.ReadWriteAccessToken == null || _authorization.NeedToRenewAccessToken)
138 | {
139 | var succeed = await RenewReadWriteAccessToken();
140 | }
141 | dataParams.Add(new KeyValuePair("access_token", _authorization.ReadWriteAccessToken));
142 | }
143 | }
144 |
145 | private async Task RenewReadWriteAccessToken()
146 | {
147 | var requestTokenUri = BaseApiAddress + _authorization.TokenUri;
148 | var requestParams =
149 | _authorization.GetAuthorizationTokenParams();
150 |
151 | var response =
152 | await _clientAccessor.PostAsync(requestTokenUri, new FormUrlEncodedContent(requestParams));
153 |
154 | return await _authorization.ParseAccessToken(response);
155 | }
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/HttpClientAccessor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net.Http;
4 | using System.Net.Http.Headers;
5 | using System.Threading.Tasks;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Base
8 | {
9 | public class HttpClientAccessor : IHttpClientAccessor
10 | {
11 | private readonly HttpClient _httpClient;
12 |
13 | public HttpClientAccessor()
14 | {
15 | var httpClientHandler = new HttpClientHandler();
16 | httpClientHandler.AllowAutoRedirect = false;
17 | _httpClient = new HttpClient(httpClientHandler);
18 | }
19 |
20 | public async Task GetAsync(string address)
21 | {
22 | return await GetAsync(address, new Dictionary>());
23 | }
24 |
25 | public async Task GetAsync(string address, IDictionary> headers)
26 | {
27 | foreach (var header in headers)
28 | {
29 | _httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
30 | }
31 |
32 | var response = await _httpClient.GetAsync(address);
33 | return response.Content;
34 | }
35 |
36 |
37 | public async Task DeleteAsync(string address)
38 | {
39 | return await DeleteAsync(address, new Dictionary>());
40 | }
41 |
42 | public async Task DeleteAsync(string address, IDictionary> headers)
43 | {
44 | foreach (var header in headers)
45 | {
46 | _httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
47 | }
48 |
49 | var response = await _httpClient.DeleteAsync(address);
50 | return response.Content;
51 | }
52 |
53 | public async Task GetHeaderAsync(string finalAddress)
54 | {
55 | //Would rather make this a true Head call, but the method isn't allowed so I am faking it
56 | var request = new HttpRequestMessage(HttpMethod.Get, new Uri(finalAddress, UriKind.Absolute));
57 | var response = await _httpClient.SendAsync(request);
58 |
59 | return response.Headers;
60 | }
61 |
62 | public async Task PutAsync(string address, HttpContent content, string charSet = "",
63 | string mediaType = "")
64 | {
65 | AddHeadersToContent(content, charSet, mediaType);
66 |
67 | var response = await _httpClient.PutAsync(address, content);
68 | return response.Content;
69 | }
70 |
71 |
72 | public async Task PostAsync(string address, HttpContent content,
73 | string charSet = "",
74 | string mediaType = "")
75 | {
76 | AddHeadersToContent(content, charSet, mediaType);
77 |
78 | try
79 | {
80 | var client = new HttpClient();
81 | var response = await client.PostAsync(address, content);
82 | return response.Content;
83 | }
84 | catch (Exception ex)
85 | {
86 | throw;
87 | }
88 | }
89 |
90 | private static void AddHeadersToContent(HttpContent content, string charSet, string mediaType)
91 | {
92 | if (charSet != string.Empty && mediaType != string.Empty)
93 | {
94 | content.Headers.ContentType.CharSet = charSet;
95 | content.Headers.ContentType.MediaType = mediaType;
96 | }
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/IBeatsHttpData.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using CodingChick.BeatsMusicAPI.Core.Data;
4 |
5 | namespace CodingChick.BeatsMusicAPI.Core.Base
6 | {
7 | internal interface IBeatsHttpData
8 | {
9 | Task> GetMultipleParsedResult(string methodName, List> methodParams, bool useToken = false);
10 | Task> GetSingleParsedResult(string methodName, List> methodParams, bool useToken = false);
11 | Task> PostData(string methodName, List> dataParams);
12 | Task> PutData(string methodName, List> dataParams, bool addCredentials = true);
13 | Task DeleteData(string methodName, List> dataParams);
14 | }
15 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/IBeatsMusicManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using CodingChick.BeatsMusicAPI.Core.Data;
4 |
5 | namespace CodingChick.BeatsMusicAPI.Core.Base
6 | {
7 | internal interface IBeatsMusicManager
8 | {
9 | Task> GetMultipleParsedResult(string methodName, List> methodParams, bool useToken = false);
10 | Task> GetSingleParsedResult(string methodName, List> methodParams, bool useToken = false);
11 | Task> PostData(string methodName, List> dataParams);
12 | Task> PutData(string methodName, List> dataParams, bool addCredentials = true);
13 | Task DeleteData(string methodName, List> dataParams);
14 | }
15 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/IHttpBeatsMusicEngine.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Net.Http;
3 | using System.Net.Http.Headers;
4 | using System.Threading.Tasks;
5 | using CodingChick.BeatsMusicAPI.Core.Endpoints.Enums;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Base
8 | {
9 | public interface IHttpBeatsMusicEngine
10 | {
11 | //Task GetAsyncWithToken(string methodAndParamethers);
12 | Task GetAsyncNoToken(string method, List> queryParams);
13 | string UriAddressToNavigateForPermissions(ResponseType responseType);
14 | Task PostAsync(string method, List> dataParams);
15 | Task GetAsyncWithToken(string method, List> queryParams);
16 |
17 | Task PutAsync(string method, List> dataParams,
18 | bool addCredentials = true);
19 |
20 | Task DeleteAsync(string method, List> dataParams);
21 |
22 | Task GetHeaderAsyncWithNoToken(string method,
23 | List> queryParams);
24 |
25 | Task GetHeadAsyncWithToken(string method,
26 | List> queryParams);
27 | }
28 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/IHttpClientAccessor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Net.Http;
3 | using System.Net.Http.Headers;
4 | using System.Threading.Tasks;
5 |
6 | namespace CodingChick.BeatsMusicAPI.Core.Base
7 | {
8 | public interface IHttpClientAccessor
9 | {
10 | Task GetAsync(string address);
11 | Task GetAsync(string address, IDictionary> headers);
12 |
13 | Task PostAsync(string address, HttpContent content,
14 | string charSet = "",
15 | string mediaType = "");
16 | Task PutAsync(string address, HttpContent content, string charSet = "",
17 | string mediaType = "");
18 | Task DeleteAsync(string address);
19 | Task DeleteAsync(string address, IDictionary> headers);
20 | Task GetHeaderAsync(string finalAddress);
21 | }
22 |
23 |
24 |
25 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/IJsonBeatsMusicEngine.cs:
--------------------------------------------------------------------------------
1 | using CodingChick.BeatsMusicAPI.Core.Data;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Base
4 | {
5 | public interface IJsonBeatsMusicEngine
6 | {
7 | MultipleRootObject ParseMultipleDataResponse(string dataResponse);
8 | MultipleRootObject ParseMultipleDataResponseWithConverter(string dataResponse);
9 | SingleRootObject ParseSingleDataResponse(string dataResponse);
10 | }
11 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/JsonBeatsMusicEngine.cs:
--------------------------------------------------------------------------------
1 | using CodingChick.BeatsMusicAPI.Core.Base.JsonHelpers;
2 | using CodingChick.BeatsMusicAPI.Core.Data;
3 | using CodingChick.BeatsMusicAPI.Core.Data.Me;
4 | using Newtonsoft.Json;
5 |
6 | namespace CodingChick.BeatsMusicAPI.Core.Base
7 | {
8 | internal class JsonBeatsMusicEngine : IJsonBeatsMusicEngine
9 | {
10 | public MultipleRootObject ParseMultipleDataResponse(string dataResponse)
11 | {
12 | var parsedDataResponse = JsonConvert.DeserializeObject>(dataResponse, new JsonSerializerSettings() { ContractResolver = new UnderscoreResolver() });
13 | return parsedDataResponse;
14 | }
15 |
16 | public MultipleRootObject ParseMultipleDataResponseWithConverter(string dataResponse)
17 | {
18 | var parsedDataResponse = JsonConvert.DeserializeObject>(dataResponse, new JsonSerializerSettings() { ContractResolver = new UnderscoreResolver(), Converters = new[] { new BaseDataConverter() } });
19 | return parsedDataResponse;
20 | }
21 |
22 | public SingleRootObject ParseSingleDataResponse(string dataResponse)
23 | {
24 | // This is a very annoying fix to make sure API calls are consistent and all return "data",
25 | // and since "me" api is different in returning "result" I made sure all return the same.
26 | if (typeof(T) == typeof(MeData))
27 | {
28 | dataResponse = dataResponse.Replace("result", "data");
29 | }
30 |
31 | var parsedDataResponse = JsonConvert.DeserializeObject>(dataResponse, new JsonSerializerSettings() { ContractResolver = new UnderscoreResolver() });
32 | return parsedDataResponse;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/JsonHelpers/BaseDataConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using CodingChick.BeatsMusicAPI.Core.Data;
3 | using CodingChick.BeatsMusicAPI.Core.Data.Albums;
4 | using CodingChick.BeatsMusicAPI.Core.Data.Playlists;
5 | using Newtonsoft.Json.Linq;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Base.JsonHelpers
8 | {
9 | public class BaseDataConverter : JsonCreationConverter
10 | {
11 | protected override BaseConvertedData Create(Type objectType, JObject jObject)
12 | {
13 | if (FieldExists("essential", jObject))
14 | {
15 | return new AlbumData();
16 | }
17 | else if (FieldExists("user_display_name", jObject))
18 | {
19 | return new PlaylistData();
20 | }
21 | else
22 | {
23 | return new BaseConvertedData();
24 | }
25 | }
26 |
27 | private bool FieldExists(string fieldName, JObject jObject)
28 | {
29 | return jObject[fieldName] != null;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/JsonHelpers/JsonCreationConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 | using Newtonsoft.Json.Linq;
4 |
5 | namespace CodingChick.BeatsMusicAPI.Core.Base.JsonHelpers
6 | {
7 | public abstract class JsonCreationConverter : JsonConverter
8 | {
9 | ///
10 | /// Create an instance of objectType, based properties in the JSON object
11 | ///
12 | /// type of object expected
13 | ///
14 | /// contents of JSON object that will be deserialized
15 | ///
16 | ///
17 | protected abstract T Create(Type objectType, JObject jObject);
18 |
19 | public override bool CanConvert(Type objectType)
20 | {
21 | return typeof(T).IsAssignableFrom(objectType);
22 | }
23 |
24 | public override object ReadJson(JsonReader reader,
25 | Type objectType,
26 | object existingValue,
27 | JsonSerializer serializer)
28 | {
29 | // Load JObject from stream
30 | JObject jObject = JObject.Load(reader);
31 |
32 | // Create target object based on JObject
33 | T target = Create(objectType, jObject);
34 |
35 | // Populate the object properties
36 | serializer.Populate(jObject.CreateReader(), target);
37 |
38 | return target;
39 | }
40 |
41 | public override void WriteJson(JsonWriter writer,
42 | object value,
43 | JsonSerializer serializer)
44 | {
45 | throw new NotImplementedException();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Base/JsonHelpers/UnderscoreResolver.cs:
--------------------------------------------------------------------------------
1 | using System.Text.RegularExpressions;
2 | using Newtonsoft.Json.Serialization;
3 |
4 | namespace CodingChick.BeatsMusicAPI.Core.Base.JsonHelpers
5 | {
6 | public class UnderscoreResolver : DefaultContractResolver
7 | {
8 | protected override string ResolvePropertyName(string propertyName)
9 | {
10 | string propertyNameNoUnderscore =
11 | Regex.Replace(
12 | propertyName, @"([A-Z])([A-Z][a-z])|([a-z])([A-Z])", "$3_$4");
13 | return base.ResolvePropertyName(propertyNameNoUnderscore);
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/BeatsMusicClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.CompilerServices;
3 | using System.Threading.Tasks;
4 | using CodingChick.BeatsMusicAPI.Core.Base;
5 | using CodingChick.BeatsMusicAPI.Core.Data;
6 | using CodingChick.BeatsMusicAPI.Core.Data.Me;
7 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
8 | using CodingChick.BeatsMusicAPI.Core.Endpoints.Enums;
9 | using CodingChick.BeatsMusicAPI.Core.Helpers;
10 |
11 | [assembly: InternalsVisibleTo("CodingChick.BeatsMusicAPI.Tests")]
12 |
13 | namespace CodingChick.BeatsMusicAPI.Core
14 | {
15 | public class BeatsMusicClient
16 | {
17 | private readonly Lazy _albums;
18 | private readonly Lazy _artists;
19 | private readonly Lazy _audio;
20 | private readonly Authorization _authorization;
21 | private readonly BeatsMusicManager _beatsMusicManager;
22 | private readonly Lazy _follow;
23 | private readonly Lazy _genre;
24 | private readonly Lazy _highlights;
25 | private readonly IHttpBeatsMusicEngine _httpBeatsMusicEngine;
26 | private readonly Lazy _images;
27 | private readonly Lazy _me;
28 | private readonly Lazy _playlists;
29 | private readonly Lazy _ratings;
30 | private readonly Lazy _search;
31 | private readonly Lazy _tracks;
32 |
33 | ///
34 | /// Initializes a new instance of for read-only operations.
35 | ///
36 | /// Beats Music API client ID.
37 | /// Beats Music Redirect Uri.
38 | public BeatsMusicClient(string clientId, string redirectUri)
39 | {
40 | _authorization = new Authorization(redirectUri, clientId);
41 |
42 | _httpBeatsMusicEngine = new HttpBeatsMusicEngine(new HttpClientAccessor(), _authorization);
43 |
44 | _beatsMusicManager = new BeatsMusicManager(_httpBeatsMusicEngine, new JsonBeatsMusicEngine());
45 | _search = new Lazy(() => new SearchEndpoint(_beatsMusicManager));
46 | _playlists = new Lazy(() => new PlaylistsEndpoint(_beatsMusicManager));
47 | _albums = new Lazy(() => new AlbumsEndpoint(_beatsMusicManager));
48 | _artists = new Lazy(() => new ArtistsEndpoint(_beatsMusicManager));
49 | _highlights = new Lazy(() => new HighlightsEndpoint(_beatsMusicManager));
50 | _follow = new Lazy(() => new FollowEndpoint(_beatsMusicManager));
51 | _genre = new Lazy(() => new GenreEndpoint(_beatsMusicManager));
52 | _audio = new Lazy(() => new AudioEndpoint(_beatsMusicManager));
53 | _ratings = new Lazy(()=> new RatingsEndpoint(_beatsMusicManager));
54 | _me = new Lazy(() => new MeEndpoint(_beatsMusicManager));
55 | _images = new Lazy(() => new ImagesEndpoint(_beatsMusicManager));
56 | _tracks = new Lazy(() => new TracksEndpoint(_beatsMusicManager));
57 | }
58 |
59 | ///
60 | /// Initializes a new instance of for read-write and user specific operations.
61 | ///
62 | /// Beats Music API client ID.
63 | /// Beats Music API Redirect Uri.
64 | /// Beats Music API client secret
65 | public BeatsMusicClient(string clientId, string redirectUri, string clientSecret)
66 | : this(clientId, redirectUri)
67 | {
68 | _authorization.ClientSecret = clientSecret;
69 | }
70 |
71 | public MeEndpoint Me
72 | {
73 | get { return _me.Value; }
74 | }
75 |
76 | public AudioEndpoint Audio
77 | {
78 | get { return _audio.Value; }
79 | }
80 |
81 | public GenreEndpoint Genre
82 | {
83 | get { return _genre.Value; }
84 | }
85 |
86 | public FollowEndpoint Follow
87 | {
88 | get { return _follow.Value; }
89 | }
90 |
91 | public HighlightsEndpoint Highlights
92 | {
93 | get { return _highlights.Value; }
94 | }
95 |
96 | public AlbumsEndpoint Albums
97 | {
98 | get { return _albums.Value; }
99 | }
100 |
101 | public SearchEndpoint Search
102 | {
103 | get { return _search.Value; }
104 | }
105 |
106 | public PlaylistsEndpoint Playlists
107 | {
108 | get { return _playlists.Value; }
109 | }
110 |
111 | public RatingsEndpoint Ratings
112 | {
113 | get { return _ratings.Value; }
114 | }
115 |
116 | public ImagesEndpoint Images
117 | {
118 | get { return _images.Value; }
119 | }
120 |
121 | public TracksEndpoint Tracks
122 | {
123 | get { return _tracks.Value; }
124 | }
125 |
126 | public string ServerCode
127 | {
128 | get { return _authorization.Code; }
129 | set { _authorization.Code = value; }
130 | }
131 |
132 | public ArtistsEndpoint Artists
133 | {
134 | get { return _artists.Value; }
135 | }
136 |
137 | public string ClientId
138 | {
139 | get { return _authorization.ClientId; }
140 | }
141 |
142 | public string AccessToken
143 | {
144 | get
145 | {
146 | if (!string.IsNullOrEmpty(_authorization.ReadOnlyAccessToken))
147 | return _authorization.ReadOnlyAccessToken;
148 | return _authorization.ReadWriteAccessToken;
149 | }
150 | }
151 |
152 | #region Internal
153 |
154 | internal string ReadWriteAccessToken
155 | {
156 | get { return _authorization.ReadWriteAccessToken; }
157 | set { _authorization.ReadWriteAccessToken = value; }
158 | }
159 |
160 | internal void SetExpiresAt(int seconds)
161 | {
162 | _authorization.SetExpiresAt(seconds);
163 | }
164 |
165 | #endregion
166 |
167 | public string UriAddressToNavigateForPermissions()
168 | {
169 | if (_authorization.ClientSecret == null)
170 | return _httpBeatsMusicEngine.UriAddressToNavigateForPermissions(ResponseType.Token);
171 | return _httpBeatsMusicEngine.UriAddressToNavigateForPermissions(ResponseType.Code);
172 | }
173 |
174 | public void SetClientAccessTokenFromRedirectUri(string accessToken, int expiresAt)
175 | {
176 | _authorization.ReadOnlyAccessToken = accessToken;
177 | _authorization.SetExpiresAt(expiresAt);
178 | }
179 |
180 | public async Task GetBeatsMusicPlayerCode(string playableResourceId)
181 | {
182 | var user = await Me.GetMeInfo();
183 | var helper = new FileHelper();
184 | var fileContents = helper.GetResourceTextFile("PlayerCode.html");
185 | fileContents = fileContents.Replace("myClientId", _authorization.ClientId);
186 | fileContents = fileContents.Replace("myAccessToken", AccessToken);
187 | fileContents = fileContents.Replace("myUserId", user.Data.UserContext);
188 | fileContents = fileContents.Replace("myTrack", playableResourceId);
189 | return fileContents;
190 | }
191 |
192 | //Internal properties exposed for testing purposes only.
193 | }
194 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Activities/ActivityData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Activities
8 | {
9 | [JsonObject("Datum")]
10 | public class ActivityData : BaseData
11 | {
12 | public string Type { get; set; }
13 | public string Name { get; set; }
14 | public string Id { get; set; }
15 | public int CreatedAt { get; set; }
16 | public int TotalEditorialPlaylists { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Albums/AlbumData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Text;
4 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Albums
8 | {
9 | [JsonObject("Datum")]
10 | public class AlbumData : BaseConvertedData
11 | {
12 | public string Title { get; set; }
13 |
14 | public int Duration { get; set; }
15 |
16 | public bool ParentalAdvisory { get; set; }
17 |
18 | public bool EditedVersion { get; set; }
19 |
20 | public string ReleaseDate { get; set; }
21 |
22 | public string ReleaseFormat { get; set; }
23 |
24 | public int Rating { get; set; }
25 |
26 | public int Popularity { get; set; }
27 |
28 | public bool Streamable { get; set; }
29 | public string ArtistDisplayName { get; set; }
30 |
31 | [JsonProperty("refs")]
32 | public AlbumRefs AlbumRefs { get; set; }
33 |
34 | public bool Canonical { get; set; }
35 |
36 | public int TotalCompanionAlbums { get; set; }
37 |
38 | public int TotalTracks { get; set; }
39 |
40 | public bool Essential { get; set; }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Albums/AlbumRefs.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 |
4 | namespace CodingChick.BeatsMusicAPI.Core.Data.Albums
5 | {
6 | public class AlbumRefs
7 | {
8 | public List Artists { get; set; }
9 | public RefTypeInfo Label { get; set; }
10 | public List Tracks { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Artists/ArtistData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Text;
4 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Artists
8 | {
9 | [JsonObject("Datum")]
10 | public class ArtistData : BaseData
11 | {
12 | public string Type { get; set; }
13 | public string Id { get; set; }
14 | public string Name { get; set; }
15 | public int Popularity { get; set; }
16 | public bool Streamable { get; set; }
17 | public string TotalAlbums { get; set; }
18 | public string TotalSingles { get; set; }
19 | public string TotalEps { get; set; }
20 | public string TotalLps { get; set; }
21 | public int TotalFreeplays { get; set; }
22 | public string TotalCompilations { get; set; }
23 | public string TotalTracks { get; set; }
24 | public ArtistRefs Refs { get; set; }
25 | public bool Verified { get; set; }
26 | public int TotalFollows { get; set; }
27 | public int TotalFollowedBy { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Artists/ArtistRefs.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data.Artists
4 | {
5 | public class ArtistRefs
6 | {
7 | public List Similars { get; set; }
8 | }
9 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Audio/AudioData.cs:
--------------------------------------------------------------------------------
1 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
2 | using Newtonsoft.Json;
3 |
4 | namespace CodingChick.BeatsMusicAPI.Core.Data.Audio
5 | {
6 | [JsonObject("Datum")]
7 | public class AudioData : BaseData
8 | {
9 | public string Location { get; set; }
10 | public string Resource { get; set; }
11 | public string Codec { get; set; }
12 | public int Bitrate { get; set; }
13 | public string Type { get; set; }
14 | public AudioRefs Refs { get; set; }
15 |
16 | }
17 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Audio/AudioRefs.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data.Audio
4 | {
5 | public class AudioRefs
6 | {
7 | public RefTypeInfo Track { get; set; }
8 | }
9 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/BaseData.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 | using Newtonsoft.Json.Linq;
4 |
5 | namespace CodingChick.BeatsMusicAPI.Core.Data
6 | {
7 | public class BaseConvertedData : BaseData
8 | {
9 | public string Type { get; set; }
10 |
11 | public string Id { get; set; }
12 | }
13 |
14 | public abstract class BaseData
15 | {
16 | [JsonExtensionData]
17 | public IDictionary AdditionalData;
18 | }
19 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Content/ContentData.cs:
--------------------------------------------------------------------------------
1 |
2 | using Newtonsoft.Json;
3 |
4 | namespace CodingChick.BeatsMusicAPI.Core.Data.Content
5 | {
6 | [JsonObject("Datum")]
7 | public class ContentData : BaseData
8 | {
9 | public string Type { get; set; }
10 | public string Id { get; set; }
11 | public string Title { get; set; }
12 | public int Duration { get; set; }
13 | public bool ParentalAdvisory { get; set; }
14 | public bool EditedVersion { get; set; }
15 | public string ReleaseDate { get; set; }
16 | public string ReleaseFormat { get; set; }
17 | public int Rating { get; set; }
18 | public int Popularity { get; set; }
19 | public bool Streamable { get; set; }
20 | public string ArtistDisplayName { get; set; }
21 | public ContentRefs Refs { get; set; }
22 | public bool Canonical { get; set; }
23 | public int TotalCompanionAlbums { get; set; }
24 | public int TotalTracks { get; set; }
25 | public bool Essential { get; set; }
26 | public string Name { get; set; }
27 | public string Description { get; set; }
28 | public string UserDisplayName { get; set; }
29 | public string Access { get; set; }
30 | public int? TotalSubscribers { get; set; }
31 | public int? CreatedAt { get; set; }
32 | public int? UpdatedAt { get; set; }
33 | }
34 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Content/ContentRefs.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 |
4 | namespace CodingChick.BeatsMusicAPI.Core.Data.Content
5 | {
6 | public class ContentRefs
7 | {
8 | public List Artists { get; set; }
9 | public RefTypeInfo Label { get; set; }
10 | public List Tracks { get; set; }
11 | public RefTypeInfo User { get; set; }
12 | public RefTypeInfo Author { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Genres/GenreData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Genres
8 | {
9 | [JsonObject("Datum")]
10 | public class GenreData : BaseData
11 | {
12 | public string Id { get; set; }
13 | public string Username { get; set; }
14 | public string Name { get; set; }
15 | public bool Verified { get; set; }
16 | public int TotalFollows { get; set; }
17 | public int TotalFollowedBy { get; set; }
18 | public int PlaylistCount { get; set; }
19 | public string Type { get; set; }
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Info.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data
4 | {
5 | public class Info
6 | {
7 | public int Offset { get; set; }
8 | public int Count { get; set; }
9 | public int Total { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Me/MeData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Me
8 | {
9 | [JsonObject("Datum")]
10 | public class MeData : BaseData
11 | {
12 | public string ClientId { get; set; }
13 |
14 | public string TokenType { get; set; }
15 |
16 | public string GrantType { get; set; }
17 |
18 | public string Expires { get; set; }
19 |
20 | public string Scope { get; set; }
21 |
22 | public string UserContext { get; set; }
23 |
24 | public object Extended { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/MultipleRootObject.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Newtonsoft.Json;
3 |
4 | namespace CodingChick.BeatsMusicAPI.Core.Data
5 | {
6 | [JsonObject("RootObject")]
7 | public class MultipleRootObject : RootObject
8 | {
9 | public List Data { get; set; }
10 |
11 | public Info Info { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Player/PlayerCode.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | My Beats Music Player
4 |
5 |
6 |
7 |
48 |
49 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Playlists/PlaylistData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
6 | using Newtonsoft.Json;
7 |
8 | namespace CodingChick.BeatsMusicAPI.Core.Data.Playlists
9 | {
10 | [JsonObject("Datum")]
11 | public class PlaylistData : BaseConvertedData
12 | {
13 | public string Name { get; set; }
14 | public string Description { get; set; }
15 | public string UserDisplayName { get; set; }
16 | public string Access { get; set; }
17 | public int Duration { get; set; }
18 | public int TotalTracks { get; set; }
19 | public int TotalSubscribers { get; set; }
20 | public int CreatedAt { get; set; }
21 | public int UpdatedAt { get; set; }
22 | public bool ParentalAdvisory { get; set; }
23 | public PlaylistsRefs Refs { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Playlists/PlaylistsRefs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
6 | using Newtonsoft.Json;
7 |
8 | namespace CodingChick.BeatsMusicAPI.Core.Data.Playlists
9 | {
10 | public class PlaylistsRefs
11 | {
12 | public List Tracks { get; set; }
13 | public RefTypeInfo User { get; set; }
14 | public RefTypeInfo Author { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Ratings/RatingData.cs:
--------------------------------------------------------------------------------
1 | using CodingChick.BeatsMusicAPI.Core.Endpoints.Enums;
2 | using Newtonsoft.Json;
3 |
4 | namespace CodingChick.BeatsMusicAPI.Core.Data.Ratings
5 | {
6 | public class RatingData : BaseConvertedData
7 | {
8 | public int? UpdatedAt { get; set; }
9 | public RefTypeInfo Rated { get; set; }
10 | public Rating Rating { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/RefTypeInfo.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data
4 | {
5 | public class RefTypeInfo
6 | {
7 | public string RefType { get; set; }
8 | public string Id { get; set; }
9 | public string Display { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Reviews/ReviewData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Reviews
8 | {
9 | [JsonObject("Datum")]
10 | public class ReviewData : BaseData
11 | {
12 | public string Type { get; set; }
13 | public string Content { get; set; }
14 | public string Headline { get; set; }
15 | public string Rating { get; set; }
16 | public string Source { get; set; }
17 | public string Author { get; set; }
18 | public RefTypeInfo Subject { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/RootObject.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data
4 | {
5 | public abstract class RootObject
6 | {
7 | public string Code { get; set; }
8 |
9 | public bool HasErrors
10 | {
11 | get { return Code.ToLower() != "ok"; }
12 | }
13 |
14 | }
15 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Search/Related.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data.Search
4 | {
5 | public class Related
6 | {
7 | [JsonProperty("ref_type")]
8 | public string RefereceType { get; set; }
9 | public string Id { get; set; }
10 | public string Display { get; set; }
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Search/SearchData.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data.Search
4 | {
5 | [JsonObject("Datum")]
6 | public class SearchData : BaseData
7 | {
8 | public string Type { get; set; }
9 | public string ResultType { get; set; }
10 | public string Id { get; set; }
11 | public string Display { get; set; }
12 | public string Detail { get; set; }
13 | public Related Related { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/SingleRootObject.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace CodingChick.BeatsMusicAPI.Core.Data
4 | {
5 | [JsonObject("RootObject")]
6 | public class SingleRootObject : RootObject
7 | {
8 | public T Data { get; set; }
9 |
10 | }
11 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Tracks/TrackData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Text;
4 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Tracks
8 | {
9 | [JsonObject("Datum")]
10 | public class TrackData : BaseData
11 | {
12 | public string Type { get; set; }
13 | public string Id { get; set; }
14 | public string Title { get; set; }
15 | public int DiscNumber { get; set; }
16 | public bool ParentalAdvisory { get; set; }
17 | public bool EditedVersion { get; set; }
18 | public int Duration { get; set; }
19 | public int TrackPosition { get; set; }
20 | public int Popularity { get; set; }
21 | public bool Streamable { get; set; }
22 | public string ReleaseDate { get; set; }
23 | public string ArtistDisplayName { get; set; }
24 | public TrackRefs Refs { get; set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Tracks/TrackRefs.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using CodingChick.BeatsMusicAPI.Core.Endpoints;
3 | using Newtonsoft.Json;
4 |
5 | namespace CodingChick.BeatsMusicAPI.Core.Data.Tracks
6 | {
7 | public class TrackRefs
8 | {
9 | public List Artists { get; set; }
10 | public RefTypeInfo Album { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Data/Users/UserData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Newtonsoft.Json;
6 |
7 | namespace CodingChick.BeatsMusicAPI.Core.Data.Users
8 | {
9 | [JsonObject("Datum")]
10 | public class UserData : BaseData
11 | {
12 | public string Type { get; set; }
13 | public string Id { get; set; }
14 | public string Username { get; set; }
15 | public string FullName { get; set; }
16 | public int TotalFollowedBy { get; set; }
17 | public int TotalFollows { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Endpoints/ActivitiesEndpoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics.Contracts;
4 | using System.Threading.Tasks;
5 | using CodingChick.BeatsMusicAPI.Core.Base;
6 | using CodingChick.BeatsMusicAPI.Core.Data;
7 | using CodingChick.BeatsMusicAPI.Core.Data.Activities;
8 |
9 | namespace CodingChick.BeatsMusicAPI.Core.Endpoints
10 | {
11 | //TODO: add comments
12 | public class ActivitiesEndpoint : BaseEndpoint
13 | {
14 |
15 | internal ActivitiesEndpoint(BeatsMusicManager beatsMusicManager) : base(beatsMusicManager)
16 | {
17 | }
18 |
19 | public async Task> GetAllActivities()
20 | {
21 | return await BeatsMusicManager.GetMultipleParsedResult("activities", null);
22 | }
23 |
24 | public async Task> GetActivityById(string activityId)
25 | {
26 | Contract.Requires(!string.IsNullOrEmpty(activityId), "activityId should contain a value");
27 |
28 | return await BeatsMusicManager.GetSingleParsedResult("activities/" + activityId, null);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/CodingChick.BeatsMusicAPI/CodingChick.BeatsMusicAPI.Core/Endpoints/AlbumsEndpoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics.Contracts;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using CodingChick.BeatsMusicAPI.Core.Base;
8 | using CodingChick.BeatsMusicAPI.Core.Data;
9 | using CodingChick.BeatsMusicAPI.Core.Data.Albums;
10 | using CodingChick.BeatsMusicAPI.Core.Data.Artists;
11 | using CodingChick.BeatsMusicAPI.Core.Data.Reviews;
12 | using CodingChick.BeatsMusicAPI.Core.Data.Tracks;
13 | using CodingChick.BeatsMusicAPI.Core.Endpoints.Enums;
14 | using CodingChick.BeatsMusicAPI.Core.Helpers;
15 |
16 | namespace CodingChick.BeatsMusicAPI.Core.Endpoints
17 | {
18 | public class AlbumsEndpoint : BaseEndpoint
19 | {
20 |
21 | internal AlbumsEndpoint(BeatsMusicManager beatsMusicManager)
22 | : base(beatsMusicManager)
23 | {
24 | }
25 |
26 | ///
27 | /// You can retrieve part or all of the collection of albums in Beats, including those not available for streaming.
28 | ///
29 | /// Indicates how the results set should be sorted.
30 | /// Specifies the maximum number of records to retrieve. The number of results returned will be less than or equal to this value. No results are returned if it is set to zero or less. The maximum permitted value is 200. If a value higher than 200 is specified, no more 200 results will be returned. Default 20
31 | /// A zero-based integer offset into the results. Default 0.
32 | /// A Task containing a list of AlbumData
33 | public async Task> GetAlbumCollection(AlbumsOrderBy albumsOrderBy, int offset = 0, int limit = 20)
34 | {
35 | Contract.Requires(limit >= 0, "limit can only be a positive number");
36 | Contract.Requires(offset >= 0, "offset can only be a positive number");
37 |
38 | var methodParams = new List>();
39 | methodParams = AddOffsetAndLimitParams(methodParams, offset, limit);
40 | methodParams = AddOrderByParam(albumsOrderBy, methodParams);
41 |
42 |
43 | return await BeatsMusicManager.GetMultipleParsedResult("albums", methodParams);
44 | }
45 |
46 | ///
47 | /// You can retrieve a single album from the collection of available albums.
48 | ///
49 | /// The unique ID of the album.
50 | ///
51 | //TODO: add the other two parameters (fields and refs)
52 | public async Task> GetAlbumById(string albumId)
53 | {
54 | Contract.Requires(!string.IsNullOrEmpty(albumId), "albumId is null or empty");
55 |
56 | return
57 | await
58 | BeatsMusicManager.GetSingleParsedResult(GetSingleFirstLevelMethod(albumId), null);
59 | }
60 |
61 | public async Task> GetArtistsInAlbumId(string albumId)
62 | {
63 | Contract.Requires