diff --git a/VERSION b/VERSION index b0f2dcb..eca690e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.4 +3.0.5 diff --git a/lib/telnyx/telnyx_response.rb b/lib/telnyx/telnyx_response.rb index 0dff546..8d67c5f 100644 --- a/lib/telnyx/telnyx_response.rb +++ b/lib/telnyx/telnyx_response.rb @@ -64,7 +64,17 @@ class << self # Helper to handle when the server responds with a blank body (as is the case with SimCards). def preprocess_response(resp) - resp.empty? ? "{}" : resp + return "{}" if resp.empty? + + return resp if valid_json?(resp) + + # If the response is a plain string (as is with JWTs), wrap it in a JSON object + { token: resp }.to_json + end + + # Helper method to check if the string is a valid JSON format + def valid_json?(resp) + resp.strip.start_with?("{", "[") end end end diff --git a/lib/telnyx/version.rb b/lib/telnyx/version.rb index 9c83c59..b3acf8a 100644 --- a/lib/telnyx/version.rb +++ b/lib/telnyx/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Telnyx - VERSION = "3.0.4".freeze + VERSION = "3.0.5".freeze end