Skip to content

Commit

Permalink
struct Status
Browse files Browse the repository at this point in the history
  • Loading branch information
kaat0 committed Nov 21, 2024
1 parent 9ad9a1b commit f18d3cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Receive current Status of Overpass API endpoint.
Overpass.status()
```

The returned EndpointStatus struct provides the following fields:
The returned Status struct provides the following fields:
- `connection_id::String`
- `server_time::DateTime`
- `endpoint::Union{Nothing, String}`
Expand Down
10 changes: 5 additions & 5 deletions src/Overpass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export query, set_endpoint, status, turbo_url
# TYPES
Bbox = Union{Nothing, NTuple{4, Number}}
Center = Union{Nothing, NTuple{2, Number}}
struct EndpointStatus
struct Status
connection_id::String
server_time::DateTime
endpoint::Union{Nothing, String}
Expand Down Expand Up @@ -89,11 +89,11 @@ function set_endpoint(endpoint::Union{Nothing, String} = nothing)::Bool
end

"""
status()::EndpointStatus
status()::Status
Receive current Status of Overpass API.
EndpointStatus provides the following fields:
Status provides the following fields:
- connection_id::String
- server_time::DateTime
- endpoint::Union{Nothing, String}
Expand All @@ -102,7 +102,7 @@ EndpointStatus provides the following fields:
See also [`set_endpoint`](@ref) to change Overpass API endpoint.
"""
function status()::EndpointStatus
function status()::Status
url = @load_preference("endpoint", DEFAULT_ENDPOINT) * "status"

response = HTTP.get(url)
Expand All @@ -119,7 +119,7 @@ function status()::EndpointStatus

@debug "Status regex matches" matches

status = EndpointStatus(
status = Status(
matches[:connection_id],
DateTime(matches[:server_time], "yyyy-mm-ddTHH:MM:SSZ"),
matches[:endpoint],
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ configure!(;
@testset "default endpoint" begin
status = playback(() -> Overpass.status(), "op-status")

@test status isa Overpass.EndpointStatus
@test status isa Overpass.Status
@test status.connection_id == "3158479246"
@test status.server_time == DateTime("2024-11-11T23:37:10")
@test status.endpoint == "lambert.openstreetmap.de/"
Expand All @@ -66,7 +66,7 @@ configure!(;
Overpass.set_endpoint("https://maps.mail.ru/osm/tools/overpass/api/")
status = playback(() -> Overpass.status(), "op-status-ru")

@test status isa Overpass.EndpointStatus
@test status isa Overpass.Status
@test status.connection_id == "1293416468"
@test status.server_time == DateTime("2024-11-11T23:56:34")
@test isnothing(status.endpoint)
Expand All @@ -80,7 +80,7 @@ configure!(;
Overpass.set_endpoint("https://overpass.private.coffee/api/")
status = playback(() -> Overpass.status(), "op-status-coffee")

@test status isa Overpass.EndpointStatus
@test status isa Overpass.Status
@test status.connection_id == "177472788"
@test status.server_time == DateTime("2024-11-12T00:03:37")
@test status.endpoint == "none"
Expand All @@ -94,7 +94,7 @@ configure!(;
Overpass.set_endpoint("https://overpass.osm.jp/api/")
status = playback(() -> Overpass.status(), "op-status-jp")

@test status isa Overpass.EndpointStatus
@test status isa Overpass.Status
@test status.connection_id == "1293416468"
@test status.server_time == DateTime("2024-11-12T00:04:21")
@test status.endpoint == "none"
Expand Down

0 comments on commit f18d3cb

Please sign in to comment.