Class: Ohme::API::Contact
- Inherits:
-
Object
- Object
- Ohme::API::Contact
- 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
-
#create(body) ⇒ Hash
Creates a new contact.
-
#delete(id) ⇒ nil
Deletes a contact by ID.
-
#index(params = {}) ⇒ Hash
Fetches the list of contacts.
-
#initialize(client = Ohme::Client.new) ⇒ Ohme::API::Contact
constructor
Initializes a new Contact instance with a client.
-
#show(id) ⇒ Hash
Fetches a contact by ID.
-
#update(id, body) ⇒ Hash
Updates a contact by ID.
Constructor Details
#initialize(client = Ohme::Client.new) ⇒ Ohme::API::Contact
Initializes a new Contact instance with a client.
make API requests
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
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
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
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
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
39 40 41 |
# File 'lib/ohme/api/contact.rb', line 39 def update(id, body) @client.put("contacts/#{id}", body) end |