Class: Alchemrest::Response

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
Memosa
Defined in:
lib/alchemrest/response.rb,
lib/alchemrest/response/pipeline.rb,
lib/alchemrest/response/pipeline/omit.rb,
lib/alchemrest/response/pipeline/final.rb,
lib/alchemrest/response/pipeline/sanitize.rb,
lib/alchemrest/response/pipeline/transform.rb,
lib/alchemrest/response/pipeline/was_successful.rb,
lib/alchemrest/response/pipeline/extract_payload.rb

Defined Under Namespace

Classes: Pipeline

Instance Method Summary collapse

Instance Method Details

#auth_error?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/alchemrest/response.rb', line 35

def auth_error?
  [401, 403].include?(status)
end

#circuit_open?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/alchemrest/response.rb', line 55

def circuit_open?
  false
end

#client_error?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/alchemrest/response.rb', line 31

def client_error?
  (400..499).cover?(status)
end

#dataObject



10
11
12
# File 'lib/alchemrest/response.rb', line 10

def data
  body
end

#error_detailsObject



23
24
25
# File 'lib/alchemrest/response.rb', line 23

def error_details
  "Error with HTTP status: #{status}" unless success?
end

#no_content_response?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/alchemrest/response.rb', line 43

def no_content_response?
  status == 204
end

#not_found_error?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/alchemrest/response.rb', line 39

def not_found_error?
  status == 404
end

#request_failed?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/alchemrest/response.rb', line 47

def request_failed?
  status >= 500 && status <= 599
end

#server_error?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/alchemrest/response.rb', line 27

def server_error?
  (500..599).cover?(status)
end

#timeout?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/alchemrest/response.rb', line 51

def timeout?
  false
end

#to_resultObject



14
15
16
17
18
19
20
21
# File 'lib/alchemrest/response.rb', line 14

def to_result
  if success?
    Result.Ok(self)
  else
    error.set_backtrace(caller)
    Result.Error(error)
  end
end