Skip to content

Add support for Heights API#10

Merged
0mega merged 19 commits intomainfrom
001-support-heights-api
Jan 15, 2026
Merged

Add support for Heights API#10
0mega merged 19 commits intomainfrom
001-support-heights-api

Conversation

@0mega
Copy link
Owner

@0mega 0mega commented Jan 15, 2026

This pull request introduces support for fetching tide height predictions and flexible combined tide data in the WorldTides library. It adds new API methods, refactors the callback interface to be generic, and introduces new data models and enums. The changes include breaking API changes, updated documentation, and new architectural patterns to enable future extensibility.

API Changes and Breaking Changes

  • Refactored the callback interface to a generic TidesCallback<T>, requiring migration for existing Java consumers. The Height.date property is now non-nullable for consistency. [1] [2] [3] [4]

New Features and Methods

  • Added getTideHeights() and getTides() methods to WorldTides, allowing retrieval of tide heights and flexible combinations of tide data types (e.g., heights and extremes) via both Kotlin and Java-friendly interfaces. Introduced the TideDataType enum for specifying data types. [1] [2] [3] [4]

Data Model and Architecture

  • Defined new data models: TideHeights, Height, and Tides for flexible responses, along with corresponding DTOs for parsing API responses. Updated the internal architecture to move repositories and gateways to package root and introduced new package structure for feature-specific and shared models. [1] [2] [3]

Documentation and Developer Experience

  • Updated the README, changelog, and added quickstart guides and migration instructions for both Kotlin and Java users. Provided comprehensive usage examples and migration notes for breaking changes. [1] [2] [3]

Specification and Planning

  • Added detailed specification, planning, research, and quality checklists to ensure completeness, clarity, and testability of the new feature. [1] [2] [3]

These changes collectively modernize the WorldTides library, improve flexibility for future data types, and ensure a smooth developer experience across both Kotlin and Java.

0mega added 19 commits January 9, 2026 23:20
- Define user stories (Heights P1, Flexible Tides P2, Generic Callback P1)
- Add functional requirements FR-001 to FR-010
- Add acceptance scenarios and edge cases
- Include requirements quality checklist
- Document API endpoint decisions (v2?heights)
- Define package structure (Repository/Gateway at root)
- Plan for getTideHeights and getTides methods
- Note breaking change for TidesCallback<T> refactoring
- Define TideHeights, Height, Tides, TideDataType entities
- Add TidesResponse and HeightResponse DTOs
- Define generic TidesCallback<T> interface
- Add WorldTides.getTideHeights and getTides method signatures
- Add Kotlin and Java usage examples for getTideHeights and getTides
- Define 31 implementation tasks across 5 phases
- Organize tasks by user story for independent delivery
- Include parallel execution opportunities and MVP strategy
BREAKING CHANGE: TidesCallback is now TidesCallback<T>. Existing consumers
using the Java-style callback must update their code to specify the type.

- TidesCallback now accepts type parameter for result type
- Updated getTideExtremes to use TidesCallback<TideExtremes>
- Move WorldTidesRepository.kt from extremes/ to package root
- Move WorldTidesGateway.kt from extremes/ to package root
- Update imports in RetrofitClient.kt
- Repository and Gateway are now shared infrastructure
- Add Height model (date, height)
- Add TideHeights wrapper class
- Add HeightResponse and TideHeightsResponse DTOs
- Add heights endpoint to WorldTidesGateway
- Add heights method to WorldTidesRepository
- Add getTideHeights methods to WorldTides (Kotlin + Java)
- Add TideDataType enum (HEIGHTS, EXTREMES)
- Add Tides model with optional heights and extremes
- Add TidesResponse DTO for combined API responses
- Add dynamic tides endpoint to WorldTidesGateway
- Add tides method to WorldTidesRepository
- Add getTides methods to WorldTides (Kotlin + Java)
- Add getTideHeights (Kotlin lambda + Java callback)
- Add getTides with flexible TideDataType list parameter
- Both methods support Kotlin Result pattern and Java callback
- Mark Heights as supported in API table
- Add getTideHeights usage examples (Kotlin + Java)
- Add getTides usage examples for flexible data requests
- Update existing examples to reflect generic TidesCallback<T>
- Add WorldTidesGatewayHeightsTest (10 tests)
- Add WorldTidesRepositoryHeightsTest (4 tests)
- Add WorldTidesGatewayTidesTest (9 tests)
- Add WorldTidesRepositoryTidesTest (7 tests)
- Add TideDataTypeTest (4 tests)
- Add HeightTest (5 tests)
- Add TideHeightsTest (4 tests)
- Add TidesTest (6 tests)
- Update WorldTidesTest with getTideHeights/getTides tests (6 new tests)
- Fix existing tests for generic TidesCallback<T> and package moves

Total: 69 tests (55 new, 14 existing)
- Add Heights API, Tides API to CHANGELOG
- Document breaking change for TidesCallback<T>
- Add new models and test coverage to CHANGELOG
- Mark all Phase 5 tasks complete
BREAKING CHANGE: Height.date is now Date instead of Date?
Removes null-date test case as it's no longer valid.
Adds toExtreme(), toTideExtremes(), toHeight(), toTideHeights() extensions.
Includes unit tests for all mapping functions.
Refactors WorldTidesRepository to use new extensions.
Centralizes Retrofit callback handling into a single generic extension.
Reduces ~45 lines of duplicated code across repository methods.
No functional change - all existing tests pass.
- Delete WorldTidesJavaApiTest.kt (duplicate of WorldTidesTest)
- Remove query param tests from heights/tides gateways (kept in extremes)
- Remove trivial enum count tests from TideDataTypeTest
- Remove trivial edge cases from HeightTest and TideHeightsTest

Test count reduced from 76 to 59 while maintaining coverage.
@0mega 0mega merged commit ecd01ef into main Jan 15, 2026
1 check passed
@0mega 0mega deleted the 001-support-heights-api branch January 15, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant