libring 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libring/api.rb +27 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86a2b2c42e4903d28ceb5eb2d9fc21231635de9c
4
- data.tar.gz: bb74d1c3d1d2246c55aac0393e3b58f7ae0b77cb
3
+ metadata.gz: 13c5279d901bc2a7f889925c3570cabf5ee2c83c
4
+ data.tar.gz: 7c50d33e8ffcf80a5288135326b605f4fb387756
5
5
  SHA512:
6
- metadata.gz: 51d9b55d1488761638a5156809df815338d5f5f36925976fad9cb633df71dd941b9145bfa78aafd38727590d2b14eff56f2779005df5328493f5d9d057d09c82
7
- data.tar.gz: ceb136485eae45be3e44561ec260fa4841a7bca333cf76f9a8c4b2010f7361d8bf68f4db74e6cf88895c75e2d5f5c7fcbedaf420c5faf5f742b90df60b7e0d27
6
+ metadata.gz: f03fb1287a5e5a078cd461755269c448d5e854a1ea7f1cc1c9c63577695565ca643876cf614035a83d3a4a10b143a05adbf5854f4d4fb67c2ef91a2ca3c534c7
7
+ data.tar.gz: da8f8c9f43ee0607e592b395262cad7a300273303ed92b004eaed9eee129c81b8fac95a28f1c14f78bb3efb9384f4e3db499658404b09ae079ea3a185994fd09
@@ -14,21 +14,38 @@ class Libring::API
14
14
  require "uri"
15
15
  require "json"
16
16
 
17
- uri = URI.parse("https://api.libring.com/v2/event_tracker")
17
+ x = 0
18
18
 
19
- https = Net::HTTP.new(uri.host, uri.port)
20
- https.use_ssl = true
19
+ begin
21
20
 
22
- req = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json', 'Authorization' => "Token #{@token}"})
21
+ x += 1
23
22
 
24
- req.set_form_data({ libring: { "#{contact.contact_code}" => { attributes: contact.attributes, location: contact.location, events: contact.events } }.to_json })
23
+ uri = URI.parse("https://api.libring.com/v2/event_tracker")
25
24
 
26
- response = https.request(req)
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.1
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-01 00:00:00.000000000 Z
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