Class: PetstoreApiClient::Models::ApiResponse

Inherits:
Base
  • Object
show all
Defined in:
lib/petstore_api_client/models/api_response.rb

Overview

ApiResponse model for structured error responses Not used much since we raise exceptions instead of returning error objects

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_response(data) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/petstore_api_client/models/api_response.rb', line 20

def self.from_response(data)
  return nil if data.nil?

  new(
    code: data["code"] || data[:code],
    type: data["type"] || data[:type],
    message: data["message"] || data[:message]
  )
end

Instance Method Details

#to_hObject



12
13
14
15
16
17
18
# File 'lib/petstore_api_client/models/api_response.rb', line 12

def to_h
  {
    code: code,
    type: type,
    message: message
  }.compact
end