Exception: Avmtrf1::RestProvider::Response

Inherits:
StandardError
  • Object
show all
Defined in:
lib/avmtrf1/rest_provider/response.rb

Instance Method Summary collapse

Instance Method Details

#body_dataObject


12
13
14
15
16
17
18
# File 'lib/avmtrf1/rest_provider/response.rb', line 12

def body_data
  r = performed_curl.headers['Accept'].if_present(body_str) do |v|
    send("body_data_from_#{v.parameterize.underscore}")
  end
  r = body_data_proc.call(r) if body_data_proc.present?
  r
end

#body_data_or_raiseObject


20
21
22
23
24
# File 'lib/avmtrf1/rest_provider/response.rb', line 20

def body_data_or_raise
  raise_unless_200

  body_data
end

#body_strObject


26
27
28
# File 'lib/avmtrf1/rest_provider/response.rb', line 26

def body_str
  performed_curl.body_str
end

#body_str_or_raiseObject


30
31
32
33
34
# File 'lib/avmtrf1/rest_provider/response.rb', line 30

def body_str_or_raise
  raise_unless_200

  body_str
end

#raise_unless_200Object

Raises:

  • (self)

36
37
38
39
40
# File 'lib/avmtrf1/rest_provider/response.rb', line 36

def raise_unless_200
  return nil if status == 200

  raise self
end

#statusObject


42
43
44
# File 'lib/avmtrf1/rest_provider/response.rb', line 42

def status
  performed_curl.status.to_i
end

#to_sObject


50
51
52
# File 'lib/avmtrf1/rest_provider/response.rb', line 50

def to_s
  "URL: #{url}\nStatus: #{status}\nBody:\n\n#{body_str}"
end

#urlObject


46
47
48
# File 'lib/avmtrf1/rest_provider/response.rb', line 46

def url
  curl.url
end