Class: Ohme::API::Contact

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

Overview

The Contact class provides methods to interact with the Ohme API’s contacts endpoint. It allows you to list, create, read, update, and delete contacts.

Instance Method Summary collapse

Constructor Details

#initialize(client = Ohme::Client.new) ⇒ Ohme::API::Contact

Initializes a new Contact instance with a client.

make API requests

Parameters:

  • client (Ohme::Client) (defaults to: Ohme::Client.new)

    An instance of the Ohme client to



14
15
16
# File 'lib/ohme/api/contact.rb', line 14

def initialize(client = Ohme::Client.new)
  @client = client
end

Instance Method Details

#create(body) ⇒ Hash

Creates a new contact

Parameters:

  • body (Hash)

    The contact data to be sent in the request body

Returns:

  • (Hash)

    The response from the API



30
31
32
# File 'lib/ohme/api/contact.rb', line 30

def create(body)
  @client.post('contacts', body)
end

#delete(id) ⇒ nil

Deletes a contact by ID

Parameters:

  • id (String)

    The ID of the contact to delete

Returns:

  • (nil)

    The response from the API



55
56
57
# File 'lib/ohme/api/contact.rb', line 55

def delete(id)
  @client.delete("contacts/#{id}")
end

#index(params = {}) ⇒ Hash

Fetches the list of contacts

Parameters:

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

    Optional query parameters

Returns:

  • (Hash)

    The response from the API



22
23
24
# File 'lib/ohme/api/contact.rb', line 22

def index(params = {})
  @client.get('contacts', params)
end

#show(id) ⇒ Hash

Fetches a contact by ID

Parameters:

  • id (String)

    The ID of the contact to retrieve

Returns:

  • (Hash)

    The response from the API



47
48
49
# File 'lib/ohme/api/contact.rb', line 47

def show(id)
  @client.get("contacts/#{id}")
end

#update(id, body) ⇒ Hash

Updates a contact by ID

Parameters:

  • id (String)

    The ID of the contact to update

  • body (Hash)

    The contact data to be updated

Returns:

  • (Hash)

    The response from the API



39
40
41
# File 'lib/ohme/api/contact.rb', line 39

def update(id, body)
  @client.put("contacts/#{id}", body)
end