Skip to content

Commit

Permalink
created Genre
Browse files Browse the repository at this point in the history
  • Loading branch information
yvasyliev committed Dec 29, 2023
1 parent 2971c75 commit 21c8cdf
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/main/java/io/github/yvasyliev/deezer/DeezerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.yvasyliev.deezer.methods.GetMethod;
import io.github.yvasyliev.deezer.methods.PagingMethod;
import io.github.yvasyliev.deezer.objects.Artist;
import io.github.yvasyliev.deezer.objects.Genre;
import io.github.yvasyliev.deezer.objects.Page;
import io.github.yvasyliev.deezer.objects.Track;
import lombok.AllArgsConstructor;
Expand All @@ -16,7 +17,8 @@
@Builder
public class DeezerClient {
private static final String GET_ARTIST_TEMPLATE = "/artist/%d";
private static final String GET_ARTIST_TOP = GET_ARTIST_TEMPLATE + "/top";
private static final String GET_ARTIST_TOP_TEMPLATE = GET_ARTIST_TEMPLATE + "/top";
private static final String GET_GENRE_TEMPLATE = "/genre/%d";

@NonNull
private DeezerContext context;
Expand All @@ -31,7 +33,12 @@ public GetMethod<Artist> getArtist(int artistId) {
}

public PagingMethod<Track> getArtistTop(int artistId) {
return new PagingMethod<>(context, String.format(GET_ARTIST_TOP, artistId), new TypeReference<Page<Track>>() {
return new PagingMethod<>(context, String.format(GET_ARTIST_TOP_TEMPLATE, artistId), new TypeReference<Page<Track>>() {
});
}

public GetMethod<Genre> getGenre(long genreId) {
return new GetMethod<>(context, String.format(GET_GENRE_TEMPLATE, genreId), new TypeReference<Genre>() {
});
}
}
63 changes: 63 additions & 0 deletions src/main/java/io/github/yvasyliev/deezer/objects/Genre.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.github.yvasyliev.deezer.objects;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.net.URL;

/**
* A genre object.
*/
@Data
@JsonIgnoreProperties(value = "type", allowGetters = true, ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Genre {
/**
* The editorial's Deezer id.
*/
@JsonProperty("id")
private Long id;

/**
* The editorial's name.
*/
@JsonProperty("name")
private String name;

/**
* The url of the genre picture. Add 'size' parameter to the url to change size. Can be 'small', 'medium', 'big', 'xl'.
*/
@JsonProperty("picture")
private Picture picture;

/**
* The url of the genre picture in size small.
*/
@JsonProperty("picture_small")
private URL pictureSmall;

/**
* The url of the genre picture in size medium.
*/
@JsonProperty("picture_medium")
private URL pictureMedium;

/**
* The url of the genre picture in size big.
*/
@JsonProperty("picture_big")
private URL pictureBig;

/**
* The url of the genre picture in size xl.
*/
@JsonProperty("picture_xl")
private URL pictureXl;

@JsonProperty("type")
public ObjectType getType() {
return ObjectType.GENRE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

public enum ObjectType {
@JsonProperty("artist") ARTIST,
@JsonProperty("track") TRACK
@JsonProperty("track") TRACK,
@JsonProperty("genre") GENRE
}

0 comments on commit 21c8cdf

Please sign in to comment.