-
Notifications
You must be signed in to change notification settings - Fork 3
/
GetLeads.rb
52 lines (40 loc) · 829 Bytes
/
GetLeads.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require "net/https"
require "uri"
#force lowercase as the IDX Broker API is sensitve to case in the request headers.
class Net::HTTP::ImmutableHeaderKey
attr_reader :key
def initialize(key)
@key = key
end
def downcase
self
end
def capitalize
self
end
def split(*)
[self]
end
def hash
key.hash
end
def eql?(other)
key.eql? other.key.eql?
end
def to_s
key
end
end
# make API call
url = 'https://api.idxbroker.com/leads/lead'
api_key = 'YOUR API KEY HERE'
uri = URI.parse(url)
req = Net::HTTP::Get.new(uri.path)
accesskey = Net::HTTP::ImmutableHeaderKey.new("accesskey")
req[accesskey] = api_key
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
resp = http.request(req)
#print out return
puts resp.body