malgleam/living_index
생활기상지수 조회서비스 (LivingWthrIdxServiceV2). 동파가능지수, 자외선지수, 대기확산지수, 체감온도 4개 엔드포인트를 제공한다.
Types
대기확산지수. 등급: 100(낮음=확산 잘됨), 75(보통), 50(높음), 25(매우높음=확산 안됨). 3시간 간격, 최대 78시간 예측. 연중 서비스.
pub type AirDiffusionIndex {
AirDiffusionIndex(
code: String,
area_no: String,
date: String,
hourly: List(HourlyValue),
)
}
Constructors
-
AirDiffusionIndex( code: String, area_no: String, date: String, hourly: List(HourlyValue), )Arguments
- hourly
-
h3,h6,…h78, 3시간 간격 (값: 25/50/75/100)
동파가능지수. 등급: 25(낮음, -5℃ 이상), 50(보통), 75(높음), 100(매우높음, -15℃ 이하). 서비스 기간: 11월~3월.
pub type FreezeIndex {
FreezeIndex(
code: String,
area_no: String,
date: String,
hourly: List(HourlyValue),
)
}
Constructors
-
FreezeIndex( code: String, area_no: String, date: String, hourly: List(HourlyValue), )Arguments
- hourly
-
h1~h78, 1시간 간격 (값: 25/50/75/100)
시간별 예측값.
pub type HourlyValue {
HourlyValue(hour: Int, value: option.Option(Int))
}
Constructors
-
HourlyValue(hour: Int, value: option.Option(Int))
체감온도(여름철). hourly 값은 체감온도(℃). 서비스 기간: 5/1~9/30. RequestCode로 대상(노인, 어린이, 도로 등) 지정.
pub type SensibleTemperature {
SensibleTemperature(
code: String,
area_no: String,
date: String,
hourly: List(HourlyValue),
)
}
Constructors
-
SensibleTemperature( code: String, area_no: String, date: String, hourly: List(HourlyValue), )Arguments
- hourly
-
h1~h78, 1시간 간격 (값: 체감온도 ℃)
자외선지수. 등급: 0~2(낮음), 3~5(보통), 6~7(높음), 8~10(매우높음), 11+(위험). 06:00 발표: today/tomorrow/dayaftertomorrow. 18:00 발표: tomorrow/dayaftertomorrow/twodaysaftertomorrow.
pub type UvIndex {
UvIndex(
code: String,
area_no: String,
date: String,
today: option.Option(Int),
tomorrow: option.Option(Int),
day_after_tomorrow: option.Option(Int),
two_days_after_tomorrow: option.Option(Int),
)
}
Constructors
-
UvIndex( code: String, area_no: String, date: String, today: option.Option(Int), tomorrow: option.Option(Int), day_after_tomorrow: option.Option(Int), two_days_after_tomorrow: option.Option(Int), )
Values
pub fn air_diffusion_idx(
service_key key: String,
area a: area.AreaCode,
time time: String,
) -> request.Request(String)
대기확산지수조회 요청을 생성한다.
pub fn decode_air_diffusion_idx(
response: response.Response(String),
) -> Result(AirDiffusionIndex, error.ApiError)
대기확산지수 응답을 디코딩한다.
pub fn decode_freeze_idx(
response: response.Response(String),
) -> Result(FreezeIndex, error.ApiError)
동파가능지수 응답을 디코딩한다.
pub fn decode_sen_ta_idx(
response: response.Response(String),
) -> Result(SensibleTemperature, error.ApiError)
체감온도 응답을 디코딩한다.
pub fn decode_uv_idx(
response: response.Response(String),
) -> Result(UvIndex, error.ApiError)
자외선지수 응답을 디코딩한다.
pub fn find_hourly(
hourly: List(HourlyValue),
hour: Int,
) -> option.Option(Int)
HourlyValue 리스트에서 특정 시간의 예측값을 조회한다.
let assert Ok(freeze) = living_index.decode_freeze_idx(response)
case living_index.find_hourly(freeze.hourly, 6) {
Some(value) -> // 6시간 후 동파가능지수
None -> // 해당 시간 데이터 없음
}
pub fn freeze_idx(
service_key key: String,
area a: area.AreaCode,
time time: String,
) -> request.Request(String)
동파가능지수조회 요청을 생성한다.
pub fn sen_ta_idx(
service_key key: String,
area a: area.AreaCode,
time time: String,
request_code code: area.RequestCode,
) -> request.Request(String)
체감온도(여름철)조회 요청을 생성한다. request_code로 대상을 지정한다: Elderly(노인), Children(어린이), Rural(농촌), Greenhouse(비닐하우스), Vulnerable(취약거주), Road(도로), Construction(건설), Shipyard(조선소).
pub fn uv_idx(
service_key key: String,
area a: area.AreaCode,
time time: String,
) -> request.Request(String)
자외선지수조회 요청을 생성한다.
pub fn with_page(
req: request.Request(String),
page: Int,
) -> request.Request(String)
페이지 번호를 설정한다 (기본값: 1).
pub fn with_rows(
req: request.Request(String),
rows: Int,
) -> request.Request(String)
한 페이지 결과 수를 설정한다 (기본값: 10).