From 2286759b5f66eb7943dd6716b760fc38aa0ae5b6 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 16 Oct 2023 13:36:06 +0200 Subject: [PATCH] fix(api_client): fix some edge cases --- app/lib/api/client.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/lib/api/client.rb b/app/lib/api/client.rb index 31507f72f..dcf8eab2d 100644 --- a/app/lib/api/client.rb +++ b/app/lib/api/client.rb @@ -7,7 +7,7 @@ class API::Client response = case method when :get Typhoeus.get(url, - headers: headers_with_authorization(headers, authorization_token), + headers: headers_with_authorization(headers, false, authorization_token), params:, timeout: TIMEOUT) when :post @@ -40,8 +40,8 @@ class API::Client body = parse_body(response.body) case body in Success(body) - if !schema || schema.valid?(body) - Success(OK[body.deep_symbolize_keys, response]) + if !schema || schema.valid?(body.deep_stringify_keys) + Success(OK[body, response]) else Failure(Error[:schema, response.code, false, SchemaError.new(schema.validate(body))]) end @@ -58,7 +58,7 @@ class API::Client end def parse_body(body) - Success(JSON.parse(body)) + Success(JSON.parse(body, symbolize_names: true)) rescue JSON::ParserError => error Failure(error) end