Class: Tomba::Bulk

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

Overview

Bulk service for managing bulk operations.

Provides methods to list, get, create, launch, delete, archive, rename, check progress, and download bulk tasks.

Constant Summary collapse

VALID_TYPES =
%w[search similar company finder enrich linkedin author verifier phone-finder phone-validator].freeze

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Tomba::Service

Instance Method Details

#archive(type, id) ⇒ Hash

Archive Bulk Task

Archives a bulk task by type and ID.

Parameters:

  • type (String)

    the bulk task type

  • id (String)

    the bulk task ID

Returns:

  • (Hash)

    API response

Raises:

See Also:



146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/tomba/services/bulk.rb', line 146

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

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

  path = "/bulk/#{type}/#{id}/archive"

  params = {}

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

#create(type, data) ⇒ Hash

Create Bulk Task

Creates a new bulk task of the specified type.

Parameters:

  • type (String)

    the bulk task type

  • data (Hash)

    the bulk task data

Returns:

  • (Hash)

    API response containing the created bulk task

Raises:

See Also:



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

def create(type, data)
  raise Tomba::Exception, 'Missing required parameter: "type"' if type.nil?

  validate_type(type)

  path = "/bulk/#{type}"

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

#delete(type, id) ⇒ Hash

Delete Bulk Task

Deletes a bulk task by type and ID.

Parameters:

  • type (String)

    the bulk task type

  • id (String)

    the bulk task ID

Returns:

  • (Hash)

    API response

Raises:

See Also:



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/tomba/services/bulk.rb', line 122

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

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

  path = "/bulk/#{type}/#{id}"

  params = {}

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

#download(type, id) ⇒ Hash

Download Bulk Task

Downloads the results of a completed bulk task.

Parameters:

  • type (String)

    the bulk task type

  • id (String)

    the bulk task ID

Returns:

  • (Hash)

    API response containing download data

Raises:

See Also:



220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/tomba/services/bulk.rb', line 220

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

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

  path = "/bulk/#{type}/#{id}/download"

  params = {}

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

#get(type, id) ⇒ Hash

Get Bulk Task

Returns a specific bulk task by type and ID.

Parameters:

  • type (String)

    the bulk task type

  • id (String)

    the bulk task ID

Returns:

  • (Hash)

    API response containing the bulk task data

Raises:

See Also:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/tomba/services/bulk.rb', line 53

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

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

  path = "/bulk/#{type}/#{id}"

  params = {}

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

#launch(type, id) ⇒ Hash

Launch Bulk Task

Launches (starts) a bulk task by type and ID.

Parameters:

  • type (String)

    the bulk task type

  • id (String)

    the bulk task ID

Returns:

  • (Hash)

    API response

Raises:

See Also:



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/tomba/services/bulk.rb', line 98

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

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

  path = "/bulk/#{type}/#{id}/launch"

  params = {}

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

#list(type, params: {}) ⇒ Hash

List Bulk Tasks

Returns a list of bulk tasks of the specified type.

Parameters:

  • type (String)

    the bulk task type (e.g., "searches", "verifiers")

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

    optional query parameters for filtering

Returns:

  • (Hash)

    API response containing the list of bulk tasks

Raises:

See Also:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tomba/services/bulk.rb', line 32

def list(type, params: {})
  raise Tomba::Exception, 'Missing required parameter: "type"' if type.nil?

  validate_type(type)

  path = "/bulk/#{type}"

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

#progress(type, id) ⇒ Hash

Bulk Task Progress

Returns the progress status of a bulk task.

Parameters:

  • type (String)

    the bulk task type

  • id (String)

    the bulk task ID

Returns:

  • (Hash)

    API response containing progress data

Raises:

See Also:



196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/tomba/services/bulk.rb', line 196

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

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

  path = "/bulk/#{type}/#{id}/progress"

  params = {}

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

#rename(type, id, name) ⇒ Hash

Rename Bulk Task

Renames a bulk task by type and ID.

Parameters:

  • type (String)

    the bulk task type

  • id (String)

    the bulk task ID

  • name (String)

    the new name for the bulk task

Returns:

  • (Hash)

    API response

Raises:

See Also:



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/tomba/services/bulk.rb', line 171

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

  validate_type(type)
  raise Tomba::Exception, 'Missing required parameter: "id"' if id.nil?
  raise Tomba::Exception, 'Missing required parameter: "name"' if name.nil?

  path = "/bulk/#{type}/#{id}/rename"

  params = { name: name }

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

#validate_type(type) ⇒ Object

Validate the bulk type parameter.

Parameters:

  • type (String)

    the bulk type to validate

Raises:



17
18
19
20
21
# File 'lib/tomba/services/bulk.rb', line 17

def validate_type(type)
  return if VALID_TYPES.include?(type)

  raise Tomba::Exception, "Invalid bulk type: \"#{type}\". Must be one of: #{VALID_TYPES.join(', ')}"
end