Method: Strutta::API#call

Defined in:
lib/strutta-api.rb

#call(method, url, params = {}) ⇒ Hash

Makes an API call

Parameters:

  • method (String)

    the required HTTP method

  • url (String)

    URL for the call

  • params (Hash) (defaults to: {})

    Parameters for the call

Returns:

  • (Hash)

    Parsed body of the response



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/strutta-api.rb', line 45

def call(method, url, params = {})
  params = JSON.generate(params)
  r = @session.send(method, path: "#{@path}#{url}", headers: api_headers, body: params)

  # Delete calls have no JSON return
  return true if r.status == 204

  # Raise exceptions on error response codes
  cast_error(r.status, r.body) if r.status >= 400

  JSON.parse(r.body)
end