Skip to content

Commit

Permalink
fix(delta/api): handle empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Mar 11, 2024
1 parent 3472663 commit e554932
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions drivers/delta/api.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Delta::API < PlaceOS::Driver
raise "unexpected response #{response.status_code}\n#{response.body}" unless response.success?
logger.debug { "response body:\n#{response.body}" }

# returns this when there are no more results
# {"Collection":""}

body = Models::ListDevicesBySiteNameResponse.from_json(response.body)
body.json_unmapped.keys.each do |key|
value = body.json_unmapped[key].as_h
Expand Down
6 changes: 5 additions & 1 deletion drivers/delta/models/list_devices_by_site_name_response.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ module Delta
include JSON::Serializable::Unmapped

@[JSON::Field(key: "$base")]
property base : String
property base : String? = nil

# returns this when there are no more results
@[JSON::Field(key: "Collection")]
property collection : String? = nil
end
end
end

0 comments on commit e554932

Please sign in to comment.