xlogin-apiclient 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xlogin/apiclient.rb +7 -0
- data/lib/xlogin/apiclient/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f3e532530879c3353dcfb7f59479eb4b0f0c1b399f89ee8c65dbf024cee76f5
|
4
|
+
data.tar.gz: 9ea1381765bf42a205d649f5eaf42b490f9dbfd16de7fde69d4843192f5c2156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb5e5d6fbcb8fcf18b41d39b71e87f39ae8a63622711668b369a3736185e12c772a3e95c440120302044936127cb1f3bb9136a891bd41cf7cc65b3ce511798b8
|
7
|
+
data.tar.gz: b877ebf767de4ae72912d31cc802a479e9284aed5515f7430b38ccccd2af2e48b5549c192a7a1c84581d7965f47ebef32ed3cf25d96e9b329d26edf4854cea8d
|
data/lib/xlogin/apiclient.rb
CHANGED
@@ -5,12 +5,16 @@ require 'addressable/uri'
|
|
5
5
|
require 'em-eventsource'
|
6
6
|
require "xlogin/apiclient/version"
|
7
7
|
|
8
|
+
|
8
9
|
module Xlogin
|
9
10
|
class APIClient
|
11
|
+
DEFAULT_TIMEOUT = 60
|
12
|
+
|
10
13
|
class Error < StandardError; end
|
11
14
|
|
12
15
|
class << self
|
13
16
|
attr_accessor :base_url
|
17
|
+
attr_accessor :timeout
|
14
18
|
end
|
15
19
|
|
16
20
|
attr_reader :type, :args
|
@@ -55,6 +59,9 @@ module Xlogin
|
|
55
59
|
req["Accept"] = "application/json"
|
56
60
|
|
57
61
|
http = Net::HTTP.new(uri.host, uri.port)
|
62
|
+
http.open_timeout = self.class.timeout || DEFAULT_TIMEOUT
|
63
|
+
http.read_timeout = self.class.timeout || DEFAULT_TIMEOUT
|
64
|
+
|
58
65
|
resp = http.request(req)
|
59
66
|
raise Error.new(resp.message) unless resp.code =~ /^2[0-9]{2}$/
|
60
67
|
|