package io.delphiplatform.api.v3.model.spotify;

import com.fasterxml.jackson.annotation.JsonProperty;

import io.delphiplatform.api.v3.rdb.entity.spotify.SpotifyStreamsNewListenersTrackBaseInfoProjection;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;

@Builder
@Getter
@EqualsAndHashCode
public class SpotifyTrackShortInfo {
    @JsonProperty("spotify_track_id")
    private String spotifyTrackId;

    @JsonProperty("track_name")
    private String trackName;

    @JsonProperty("isrc")
    private String isrc;

    public static SpotifyTrackShortInfo from(SpotifyStreamsNewListenersTrackBaseInfoProjection baseTrackInfo) {
        if (baseTrackInfo == null) {
            return null;
        }

        return SpotifyTrackShortInfo.builder()
            .spotifyTrackId(baseTrackInfo.getTrackId())
            .trackName(baseTrackInfo.getTrackName())
            .isrc(baseTrackInfo.getTrackIsrc())
            .build();
    }
}
