Skip to content

Commit

Permalink
feat: elevation query param
Browse files Browse the repository at this point in the history
Elevation is not nullable in the `Response.Elevation` interface.
  • Loading branch information
DadiBit committed Jun 4, 2023
1 parent 234a065 commit d82fbbd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/src/main/kotlin/com/openmeteo/api/Forecast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ object Forecast {
override val windSpeedUnit: WindSpeedUnit? = null,
@SerialName("precipitation_unit")
override val precipitationUnit: PrecipitationUnit? = null,
) : Q.Coordinate, Q.Daily, Q.Hourly, Q.TimeFormat, Q.DateRange,
override val elevation: Float? = null,
) : Q.Coordinate, Q.Elevation, Q.Daily, Q.Hourly, Q.TimeFormat, Q.DateRange,
Q.PastDays, Q.ForecastDays, Q.CurrentWeather, Q.Timezone,
Q.TemperatureUnit, Q.WindSpeedUnit, Q.PrecipitationUnit

Expand All @@ -59,8 +60,8 @@ object Forecast {
override val hourlyUnits: Map<String, Unit> = mapOf(),
@SerialName("hourly")
override val hourlyValues: Map<String, Array<Double?>> = mapOf(),
override val currentWeather: com.openmeteo.api.common.Response.CurrentWeather.CurrentWeather? = null,
) : R.Coordinate, R.GenerationTimed, R.TimeZone, R.Elevation, R.Daily, R.Hourly, R.CurrentWeather
override val currentWeather: R.CurrentWeather.CurrentWeather? = null,
) : R.Coordinate, R.Elevation, R.GenerationTimed, R.TimeZone, R.Daily, R.Hourly, R.CurrentWeather

@Serializable
object Daily : Options.Daily {
Expand Down
8 changes: 8 additions & 0 deletions lib/src/main/kotlin/com/openmeteo/api/common/Elevation.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.openmeteo.api.common

/**
* The elevation in meters.
*/
interface Elevation {
val elevation: Float?
}
8 changes: 6 additions & 2 deletions lib/src/main/kotlin/com/openmeteo/api/common/Response.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ interface Response {
)
}

interface Elevation {
val elevation: Float
/**
* Elevation-based resource.
*/
interface Elevation : com.openmeteo.api.common.Elevation {
override val elevation: Float // not nullable, since it's always returned!
}

}
5 changes: 5 additions & 0 deletions lib/src/main/kotlin/com/openmeteo/api/common/query/Query.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ interface Query {
*/
interface Coordinate : com.openmeteo.api.common.Coordinate, Query

/**
* Query for elevation-based resources. Defaults to a 90 meters model.
*/
interface Elevation : com.openmeteo.api.common.Elevation

/**
* Query for resources that may include the current weather in the response.
*/
Expand Down

0 comments on commit d82fbbd

Please sign in to comment.