libring 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libring/api.rb +27 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13c5279d901bc2a7f889925c3570cabf5ee2c83c
|
4
|
+
data.tar.gz: 7c50d33e8ffcf80a5288135326b605f4fb387756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f03fb1287a5e5a078cd461755269c448d5e854a1ea7f1cc1c9c63577695565ca643876cf614035a83d3a4a10b143a05adbf5854f4d4fb67c2ef91a2ca3c534c7
|
7
|
+
data.tar.gz: da8f8c9f43ee0607e592b395262cad7a300273303ed92b004eaed9eee129c81b8fac95a28f1c14f78bb3efb9384f4e3db499658404b09ae079ea3a185994fd09
|
data/lib/libring/api.rb
CHANGED
@@ -14,21 +14,38 @@ class Libring::API
|
|
14
14
|
require "uri"
|
15
15
|
require "json"
|
16
16
|
|
17
|
-
|
17
|
+
x = 0
|
18
18
|
|
19
|
-
|
20
|
-
https.use_ssl = true
|
19
|
+
begin
|
21
20
|
|
22
|
-
|
21
|
+
x += 1
|
23
22
|
|
24
|
-
|
23
|
+
uri = URI.parse("https://api.libring.com/v2/event_tracker")
|
25
24
|
|
26
|
-
|
25
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
26
|
+
https.use_ssl = true
|
27
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
28
|
+
|
29
|
+
req = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json', 'Authorization' => "Token #{@token}"})
|
30
|
+
|
31
|
+
req.set_form_data({ libring: { "#{contact.contact_code}" => { attributes: contact.attributes, location: contact.location, events: contact.events } }.to_json })
|
32
|
+
|
33
|
+
response = https.request(req)
|
34
|
+
|
35
|
+
if response.body == ""
|
36
|
+
{ success: true }
|
37
|
+
else
|
38
|
+
{ error: response.body, success: false }
|
39
|
+
end
|
40
|
+
|
41
|
+
rescue
|
42
|
+
|
43
|
+
if x <= 5
|
44
|
+
retry
|
45
|
+
else
|
46
|
+
next
|
47
|
+
end
|
27
48
|
|
28
|
-
if response.body == ""
|
29
|
-
{ success: true }
|
30
|
-
else
|
31
|
-
{ error: response.body, success: false }
|
32
49
|
end
|
33
50
|
|
34
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitor Pereira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Libring API for Ruby
|
14
14
|
email: vitor@libring.com
|