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
|
# File 'lib/libring/api.rb', line 11
def event_track(contact)
require "net/https"
require "uri"
require "json"
x = 0
begin
x += 1
uri = URI.parse("https://api.libring.com/v2/event_tracker")
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
req = Net::HTTP::Post.new(uri.request_uri, = {'Content-Type' =>'application/json', 'Authorization' => "Token #{@token}"})
req.set_form_data({ libring: { "#{contact.contact_code}" => { attributes: contact.attributes, location: contact.location, events: contact.events } }.to_json })
response = https.request(req)
if response.body == ""
{ success: true }
else
{ error: response.body, success: false }
end
rescue
if x <= 5
retry
end
end
end
|