Module: Airborne::Helpers

Defined in:
lib/airborne/helpers.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



16
17
18
# File 'lib/airborne/helpers.rb', line 16

def body
  response.body
end

#headersObject



9
10
11
12
13
14
# File 'lib/airborne/helpers.rb', line 9

def headers
  response
    .headers
    .transform_keys { |k| k.to_s.underscore.to_sym }
    .with_indifferent_access
end

#json_bodyObject



20
21
22
23
24
# File 'lib/airborne/helpers.rb', line 20

def json_body
  JSON.parse(response.body, symbolize_names: true)
rescue StandardError
  raise InvalidJsonError, "API request returned invalid json"
end

#responseObject



5
6
7
# File 'lib/airborne/helpers.rb', line 5

def response
  @response
end