Skip to content

Feature/shows and episodes#437

Merged
JohnnyCrazy merged 6 commits intomasterfrom
feature/shows-and-episodes
May 30, 2020
Merged

Feature/shows and episodes#437
JohnnyCrazy merged 6 commits intomasterfrom
feature/shows-and-episodes

Conversation

@JohnnyCrazy
Copy link
Copy Markdown
Owner

@JohnnyCrazy JohnnyCrazy commented Apr 14, 2020

This is the successor to #436

First of all, thanks @shayo, Great work!

I had to create a new branch because I was unable to commit to your master branch @shayo. Next time, it would be good if you open a feature branch in your fork and grant write access (This is done automatically on GitHub normally). If you want to add/fix anything here, feel free to make a PR against this branch.

What changes I did:

  • 💄 cleanup, making sure indentation is correct.
  • Moved converters to their own namespace and changed the interface logic a bit. There is now no ItemType but rather an interface which covers "type" properties.
  • Adapt search endpoint to support new episodes & shows
  • GetPlaylist also needed additional_types.
  • Removed obsolete methods ( I hijacked this feature branch for that, sorry 🙇 )

What do you think?

shayo and others added 6 commits April 12, 2020 21:14
Mostly small changes except for one major (Item in PlaybackContext).
Since Item can be either FullTrack or FullEpisode, I had to use an interface that decodes this on the fly.
@shayo
Copy link
Copy Markdown
Contributor

shayo commented Apr 14, 2020

Thanks for the cleanup. Sorry about indentation issues. My VS went nuts with your code.
The only comment I have is about ITyped. I would prefer to keep the type inside the Enum rather than open ended string. Any reason for not using the Enum?

@JohnnyCrazy
Copy link
Copy Markdown
Owner Author

Do you mean public TrackType ItemType ?

I removed it because it doesn't offer any more information that is not already present in the class instance.

You can already do the following:

if(track instanceof FullTrack) {

} else  if (track instanceof FullEpisode) {

}

Do you have any specific advantages of having it?

@shayo
Copy link
Copy Markdown
Contributor

shayo commented Apr 16, 2020

No. You're probably right. I'm a bit rusty on C#. Looks like "instanceof" is a good solution and you don't need to query the itemtype.

@JohnnyCrazy
Copy link
Copy Markdown
Owner Author

I'm wondering how we can make it easier for the user to get the correct types. Right now, the user has to know that it returns either FullTrack or FullEpisode. I don't like that. I'm maybe thinking about helper methods like IsTrack and AsTrack, but I wonder if there are better methods.

@JohnnyCrazy
Copy link
Copy Markdown
Owner Author

I'm not sure what got into me earlier, but instanceof is not a c# thing. It's Java. I thought I've tested it...

The only thing we have available is as and is, so users could use the following:

if (item.Track is FullTrack)
{
  var track = item.Track as FullTrack;
}
if (item.Track is FullEpisode)
{
  var episode = item.Track as FullEpisode;
}

@shayo
Copy link
Copy Markdown
Contributor

shayo commented May 3, 2020 via email

@JohnnyCrazy
Copy link
Copy Markdown
Owner Author

I will merge this into the current master if people want to build it on their own. However, since this is a breaking change because of the track or episode object mapping, there will be no release in 5.X

For 6.X, it's already implemented based on your work and following the same pattern (e.g https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/4c38f958a09c162eef5f9e6c3a2d1f79a91b20a9/SpotifyAPI.Web/Models/Response/Interfaces/IPlaylistElement.cs). Huge thanks to you for the work 👍

@JohnnyCrazy JohnnyCrazy merged commit 3695866 into master May 30, 2020
@JohnnyCrazy JohnnyCrazy deleted the feature/shows-and-episodes branch May 30, 2020 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants