Skip to content

Commit

Permalink
feat: update Page and Post models
Browse files Browse the repository at this point in the history
  • Loading branch information
martinalbert committed Oct 24, 2024
1 parent 6090906 commit 82e9416
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
30 changes: 30 additions & 0 deletions src/main/java/com/buttercms/model/Page.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.buttercms.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Date;
import java.util.Objects;
import java.util.StringJoiner;

Expand All @@ -10,6 +12,8 @@ public class Page<T> {
private String slug;
private String pageType;
private T fields;
private Status status;
private Date scheduled;

public String getSlug() {
return slug;
Expand All @@ -35,6 +39,22 @@ public void setFields(T fields) {
this.fields = fields;
}

public Status getStatus() {
return status;
}

public void setStatus(Status status) {
this.status = status;
}

public Date getScheduled() {
return scheduled;
}

public void setScheduled(Date scheduled) {
this.scheduled = scheduled;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -56,4 +76,14 @@ public String toString() {
.add("fields=" + fields)
.toString();
}

public enum Status {
@JsonProperty("draft")
DRAFT,
@JsonProperty("published")
PUBLISHED,
@JsonProperty("scheduled")
SCHEDULED
}
}

18 changes: 16 additions & 2 deletions src/main/java/com/buttercms/model/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Post {
private Date created;
private String metaDescription;
private Date published;
private Date scheduled;
private String seoTitle;
private String slug;
private Status status;
Expand Down Expand Up @@ -74,6 +75,14 @@ public void setPublished(Date published) {
this.published = published;
}

public Date getScheduled() {
return scheduled;
}

public void setScheduled(Date scheduled) {
this.scheduled = scheduled;
}

public String getSeoTitle() {
return seoTitle;
}
Expand Down Expand Up @@ -151,6 +160,7 @@ public boolean equals(Object o) {
Objects.equals(created, post.created) &&
Objects.equals(metaDescription, post.metaDescription) &&
Objects.equals(published, post.published) &&
Objects.equals(scheduled, post.scheduled) &&
Objects.equals(seoTitle, post.seoTitle) &&
Objects.equals(slug, post.slug) &&
status == post.status &&
Expand All @@ -164,7 +174,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(author, body, categories, created, metaDescription, published, seoTitle, slug, status, summary, tags, title, url, featuredImage, featuredImageAlt);
return Objects.hash(author, body, categories, created, metaDescription, published, scheduled, seoTitle, slug, status, summary, tags, title, url, featuredImage, featuredImageAlt);
}

@Override
Expand All @@ -188,6 +198,10 @@ public enum Status {
DRAFT,

@JsonProperty("published")
PUBLISHED
PUBLISHED,

@JsonProperty("scheduled")
SCHEDULED
}
}

0 comments on commit 82e9416

Please sign in to comment.