Class: ZktClient::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/zkt_client/http_client.rb

Overview

HttpClient class handles HTTP requests for ZktClient

Class Method Summary collapse

Class Method Details

.delete(url:, headers:) ⇒ Hash

Makes a DELETE HTTP request

Parameters:

  • url (String)

    the URL to send the request to

  • headers (Hash)

    the headers to include in the request

Returns:

  • (Hash)

    the response body



44
45
46
# File 'lib/zkt_client/http_client.rb', line 44

def delete(url:, headers:)
  do_request(:delete, url, headers:)
end

.get(url:, headers:, params: {}) ⇒ Hash

Makes a GET HTTP request

Parameters:

  • url (String)

    the URL to send the request to

  • headers (Hash)

    the headers to include in the request

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

    the query parameters to include in the request

Returns:

  • (Hash)

    the response body



15
16
17
# File 'lib/zkt_client/http_client.rb', line 15

def get(url:, headers:, params: {})
  do_request(:get, url, params:, headers:)
end

.post(url:, params:, headers: {}) ⇒ Hash

Makes a POST HTTP request

Parameters:

  • url (String)

    the URL to send the request to

  • params (Hash)

    the body of the request

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

    the headers to include in the request

Returns:

  • (Hash)

    the response body



25
26
27
# File 'lib/zkt_client/http_client.rb', line 25

def post(url:, params:, headers: {})
  do_request(:post, url, body: params, headers:)
end

.put(url:, params:, headers:) ⇒ Hash

Makes a PUT HTTP request

Parameters:

  • url (String)

    the URL to send the request to

  • params (Hash)

    the body of the request

  • headers (Hash)

    the headers to include in the request

Returns:

  • (Hash)

    the response body



35
36
37
# File 'lib/zkt_client/http_client.rb', line 35

def put(url:, params:, headers:)
  do_request(:put, url, body: params, headers:)
end