Class: Tomba::Leads

Inherits:
Service show all
Defined in:
lib/tomba/services/leads.rb

Overview

Leads service for managing individual leads.

Provides methods to list, get, create, update, and delete leads.

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Tomba::Service

Instance Method Details

#create_lead(**data) ⇒ Hash

Create Lead

Creates a new lead with the provided data.

Parameters:

  • data (Hash)

    the lead data (e.g., email, first_name, last_name)

Returns:

  • (Hash)

    API response containing the created lead

Raises:

See Also:



61
62
63
64
65
66
67
# File 'lib/tomba/services/leads.rb', line 61

def create_lead(**data)
  path = '/leads'

  @client.call('post', path, {
                 'content-type' => 'application/json'
               }, data)
end

#delete_lead(id) ⇒ Hash

Delete Lead

Deletes a specific lead by its ID.

Parameters:

  • id (String)

    the lead ID to delete

Returns:

  • (Hash)

    API response

Raises:

See Also:



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/tomba/services/leads.rb', line 96

def delete_lead(id)
  raise Tomba::Exception, 'Missing required parameter: "id"' if id.nil?

  path = "/leads/#{id}"

  params = {}

  @client.call('delete', path, {
                 'content-type' => 'application/json'
               }, params)
end

#get_lead(id) ⇒ Hash

Get Lead

Returns a specific lead by its ID.

Parameters:

  • id (String)

    the lead ID

Returns:

  • (Hash)

    API response containing the lead data

Raises:

See Also:



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tomba/services/leads.rb', line 41

def get_lead(id)
  raise Tomba::Exception, 'Missing required parameter: "id"' if id.nil?

  path = "/leads/#{id}"

  params = {}

  @client.call('get', path, {
                 'content-type' => 'application/json'
               }, params)
end

#list_leads(page: nil, limit: nil, domain: nil) ⇒ Hash

List Leads

Returns a paginated list of leads.

Parameters:

  • page (Integer, nil) (defaults to: nil)

    the page number for pagination

  • limit (Integer, nil) (defaults to: nil)

    the number of results per page

  • domain (String, nil) (defaults to: nil)

    filter leads by domain

Returns:

  • (Hash)

    API response containing the list of leads

Raises:

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tomba/services/leads.rb', line 20

def list_leads(page: nil, limit: nil, domain: nil)
  path = '/leads'

  params = {}
  params[:page] = page unless page.nil?
  params[:limit] = limit unless limit.nil?
  params[:domain] = domain unless domain.nil?

  @client.call('get', path, {
                 'content-type' => 'application/json'
               }, params)
end

#update_lead(id, **data) ⇒ Hash

Update Lead

Updates an existing lead by its ID.

Parameters:

  • id (String)

    the lead ID to update

  • data (Hash)

    the lead data to update

Returns:

  • (Hash)

    API response containing the updated lead

Raises:

See Also:



78
79
80
81
82
83
84
85
86
# File 'lib/tomba/services/leads.rb', line 78

def update_lead(id, **data)
  raise Tomba::Exception, 'Missing required parameter: "id"' if id.nil?

  path = "/leads/#{id}"

  @client.call('put', path, {
                 'content-type' => 'application/json'
               }, data)
end