Module: Nucleus::Adapters::HttpClient

Included in:
BaseAdapter
Defined in:
lib/nucleus/core/adapter_extensions/http_client.rb

Instance Method Summary collapse

Instance Method Details

#delete(path, params = {}) ⇒ Object

Executes a DELETE request to the given URL.

unprocessed response

Parameters:

  • path (String)

    path to add to the endpoint URL

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

    options to call the post request with

Options Hash (params):

  • :expects (Array<int>) — default: [200, 204]

    http status code that is expected

  • :headers (Hash)

    request headers to use with the request

  • :native_call (Boolean)

    if true the request is a native API call and shall return the

Raises:



81
82
83
# File 'lib/nucleus/core/adapter_extensions/http_client.rb', line 81

def delete(path, params = {})
  execute_request(:delete, [200, 204], path, params, params.delete(:native_call) { false })
end

#get(path, params = {}) ⇒ Object

Executes a GET request to the given URL.

unprocessed response

Parameters:

  • path (String)

    path to add to the endpoint URL

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

    options to call the post request with

Options Hash (params):

  • :expects (Array<int>) — default: [200]

    http status code that is expected

  • :headers (Hash)

    request headers to use with the request

  • :native_call (Boolean)

    if true the request is a native API call and shall return the

Raises:



26
27
28
# File 'lib/nucleus/core/adapter_extensions/http_client.rb', line 26

def get(path, params = {})
  execute_request(:get, [200], path, params, params.delete(:native_call) { false })
end

#head(path, params = {}) ⇒ Object

Executes a HEAD request to the given URL.

unprocessed response

Parameters:

  • path (String)

    path to add to the endpoint URL

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

    options to call the post request with

Options Hash (params):

  • :expects (Array<int>) — default: [200]

    http status code that is expected

  • :headers (Hash)

    request headers to use with the request

  • :native_call (Boolean)

    if true the request is a native API call and shall return the

Raises:



13
14
15
# File 'lib/nucleus/core/adapter_extensions/http_client.rb', line 13

def head(path, params = {})
  execute_request(:head, [200], path, params, params.delete(:native_call) { false })
end

#patch(path, params = {}) ⇒ Object

Executes a PATCH request to the given URL.

unprocessed response

Parameters:

  • path (String)

    path to add to the endpoint URL

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

    options to call the post request with

Options Hash (params):

  • :expects (Array<int>) — default: [200, 201]

    http status code that is expected

  • :body (Hash)

    request body, will be converted to json format

  • :headers (Hash)

    request headers to use with the request

  • :native_call (Boolean)

    if true the request is a native API call and shall return the

Raises:



54
55
56
# File 'lib/nucleus/core/adapter_extensions/http_client.rb', line 54

def patch(path, params = {})
  execute_request(:patch, [200, 201], path, params, params.delete(:native_call) { false })
end

#post(path, params = {}) ⇒ Object

Executes a POST request to the given URL.

unprocessed response

Parameters:

  • path (String)

    path to add to the endpoint URL

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

    options to call the post request with

Options Hash (params):

  • :expects (Array<int>) — default: [200, 201]

    http status code that is expected

  • :body (Hash)

    request body, will be converted to json format

  • :headers (Hash)

    request headers to use with the request

  • :native_call (Boolean)

    if true the request is a native API call and shall return the

Raises:



40
41
42
# File 'lib/nucleus/core/adapter_extensions/http_client.rb', line 40

def post(path, params = {})
  execute_request(:post, [200, 201], path, params, params.delete(:native_call) { false })
end

#put(path, params = {}) ⇒ Object

Executes a PUT request to the given URL.

unprocessed response

Parameters:

  • path (String)

    path to add to the endpoint URL

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

    options to call the post request with

Options Hash (params):

  • :expects (Array<int>) — default: [200, 201]

    http status code that is expected

  • :body (Hash)

    request body, will be converted to json format

  • :headers (Hash)

    request headers to use with the request

  • :native_call (Boolean)

    if true the request is a native API call and shall return the

Raises:



68
69
70
# File 'lib/nucleus/core/adapter_extensions/http_client.rb', line 68

def put(path, params = {})
  execute_request(:put, [200, 201], path, params, params.delete(:native_call) { false })
end