class MSS::Core::JSONClient

Protected Class Methods

request_builder_for(api_config, operation) click to toggle source
# File lib/mss/core/json_client.rb, line 19
def self.request_builder_for api_config, operation
  JSONRequestBuilder.new(api_config, operation)
end
response_parser_for(api_config, operation) click to toggle source
# File lib/mss/core/json_client.rb, line 23
def self.response_parser_for api_config, operation
  JSONResponseParser.new(operation[:outputs])
end

Protected Instance Methods

extract_error_details(response) click to toggle source
# File lib/mss/core/json_client.rb, line 27
def extract_error_details response
  if
    response.http_response.status >= 300 and
    body = response.http_response.body and
    json = (::JSON.load(body) rescue nil) and
    type = json["__type"]
  then
    code = type.split('#').last
    if code == 'RequestEntityTooLarge'
      message = 'Request body must be less than 1 MB'
    else
      message = json['message'] || json['Message']
    end
    [code, message]
  end
end