Class: Mindee::Parsing::Common::ApiRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/parsing/common/api_response.rb

Overview

HTTP request response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ ApiRequest

Returns a new instance of ApiRequest.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/mindee/parsing/common/api_response.rb', line 79

def initialize(server_response)
  @error = server_response['error']
  @ressources = server_response['ressources']

  @status = if server_response['status'] == 'failure'
              RequestStatus::FAILURE
            elsif server_response['status'] == 'success'
              RequestStatus::SUCCESS
            else
              server_response['status']&.to_sym
            end
  @status_code = server_response['status_code']
  @url = server_response['url']
end

Instance Attribute Details

#errorHash (readonly)

Returns:

  • (Hash)


69
70
71
# File 'lib/mindee/parsing/common/api_response.rb', line 69

def error
  @error
end

#ressourcesArray<String> (readonly)

Returns:

  • (Array<String>)


71
72
73
# File 'lib/mindee/parsing/common/api_response.rb', line 71

def ressources
  @ressources
end

#statusRequestStatus, Symbol (readonly)

Returns:



73
74
75
# File 'lib/mindee/parsing/common/api_response.rb', line 73

def status
  @status
end

#status_codeInteger (readonly)

Returns:

  • (Integer)


75
76
77
# File 'lib/mindee/parsing/common/api_response.rb', line 75

def status_code
  @status_code
end

#urlString (readonly)

Returns:

  • (String)


77
78
79
# File 'lib/mindee/parsing/common/api_response.rb', line 77

def url
  @url
end