Class: Attio::Client

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

Overview

HTTP client for making API requests to Attio Handles authentication, retries, and error responses

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil) ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/attio/client.rb', line 10

def initialize(api_key: nil)
  @api_key = api_key || Attio.configuration.api_key
  raise AuthenticationError, "No API key provided" unless @api_key
end

Instance Method Details

#delete(path) ⇒ Hash

Perform a DELETE request

Parameters:

  • path (String)

    The API endpoint path

Returns:

  • (Hash)

    Parsed JSON response

Raises:

  • (Error)

    On API errors



55
56
57
# File 'lib/attio/client.rb', line 55

def delete(path)
  request(:delete, path)
end

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

Perform a GET request

Parameters:

  • path (String)

    The API endpoint path

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

    Query parameters

Returns:

  • (Hash)

    Parsed JSON response

Raises:

  • (Error)

    On API errors



20
21
22
# File 'lib/attio/client.rb', line 20

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

#patch(path, body = {}) ⇒ Hash

Perform a PATCH request

Parameters:

  • path (String)

    The API endpoint path

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

    Request body to be sent as JSON

Returns:

  • (Hash)

    Parsed JSON response

Raises:

  • (Error)

    On API errors



47
48
49
# File 'lib/attio/client.rb', line 47

def patch(path, body = {})
  request(:patch, path, body)
end

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

Perform a POST request

Parameters:

  • path (String)

    The API endpoint path

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

    Request body to be sent as JSON

Returns:

  • (Hash)

    Parsed JSON response

Raises:

  • (Error)

    On API errors



29
30
31
# File 'lib/attio/client.rb', line 29

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

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

Perform a PUT request

Parameters:

  • path (String)

    The API endpoint path

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

    Request body to be sent as JSON

Returns:

  • (Hash)

    Parsed JSON response

Raises:

  • (Error)

    On API errors



38
39
40
# File 'lib/attio/client.rb', line 38

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