Class: LemonwayOnboarding::Client

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

Overview

Client for interacting with the Ohme API

Instance Method Summary collapse

Constructor Details

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

Initializes the client with the configuration

Parameters:



12
13
14
15
# File 'lib/lemonway_onboarding/client.rb', line 12

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

Instance Method Details

#delete(endpoint, params = {}) ⇒ Hash?

Performs a DELETE request

Parameters:

  • endpoint (String)

    The API endpoint to access

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

    Optional parameters to include in the request

Returns:

  • (Hash, nil)

    The parsed JSON response or nil for DELETE requests with no body



50
51
52
# File 'lib/lemonway_onboarding/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 access

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

    Optional parameters to include in the request

Returns:

  • (Hash, nil)

    The parsed JSON response or nil for DELETE requests with



22
23
24
# File 'lib/lemonway_onboarding/client.rb', line 22

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 access

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

    The body of the POST request

Returns:

  • (Hash)

    The parsed JSON response



31
32
33
# File 'lib/lemonway_onboarding/client.rb', line 31

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 access

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

    The body of the PUT request

Returns:

  • (Hash)

    The parsed JSON response



40
41
42
# File 'lib/lemonway_onboarding/client.rb', line 40

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