Class: Ohme::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ohme/client.rb

Overview

Client for interacting with the Ohme API

Instance Method Summary collapse

Constructor Details

#initialize(configuration = Ohme::Configuration.new) ⇒ Ohme::Client

Initializes the client with the configuration

Parameters:

  • configuration (Ohme::Configuration) (defaults to: Ohme::Configuration.new)

    The configuration object



13
14
15
16
# File 'lib/ohme/client.rb', line 13

def initialize(configuration = Ohme::Configuration.new)
  @configuration = configuration
  @configuration.validate!
end

Instance Method Details

#delete(endpoint, params = {}) ⇒ nil

Performs a DELETE request

Parameters:

  • endpoint (String)

    The API endpoint to request

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

    Optional query parameters

Returns:

  • (nil)

    The response from the API (nil for DELETE requests)



50
51
52
# File 'lib/ohme/client.rb', line 50

def delete(endpoint, params = {})
  request(:delete, endpoint, params: params)
end

#get(endpoint, params = {}) ⇒ Hash

Performs a GET request

Parameters:

  • endpoint (String)

    The API endpoint to request

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

    Optional query parameters

Returns:

  • (Hash)

    The response from the API



23
24
25
# File 'lib/ohme/client.rb', line 23

def get(endpoint, params = {})
  request(:get, endpoint, params: params)
end

#post(endpoint, body = {}) ⇒ Hash

Performs a POST request

Parameters:

  • endpoint (String)

    The API endpoint to request

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

    The request body to send

Returns:

  • (Hash)

    The response from the API



32
33
34
# File 'lib/ohme/client.rb', line 32

def post(endpoint, body = {})
  request(:post, endpoint, body: body)
end

#put(endpoint, body = {}) ⇒ Hash

Performs a PUT request

Parameters:

  • endpoint (String)

    The API endpoint to request

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

    The request body to send

Returns:

  • (Hash)

    The response from the API



41
42
43
# File 'lib/ohme/client.rb', line 41

def put(endpoint, body = {})
  request(:put, endpoint, body: body)
end