lib/bunny_app/client.rb in bunny_app-1.30.0 vs lib/bunny_app/client.rb in bunny_app-2.0.0

- old
+ new

@@ -17,10 +17,12 @@ @headers = { 'User-Agent' => USER_AGENT, 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{BunnyApp.access_token}" } + + @headers['host'] = host_header unless host_header.nil? end def fetch_access_token body = URI.encode_www_form({ grant_type: 'client_credentials', @@ -57,11 +59,11 @@ res = self.class.post('/graphql', headers: @headers, body:) case res.code.to_s when /2[0-9][0-9]/ # HTTP 2xx response_body = JSON.parse(res.body) - raise ResponseError, response_body['errors'] if response_body['errors'] + raise ResponseError, (response_body['errors'].map { |error| error['message'] }) if response_body['errors'] response_body when /401/ # Access Token Expired raise AuthorizationError, 'Invalid access token' unless BunnyApp.retryable @@ -86,8 +88,12 @@ end end def verify_ssl return true unless ENV['IGNORE_SSL'] + end + + def host_header + ENV.fetch('BUNNY_HOST_HEADER', nil) end end end