tomba 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/tomba/client.rb +122 -0
- data/lib/tomba/exception.rb +14 -0
- data/lib/tomba/service.rb +12 -0
- data/lib/tomba/services/account.rb +19 -0
- data/lib/tomba/services/count.rb +27 -0
- data/lib/tomba/services/domain.rb +36 -0
- data/lib/tomba/services/finder.rb +40 -0
- data/lib/tomba/services/keys.rb +59 -0
- data/lib/tomba/services/leads-attributes.rb +59 -0
- data/lib/tomba/services/leads-lists.rb +59 -0
- data/lib/tomba/services/logs.rb +19 -0
- data/lib/tomba/services/sources.rb +24 -0
- data/lib/tomba/services/status.rb +45 -0
- data/lib/tomba/services/usage.rb +19 -0
- data/lib/tomba/services/verifier.rb +24 -0
- data/lib/tomba/version.rb +4 -0
- data/lib/tomba.rb +18 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14fc88b877a55b993f2d26a344212ba05c3e95caecc23c544340c33938a0cc2b
|
4
|
+
data.tar.gz: 3c083ee97a506e80b081dd8c1316bf396e5f0f6f445d402cb70d0c40d82a2e63
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79fa611ff51ae93ff978c716e9461e0a8677889fd0b880deac9ee75af5b76d11f7c4719fcb5427cdbdffd956310dd6a7d62a267d76514d17a9937f8d68b8bf1b
|
7
|
+
data.tar.gz: 47132687b7c2f5788bc1aafc47c0ad1318d9e1d69231323509bdceb1322fe1cf68966c72050d8d847a78ab51a26c41b520aa78fb6f6efbe604e92992837f0493
|
data/lib/tomba/client.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
module Tomba
|
7
|
+
class Client
|
8
|
+
|
9
|
+
METHOD_GET = 'get'
|
10
|
+
METHOD_POST = 'post'
|
11
|
+
METHOD_PUT = 'put'
|
12
|
+
METHOD_PATCH = 'patch'
|
13
|
+
METHOD_DELETE = 'delete'
|
14
|
+
METHOD_HEAD = 'head'
|
15
|
+
METHOD_OPTIONS = 'options'
|
16
|
+
METHOD_CONNECT = 'connect'
|
17
|
+
METHOD_TRACE = 'trace'
|
18
|
+
|
19
|
+
def initialize()
|
20
|
+
@headers = {
|
21
|
+
'content-type' => '',
|
22
|
+
'user-agent' => RUBY_PLATFORM + ':ruby-' + RUBY_VERSION,
|
23
|
+
'x-sdk-version' => 'tomba:ruby:v1.0.0'
|
24
|
+
|
25
|
+
}
|
26
|
+
@endpoint = 'https://api.tomba.io/v1';
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_key(value)
|
30
|
+
add_header('x-tomba-key', value)
|
31
|
+
|
32
|
+
return self
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_secret(value)
|
36
|
+
add_header('x-tomba-secret', value)
|
37
|
+
|
38
|
+
return self
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_endpoint(endpoint)
|
42
|
+
@endpoint = endpoint
|
43
|
+
|
44
|
+
return self
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_header(key, value)
|
48
|
+
@headers[key.downcase] = value
|
49
|
+
|
50
|
+
return self
|
51
|
+
end
|
52
|
+
|
53
|
+
def call(method, path = '', headers = {}, params = {})
|
54
|
+
uri = URI.parse(@endpoint + path + ((method == METHOD_GET && params.length) ? '?' + encode(params) : ''))
|
55
|
+
return fetch(method, uri, headers, params)
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def fetch(method, uri, headers, params, limit = 5)
|
63
|
+
raise ArgumentError, 'Too Many HTTP Redirects' if limit == 0
|
64
|
+
|
65
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
66
|
+
http.use_ssl = (uri.scheme == 'https')
|
67
|
+
payload = ''
|
68
|
+
|
69
|
+
headers = @headers.merge(headers)
|
70
|
+
@BOUNDARY = "----A30#3ad1"
|
71
|
+
if (method != METHOD_GET)
|
72
|
+
case headers['content-type'][0, headers['content-type'].index(';') || headers['content-type'].length]
|
73
|
+
when 'application/json'
|
74
|
+
payload = params.to_json
|
75
|
+
else
|
76
|
+
payload = encode(params)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
begin
|
81
|
+
response = http.send_request(method.upcase, uri.request_uri, payload, headers)
|
82
|
+
rescue => error
|
83
|
+
raise Tomba::Exception.new(error.message)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Handle Redirects
|
87
|
+
if (response.class == Net::HTTPRedirection || response.class == Net::HTTPMovedPermanently)
|
88
|
+
location = response['location']
|
89
|
+
uri = URI.parse(uri.scheme + "://" + uri.host + "" + location)
|
90
|
+
|
91
|
+
return fetch(method, uri, headers, {}, limit - 1)
|
92
|
+
end
|
93
|
+
|
94
|
+
begin
|
95
|
+
res = JSON.parse(response.body);
|
96
|
+
rescue JSON::ParserError => e
|
97
|
+
raise Tomba::Exception.new(response.body, response.code, nil)
|
98
|
+
end
|
99
|
+
|
100
|
+
if(response.code.to_i >= 400)
|
101
|
+
raise Tomba::Exception.new(res['errors']['message'], res['errors']['code'], res)
|
102
|
+
end
|
103
|
+
|
104
|
+
return res;
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def encode(value, key = nil)
|
109
|
+
case value
|
110
|
+
when Hash then value.map { |k,v| encode(v, append_key(key,k)) }.join('&')
|
111
|
+
when Array then value.map { |v| encode(v, "#{key}[]") }.join('&')
|
112
|
+
when nil then ''
|
113
|
+
else
|
114
|
+
"#{key}=#{CGI.escape(value.to_s)}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def append_key(root_key, key)
|
119
|
+
root_key.nil? ? key : "#{root_key}[#{key.to_s}]"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Tomba
|
2
|
+
class Count < Service
|
3
|
+
|
4
|
+
def email_count(domain:)
|
5
|
+
if domain.nil?
|
6
|
+
raise Tomba::Exception.new('Missing required parameter: "domain"')
|
7
|
+
end
|
8
|
+
|
9
|
+
path = '/email-count'
|
10
|
+
|
11
|
+
params = {}
|
12
|
+
|
13
|
+
if !domain.nil?
|
14
|
+
params[:domain] = domain
|
15
|
+
end
|
16
|
+
|
17
|
+
return @client.call('get', path, {
|
18
|
+
'content-type' => 'application/json',
|
19
|
+
}, params);
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
private
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Tomba
|
2
|
+
class Domain < Service
|
3
|
+
|
4
|
+
def domain_search(domain:, page: nil, limit: nil, department: nil)
|
5
|
+
if domain.nil?
|
6
|
+
raise Tomba::Exception.new('Missing required parameter: "domain"')
|
7
|
+
end
|
8
|
+
|
9
|
+
path = '/domain-search/{domain}'
|
10
|
+
.gsub('{domain}', domain)
|
11
|
+
|
12
|
+
params = {}
|
13
|
+
|
14
|
+
if !page.nil?
|
15
|
+
params[:page] = page
|
16
|
+
end
|
17
|
+
|
18
|
+
if !limit.nil?
|
19
|
+
params[:limit] = limit
|
20
|
+
end
|
21
|
+
|
22
|
+
if !department.nil?
|
23
|
+
params[:department] = department
|
24
|
+
end
|
25
|
+
|
26
|
+
return @client.call('get', path, {
|
27
|
+
'content-type' => 'application/json',
|
28
|
+
}, params);
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
private
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Tomba
|
2
|
+
class Finder < Service
|
3
|
+
|
4
|
+
def email_finder(domain:, first_name:, last_name:)
|
5
|
+
if domain.nil?
|
6
|
+
raise Tomba::Exception.new('Missing required parameter: "domain"')
|
7
|
+
end
|
8
|
+
|
9
|
+
if first_name.nil?
|
10
|
+
raise Tomba::Exception.new('Missing required parameter: "firstName"')
|
11
|
+
end
|
12
|
+
|
13
|
+
if last_name.nil?
|
14
|
+
raise Tomba::Exception.new('Missing required parameter: "lastName"')
|
15
|
+
end
|
16
|
+
|
17
|
+
path = '/email-finder/{domain}'
|
18
|
+
.gsub('{domain}', domain)
|
19
|
+
|
20
|
+
params = {}
|
21
|
+
|
22
|
+
if !first_name.nil?
|
23
|
+
params[:first_name] = first_name
|
24
|
+
end
|
25
|
+
|
26
|
+
if !last_name.nil?
|
27
|
+
params[:last_name] = last_name
|
28
|
+
end
|
29
|
+
|
30
|
+
return @client.call('get', path, {
|
31
|
+
'content-type' => 'application/json',
|
32
|
+
}, params);
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
private
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Tomba
|
2
|
+
class Keys < Service
|
3
|
+
|
4
|
+
def get_keys()
|
5
|
+
path = '/keys/{id}'
|
6
|
+
|
7
|
+
params = {}
|
8
|
+
|
9
|
+
return @client.call('get', path, {
|
10
|
+
'content-type' => 'application/json',
|
11
|
+
}, params);
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete_key(id:)
|
15
|
+
if id.nil?
|
16
|
+
raise Tomba::Exception.new('Missing required parameter: "id"')
|
17
|
+
end
|
18
|
+
|
19
|
+
path = '/keys/{id}'
|
20
|
+
.gsub('{id}', id)
|
21
|
+
|
22
|
+
params = {}
|
23
|
+
|
24
|
+
return @client.call('delete', path, {
|
25
|
+
'content-type' => 'application/json',
|
26
|
+
}, params);
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_key()
|
30
|
+
path = '/keys/{id}'
|
31
|
+
|
32
|
+
params = {}
|
33
|
+
|
34
|
+
return @client.call('post', path, {
|
35
|
+
'content-type' => 'application/json',
|
36
|
+
}, params);
|
37
|
+
end
|
38
|
+
|
39
|
+
def reset_key(id:)
|
40
|
+
if id.nil?
|
41
|
+
raise Tomba::Exception.new('Missing required parameter: "id"')
|
42
|
+
end
|
43
|
+
|
44
|
+
path = '/keys/{id}'
|
45
|
+
.gsub('{id}', id)
|
46
|
+
|
47
|
+
params = {}
|
48
|
+
|
49
|
+
return @client.call('put', path, {
|
50
|
+
'content-type' => 'application/json',
|
51
|
+
}, params);
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
private
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Tomba
|
2
|
+
class LeadsAttributes < Service
|
3
|
+
|
4
|
+
def get_lead_attributes()
|
5
|
+
path = '/leads/attributes/{id}'
|
6
|
+
|
7
|
+
params = {}
|
8
|
+
|
9
|
+
return @client.call('get', path, {
|
10
|
+
'content-type' => 'application/json',
|
11
|
+
}, params);
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete_lead_attribute(id:)
|
15
|
+
if id.nil?
|
16
|
+
raise Tomba::Exception.new('Missing required parameter: "id"')
|
17
|
+
end
|
18
|
+
|
19
|
+
path = '/leads/attributes/{id}'
|
20
|
+
.gsub('{id}', id)
|
21
|
+
|
22
|
+
params = {}
|
23
|
+
|
24
|
+
return @client.call('delete', path, {
|
25
|
+
'content-type' => 'application/json',
|
26
|
+
}, params);
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_lead_attribute()
|
30
|
+
path = '/leads/attributes/{id}'
|
31
|
+
|
32
|
+
params = {}
|
33
|
+
|
34
|
+
return @client.call('post', path, {
|
35
|
+
'content-type' => 'application/json',
|
36
|
+
}, params);
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_lead_attribute(id:)
|
40
|
+
if id.nil?
|
41
|
+
raise Tomba::Exception.new('Missing required parameter: "id"')
|
42
|
+
end
|
43
|
+
|
44
|
+
path = '/leads/attributes/{id}'
|
45
|
+
.gsub('{id}', id)
|
46
|
+
|
47
|
+
params = {}
|
48
|
+
|
49
|
+
return @client.call('put', path, {
|
50
|
+
'content-type' => 'application/json',
|
51
|
+
}, params);
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
private
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Tomba
|
2
|
+
class LeadsLists < Service
|
3
|
+
|
4
|
+
def get_lists()
|
5
|
+
path = '/leads_lists/{id}'
|
6
|
+
|
7
|
+
params = {}
|
8
|
+
|
9
|
+
return @client.call('get', path, {
|
10
|
+
'content-type' => 'application/json',
|
11
|
+
}, params);
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete_list_id(id:)
|
15
|
+
if id.nil?
|
16
|
+
raise Tomba::Exception.new('Missing required parameter: "id"')
|
17
|
+
end
|
18
|
+
|
19
|
+
path = '/leads_lists/{id}'
|
20
|
+
.gsub('{id}', id)
|
21
|
+
|
22
|
+
params = {}
|
23
|
+
|
24
|
+
return @client.call('delete', path, {
|
25
|
+
'content-type' => 'application/json',
|
26
|
+
}, params);
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_list()
|
30
|
+
path = '/leads_lists/{id}'
|
31
|
+
|
32
|
+
params = {}
|
33
|
+
|
34
|
+
return @client.call('post', path, {
|
35
|
+
'content-type' => 'application/json',
|
36
|
+
}, params);
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_list_id(id:)
|
40
|
+
if id.nil?
|
41
|
+
raise Tomba::Exception.new('Missing required parameter: "id"')
|
42
|
+
end
|
43
|
+
|
44
|
+
path = '/leads_lists/{id}'
|
45
|
+
.gsub('{id}', id)
|
46
|
+
|
47
|
+
params = {}
|
48
|
+
|
49
|
+
return @client.call('put', path, {
|
50
|
+
'content-type' => 'application/json',
|
51
|
+
}, params);
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
private
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Tomba
|
2
|
+
class Sources < Service
|
3
|
+
|
4
|
+
def email_sources(email:)
|
5
|
+
if email.nil?
|
6
|
+
raise Tomba::Exception.new('Missing required parameter: "email"')
|
7
|
+
end
|
8
|
+
|
9
|
+
path = '/email-sources/{email}'
|
10
|
+
.gsub('{email}', email)
|
11
|
+
|
12
|
+
params = {}
|
13
|
+
|
14
|
+
return @client.call('get', path, {
|
15
|
+
'content-type' => 'application/json',
|
16
|
+
}, params);
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
private
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Tomba
|
2
|
+
class Status < Service
|
3
|
+
|
4
|
+
def domain_status(domain:)
|
5
|
+
if domain.nil?
|
6
|
+
raise Tomba::Exception.new('Missing required parameter: "domain"')
|
7
|
+
end
|
8
|
+
|
9
|
+
path = '/domain-status'
|
10
|
+
|
11
|
+
params = {}
|
12
|
+
|
13
|
+
if !domain.nil?
|
14
|
+
params[:domain] = domain
|
15
|
+
end
|
16
|
+
|
17
|
+
return @client.call('get', path, {
|
18
|
+
'content-type' => 'application/json',
|
19
|
+
}, params);
|
20
|
+
end
|
21
|
+
|
22
|
+
def auto_complete(query:)
|
23
|
+
if query.nil?
|
24
|
+
raise Tomba::Exception.new('Missing required parameter: "query"')
|
25
|
+
end
|
26
|
+
|
27
|
+
path = '/domains-suggestion'
|
28
|
+
|
29
|
+
params = {}
|
30
|
+
|
31
|
+
if !query.nil?
|
32
|
+
params[:query] = query
|
33
|
+
end
|
34
|
+
|
35
|
+
return @client.call('get', path, {
|
36
|
+
'content-type' => 'application/json',
|
37
|
+
}, params);
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
private
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Tomba
|
2
|
+
class Verifier < Service
|
3
|
+
|
4
|
+
def email_verifier(email:)
|
5
|
+
if email.nil?
|
6
|
+
raise Tomba::Exception.new('Missing required parameter: "email"')
|
7
|
+
end
|
8
|
+
|
9
|
+
path = '/email-verifier/{email}'
|
10
|
+
.gsub('{email}', email)
|
11
|
+
|
12
|
+
params = {}
|
13
|
+
|
14
|
+
return @client.call('get', path, {
|
15
|
+
'content-type' => 'application/json',
|
16
|
+
}, params);
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
private
|
23
|
+
end
|
24
|
+
end
|
data/lib/tomba.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
require_relative 'tomba/client'
|
5
|
+
require_relative 'tomba/service'
|
6
|
+
require_relative 'tomba/exception'
|
7
|
+
require_relative 'tomba/services/account'
|
8
|
+
require_relative 'tomba/services/domain'
|
9
|
+
require_relative 'tomba/services/finder'
|
10
|
+
require_relative 'tomba/services/verifier'
|
11
|
+
require_relative 'tomba/services/sources'
|
12
|
+
require_relative 'tomba/services/status'
|
13
|
+
require_relative 'tomba/services/count'
|
14
|
+
require_relative 'tomba/services/usage'
|
15
|
+
require_relative 'tomba/services/logs'
|
16
|
+
require_relative 'tomba/services/keys'
|
17
|
+
require_relative 'tomba/services/leads-lists'
|
18
|
+
require_relative 'tomba/services/leads-attributes'
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tomba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mohamed Ben rebia
|
8
|
+
- Tomba technology web service LLC
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-10-19 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: official Ruby library for Tomba
|
15
|
+
email:
|
16
|
+
- b.mohamed@tomba.io
|
17
|
+
- info@tomba.io
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/tomba.rb
|
23
|
+
- lib/tomba/client.rb
|
24
|
+
- lib/tomba/exception.rb
|
25
|
+
- lib/tomba/service.rb
|
26
|
+
- lib/tomba/services/account.rb
|
27
|
+
- lib/tomba/services/count.rb
|
28
|
+
- lib/tomba/services/domain.rb
|
29
|
+
- lib/tomba/services/finder.rb
|
30
|
+
- lib/tomba/services/keys.rb
|
31
|
+
- lib/tomba/services/leads-attributes.rb
|
32
|
+
- lib/tomba/services/leads-lists.rb
|
33
|
+
- lib/tomba/services/logs.rb
|
34
|
+
- lib/tomba/services/sources.rb
|
35
|
+
- lib/tomba/services/status.rb
|
36
|
+
- lib/tomba/services/usage.rb
|
37
|
+
- lib/tomba/services/verifier.rb
|
38
|
+
- lib/tomba/version.rb
|
39
|
+
homepage: https://tomba.io
|
40
|
+
licenses:
|
41
|
+
- Apache-2.0
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 2.5.0
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubygems_version: 3.0.6
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Tomba.io is an Email Finder for B2B sales and email marketing
|
62
|
+
test_files: []
|