Class: BlackStack::FreeLeadsData::API

Inherits:
Object
  • Object
show all
Defined in:
lib/freeleadsdata-api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_url = 'https://freeleadsdata.com') ⇒ API

Returns a new instance of API.



8
9
10
11
# File 'lib/freeleadsdata-api.rb', line 8

def initialize(api_key, api_url='https://freeleadsdata.com')
    @api_key = api_key
    @api_url = api_url
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/freeleadsdata-api.rb', line 5

def api_key
  @api_key
end

#api_urlObject



6
7
8
# File 'lib/freeleadsdata-api.rb', line 6

def api_url
  @api_url
end

Instance Method Details

#get(filter = '', page = 1, page_size = 25) ⇒ Object

def new



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/freeleadsdata-api.rb', line 30

def get(filter = '', page = 1, page_size = 25)
    url = @api_url+'/api1.0/zi/get.json'
    begin
        params = {
            'api_key' => @api_key,
            'filter' => filter,
            'page' => page,
            'page_size' => page_size,
        }
        res = BlackStack::Netting::call_post(url, params)
        parsed = JSON.parse(res.body)
        return parsed
    rescue Errno::ECONNREFUSED => e
        raise 'Errno::ECONNREFUSED:' + e.message
    rescue => e2
        raise 'Error:' + e2.message
    end        
end

#new(h) ⇒ Object

def initialize



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/freeleadsdata-api.rb', line 13

def new(h)
    url = @api_url+'/api1.0/zi/new.json'
    begin
        params = {
            'api_key' => @api_key,
            'search' => h,
        }
        res = BlackStack::Netting::call_post(url, params)
        parsed = JSON.parse(res.body)
        return parsed
    rescue Errno::ECONNREFUSED => e
        raise 'Errno::ECONNREFUSED:' + e.message
    rescue => e2
        raise 'Error:' + e2.message
    end        
end