From c5a9a5d1677e45b8ed3680cc20997625e38542e5 Mon Sep 17 00:00:00 2001 From: "Brian M. Long" Date: Thu, 26 Jun 2025 15:00:18 -0400 Subject: [PATCH] added ScoringApi --- .../com/poststats/golf/rs/api/ScoringApi.java | 66 ++++++++++ .../golf/rs/api/model/ScoringSystem.java | 116 ++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100755 src/main/java/com/poststats/golf/rs/api/ScoringApi.java create mode 100755 src/main/java/com/poststats/golf/rs/api/model/ScoringSystem.java diff --git a/src/main/java/com/poststats/golf/rs/api/ScoringApi.java b/src/main/java/com/poststats/golf/rs/api/ScoringApi.java new file mode 100755 index 0000000..8cd4732 --- /dev/null +++ b/src/main/java/com/poststats/golf/rs/api/ScoringApi.java @@ -0,0 +1,66 @@ +package com.poststats.golf.rs.api; + +import java.util.List; + +import com.poststats.golf.rs.api.model.ScoringSystem; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.constraints.Positive; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; + +/** + * @author brian.long@poststats.com + */ +@Path("/golf/scoring") +@Tag(name = "Scoring API") +public abstract class ScoringApi { + + @GET + @Path("systems") + @Produces(Constants.V1_JSON) + @Operation(summary = "Retrieves meta-data about all scoring systems.") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Success", useReturnTypeSchema = true) + }) + public abstract List getSystems(@QueryParam("stableford") Boolean stableford); + + @GET + @Path("/system/{id}") + @Produces(Constants.V1_JSON) + @Operation( + summary = "Retrieves meta-data about a scoring system.", + description = "Retreives name and other direct meta-data about the specified scoring system." + ) + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Success", useReturnTypeSchema = true), + @ApiResponse( + responseCode = "404", + description = "A scoring system with the specified ID could not be found" + ) + }) + public abstract ScoringSystem getSystemById(@PathParam("id") @Positive short id); + + @GET + @Path("/system/bySid/{sid}") + @Produces(Constants.V1_JSON) + @Operation( + summary = "Retrieves meta-data about a scoring system.", + description = "Retreives name and other direct meta-data about the specified scoring system." + ) + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Success", useReturnTypeSchema = true), + @ApiResponse( + responseCode = "404", + description = "A scoring system with the specified SID could not be found" + ) + }) + public abstract ScoringSystem getSystemBySid(@PathParam("sid") String sid); + +} diff --git a/src/main/java/com/poststats/golf/rs/api/model/ScoringSystem.java b/src/main/java/com/poststats/golf/rs/api/model/ScoringSystem.java new file mode 100755 index 0000000..ae1adf1 --- /dev/null +++ b/src/main/java/com/poststats/golf/rs/api/model/ScoringSystem.java @@ -0,0 +1,116 @@ +package com.poststats.golf.rs.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.poststats.rs.api.annotation.MapEntry; +import com.poststats.rs.api.model.BaseModel; + +/** + * @author brian.long@poststats.com + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ScoringSystem extends BaseModel { + + @JsonProperty(required = true) + @MapEntry("scoringSystemID") + private short id; + + @JsonProperty(required = true) + @MapEntry("scoringSystemSID") + private String sid; + + @JsonProperty(required = true) + @MapEntry("scoringSystem") + private String name; + + @JsonProperty(required = true) + @MapEntry + private String display; + + @JsonProperty(required = true) + @MapEntry + private boolean stableford; + + @JsonProperty + @MapEntry + private Short baseTarget; + + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + public ScoringSystem withId(short id) { + this.id = id; + return this.withThis(); + } + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public ScoringSystem withSid(String sid) { + this.sid = sid; + return this.withThis(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ScoringSystem withName(String name) { + this.name = name; + return this.withThis(); + } + + public String getDisplay() { + return display; + } + + public void setDisplay(String display) { + this.display = display; + } + + public ScoringSystem withDisplay(String display) { + this.display = display; + return this.withThis(); + } + + public boolean isStableford() { + return stableford; + } + + public void setStableford(boolean stableford) { + this.stableford = stableford; + } + + public ScoringSystem withStableford(boolean stableford) { + this.stableford = stableford; + return this.withThis(); + } + + public Short getBaseTarget() { + return baseTarget; + } + + public void setBaseTarget(Short baseTarget) { + this.baseTarget = baseTarget; + } + + public ScoringSystem withBaseTarget(Short baseTarget) { + this.baseTarget = baseTarget; + return this.withThis(); + } + +}