package tv.pluto.mongo.entities.campaigns;

import com.google.gson.annotations.JsonAdapter;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.BsonType;
import org.bson.codecs.pojo.annotations.BsonRepresentation;
import tv.pluto.mongo.utils.json.LocalDateTimeAdapter;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Campaigns {
  @BsonRepresentation(BsonType.OBJECT_ID)
  private String id;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime createdAt;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime updatedAt;

  private String slug = "";
  private Boolean published;
  private String name = "";
  private String displayName = "";
  private String description = "";
  private String author;
  private String activeRegion;
  private List<String> distribution = Collections.emptyList();
  private List<String> regionFilter = Collections.emptyList();

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime start;

  @JsonAdapter(LocalDateTimeAdapter.class)
  private LocalDateTime end;

  private Boolean plutoOfficeOnly;

  public Boolean getPublished() {
    return published != null && published;
  }

  public Boolean getPlutoOfficeOnly() {
    return plutoOfficeOnly != null && plutoOfficeOnly;
  }

  public String getAuthor() {
    return author == null ? "" : author;
  }

  public String getDisplayName() {
    return displayName == null ? "" : displayName;
  }

  public String getName() {
    return name == null ? "" : name;
  }

  public String getDescription() {
    return description == null ? "" : description;
  }

  public String getSlug() {
    return slug == null ? "" : slug;
  }

  public String getActiveRegion() {
    return activeRegion == null ? "" : activeRegion;
  }

  public List<String> getDistribution() {
    return distribution == null ? Collections.emptyList() : distribution;
  }
}
