Skip to content

Commit

Permalink
feat(gbif): download
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisot committed Nov 7, 2024
1 parent f3bc1ee commit 889ad78
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions GBIF/src/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ end
Prepares a request for a download through the GBIF API
"""
function download(query::Pair...)
function download(query::Pair...; notification::Bool=false)
# Get the predicates
pred = GBIF.predicate(query...)
predicates = GBIF._predicate(query...)
if notification
predicates["sendNotification"] = true
push!(predicates["notificationAddresses"], GBIF.email())
end
#
return nothing
end
Expand All @@ -58,7 +62,7 @@ function _predicate(query::Pair...)
query = (query..., "format" => "simpleCsv")
querystring = pairs_to_querystring(query...)
predicate_url = GBIF.gbifurl * "occurrence/download/request/predicate"
pre_s_req = HTTP.get(predicate_url; query = querystring)
pre_s_req = HTTP.get(predicate_url; query = querystring, headers = GBIF.apiauth())
if pre_s_req.status == 200
return JSON.parse(String(pre_s_req.body))
end
Expand Down

0 comments on commit 889ad78

Please sign in to comment.