Class: Ovh::Http2sms::ResponseParser Private
- Inherits:
-
Object
- Object
- Ovh::Http2sms::ResponseParser
- Defined in:
- lib/ovh/http2sms/response.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal parser for different response formats
Instance Method Summary collapse
-
#initialize(body, content_type) ⇒ ResponseParser
constructor
private
A new instance of ResponseParser.
- #parse ⇒ Object private
Constructor Details
#initialize(body, content_type) ⇒ ResponseParser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ResponseParser.
102 103 104 105 |
# File 'lib/ovh/http2sms/response.rb', line 102 def initialize(body, content_type) @body = body.to_s @content_type = content_type.to_s.downcase end |
Instance Method Details
#parse ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ovh/http2sms/response.rb', line 107 def parse case @content_type when /json/ parse_json when /xml/ parse_xml when /html/ parse_html else parse_plain end rescue StandardError => e # If parsing fails, raise a specific error raise ResponseParseError.new( "Failed to parse API response: #{e.message}", content_type: @content_type, raw_response: @body ) end |