Method: UnifiProtect::API#request_with_json_response
- Defined in:
- lib/unifi_protect/api.rb
#request_with_json_response(uri, method: :get, body: nil, exception_class: RequestError) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/unifi_protect/api.rb', line 107 def request_with_json_response(uri, method: :get, body: nil, exception_class: RequestError) response = http_client.request(http_request_with_bearer_token(uri, method: method, body: body)) raise exception_class, "#{response.code} #{response.msg}: #{response.body}" unless response.code == '200' JSON.parse(response.body, object_class: OpenStruct) end |