Code review and quality improvements across the codebase
- Validate apiKey in BaseService and add package-private SendGrid
  override constructors so services can be unit-tested with Mockito.
- SendgridApi: make services final, add package-private constructor
  for injection, add Javadoc, add getStatistics(int, Aggregation).
- EmailService: validate non-blank from/to/templateId, handle null
  templateData, replace magic 202 with HttpURLConnection.HTTP_ACCEPTED,
  preserve IOException as cause when wrapping into SendgridException.
- UsageService: tighten exception handling (catch IOException, not
  Exception), validate response status before parsing, configure a
  Jackson ObjectMapper with JavaTimeModule so LocalDate works,
  validate negative days and null Aggregation.
- Add Aggregation enum (DAY/WEEK/MONTH) for the stats endpoint.
- SendgridException: add (String, Throwable) constructor and Javadoc.
- Statistics: migrate date from java.util.Date to java.time.LocalDate.
- pom.xml: declare Jackson annotations and jsr310 explicitly, pin
  maven-compiler-plugin and maven-surefire-plugin, add Mockito for
  tests.
- Tests: add SendgridApiTest, SendgridExceptionTest, AggregationTest,
  BaseServiceTest, EmailServiceTest, UsageServiceTest, MetricsTest,
  StatTest. Update StatisticsTest to assert LocalDate values, use
  try-with-resources, and use a Charset instead of a string encoding.
  Suite grew from 1 to 52 passing tests.
- README: rewrite to document the new API surface, error contract,
  build/test instructions, and project layout.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6824d22 commit ffb5bea65d3b35506eddbcd95f332ca08c1be9a5
@Your Name Your Name authored on 7 May
Showing 20 changed files
View
README.md
View
pom.xml
View
src/main/java/io/ljunggren/sendgrid/api/SendgridApi.java
View
src/main/java/io/ljunggren/sendgrid/api/exception/SendgridException.java
View
src/main/java/io/ljunggren/sendgrid/api/model/Metrics.java
View
src/main/java/io/ljunggren/sendgrid/api/model/Stat.java
View
src/main/java/io/ljunggren/sendgrid/api/model/Statistics.java
View
src/main/java/io/ljunggren/sendgrid/api/service/Aggregation.java 0 → 100755
View
src/main/java/io/ljunggren/sendgrid/api/service/BaseService.java
View
src/main/java/io/ljunggren/sendgrid/api/service/EmailService.java
View
src/main/java/io/ljunggren/sendgrid/api/service/UsageService.java
View
src/test/java/io/ljunggren/sendgrid/api/SendgridApiTest.java 0 → 100755
View
src/test/java/io/ljunggren/sendgrid/api/exception/SendgridExceptionTest.java 0 → 100755
View
src/test/java/io/ljunggren/sendgrid/api/model/MetricsTest.java 0 → 100755
View
src/test/java/io/ljunggren/sendgrid/api/model/StatTest.java 0 → 100755
View
src/test/java/io/ljunggren/sendgrid/api/model/StatisticsTest.java
View
src/test/java/io/ljunggren/sendgrid/api/service/AggregationTest.java 0 → 100755
View
src/test/java/io/ljunggren/sendgrid/api/service/BaseServiceTest.java 0 → 100755
View
src/test/java/io/ljunggren/sendgrid/api/service/EmailServiceTest.java 0 → 100755
View
src/test/java/io/ljunggren/sendgrid/api/service/UsageServiceTest.java 0 → 100755