tech(APIBretagneService.clean): l'API de data.bretagne renvoie un vide quand il n'y a pas de resultat, change l'implem pour ce cas
This commit is contained in:
parent
3495147045
commit
ffdd7ee95d
1 changed files with 3 additions and 2 deletions
|
@ -34,6 +34,7 @@ class APIBretagneService
|
||||||
|
|
||||||
def fetch_page(url:, params:, retry_count: 1)
|
def fetch_page(url:, params:, retry_count: 1)
|
||||||
result = call(url:, params:)
|
result = call(url:, params:)
|
||||||
|
|
||||||
case result
|
case result
|
||||||
in Failure(code:, reason:) if code.in?(401..403)
|
in Failure(code:, reason:) if code.in?(401..403)
|
||||||
if retry_count > 0
|
if retry_count > 0
|
||||||
|
@ -42,10 +43,10 @@ class APIBretagneService
|
||||||
else
|
else
|
||||||
fail "APIBretagneService, #{reason} #{code}"
|
fail "APIBretagneService, #{reason} #{code}"
|
||||||
end
|
end
|
||||||
in Failure(code:) if code == 204
|
|
||||||
[]
|
|
||||||
in Success(body:)
|
in Success(body:)
|
||||||
body
|
body
|
||||||
|
else # no response gives back a 204, so we don't try to JSON.parse(nil) to avoid error
|
||||||
|
{ items: [] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue