Skip to content

Commit

Permalink
feat: update new air api
Browse files Browse the repository at this point in the history
  • Loading branch information
RTAkland committed Sep 10, 2024
1 parent aaf0d13 commit eb6ce24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/cn/rtast/qwsdk/api/Air.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ object Air {
return this.daily(location(), lang)
}

fun beta(): AirBeta = AirBeta
fun new(): AirNew = AirNew
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,20 @@ import cn.rtast.qwsdk.QWeatherSDK
import cn.rtast.qwsdk.entity.air.BetaAirNowEntity
import cn.rtast.qwsdk.entity.air.BetaAirStationEntity
import cn.rtast.qwsdk.enums.Lang
import cn.rtast.qwsdk.utils.Coordinate
import cn.rtast.qwsdk.utils.Http
import cn.rtast.qwsdk.utils.buildRequestURL

object AirBeta {
object AirNew {

@JvmOverloads
fun now(
location: String,
location: Coordinate,
lang: Lang = Lang.ZH,
pollutant: Boolean = false,
station: Boolean = false,
): BetaAirNowEntity {
val url = buildRequestURL(
"airquality/v1/now/$location",
mapOf(
"lang" to lang,
"pollutant" to pollutant,
"station" to station
)
"airquality/v1/current/${location.latitude}/${location.longitude}",
mapOf("lang" to lang)
)

val result = Http.get(url)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/cn/rtast/qwsdk/utils/Coordinate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package cn.rtast.qwsdk.utils

data class Coordinate(
private val longitude: Double,
private val latitude: Double,
val longitude: Double,
val latitude: Double,
) {
// overload operator to impl Class name as method
operator fun invoke(): String {
Expand Down

0 comments on commit eb6ce24

Please sign in to comment.