justimmo_client 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +2 -2
- data/lib/justimmo_client/api/v1/requests/justimmo_request.rb +6 -4
- data/lib/justimmo_client/core/caching.rb +1 -1
- data/lib/justimmo_client/core/config.rb +8 -4
- data/lib/justimmo_client/errors.rb +6 -6
- data/lib/justimmo_client/version.rb +1 -1
- metadata +2 -3
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e15b372bb14b581f41d8d71b5f9886c7c8240c3
|
4
|
+
data.tar.gz: f31c58d987586ce4c2cef6aee84b8cf84a0ebd3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d5ac18de60aa2c2c498c79a8fedacf7a801f273df5ce89be60ef78e9b10246c37f460970f8f3188a0d554b06134105782461fcc2f08177d631739fb5dabadaa
|
7
|
+
data.tar.gz: 93ae8c831522281f4db7e7e7cfcc6c586a4377bab9fad325626992ab5f7a7d1983dd0801d2993cfc0a402a695606d943cdaf4cdce4c9004234457a7208f94d81
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -53,7 +53,7 @@ pages:
|
|
53
53
|
- public
|
54
54
|
expire_in: 30 days
|
55
55
|
only:
|
56
|
-
- master
|
56
|
+
- master@exacting/justimmo_client
|
57
57
|
|
58
58
|
deploy:rubygems:
|
59
59
|
stage: deploy
|
@@ -64,4 +64,4 @@ deploy:rubygems:
|
|
64
64
|
script:
|
65
65
|
- dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY
|
66
66
|
only:
|
67
|
-
- tags
|
67
|
+
- tags@exacting/justimmo_client
|
@@ -23,21 +23,23 @@ module JustimmoClient::V1
|
|
23
23
|
}
|
24
24
|
|
25
25
|
with_retries do
|
26
|
-
|
26
|
+
with_request_error_handler do
|
27
27
|
log.debug("Requesting #{uri} with params #{options[:params]}")
|
28
|
+
RestClient.proxy = JustimmoClient::Config.proxy
|
29
|
+
log.debug("Using proxy: #{RestClient.proxy}") if RestClient.proxy
|
28
30
|
response = RestClient.get(uri, options)
|
29
31
|
response.body
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
def
|
36
|
+
def with_request_error_handler
|
35
37
|
yield
|
36
38
|
rescue RestClient::Unauthorized
|
37
39
|
log.error("Authentication failed, check your configuration.")
|
38
40
|
raise JustimmoClient::AuthenticationFailed
|
39
|
-
rescue RestClient::
|
40
|
-
raise JustimmoClient::RetrievalFailed, e
|
41
|
+
rescue RestClient::Exception, SocketError, Errno::ECONNREFUSED => e
|
42
|
+
raise JustimmoClient::RetrievalFailed, e
|
41
43
|
end
|
42
44
|
|
43
45
|
def with_retries
|
@@ -16,29 +16,33 @@ module JustimmoClient
|
|
16
16
|
config_accessor(:base_url) { "api.justimmo.at/rest" }
|
17
17
|
config_accessor(:secure) { true }
|
18
18
|
config_accessor(:api_ver) { 1 }
|
19
|
-
config_accessor(:username)
|
20
|
-
config_accessor(:password)
|
19
|
+
config_accessor(:username) { ENV.fetch("JUSTIMMO_USERNAME", nil) }
|
20
|
+
config_accessor(:password) { ENV.fetch("JUSTIMMO_PASSWORD", nil) }
|
21
21
|
config_accessor(:credentials)
|
22
22
|
config_accessor(:debug) { false }
|
23
23
|
config_accessor(:cache) { nil }
|
24
24
|
config_accessor(:request_retries) { 3 }
|
25
|
+
config_accessor(:proxy) { ENV.fetch("JUSTIMMO_PROXY", nil) }
|
25
26
|
|
26
27
|
class << self
|
27
28
|
def configure
|
28
29
|
super
|
29
30
|
self.credentials = Base64.urlsafe_encode64("#{username}:#{password}")
|
30
|
-
|
31
|
+
validate_api_version
|
31
32
|
end
|
32
33
|
|
33
|
-
def
|
34
|
+
def validate_credentials
|
34
35
|
missing = REQUIRED.select { |r| @_config[r].nil? }
|
35
36
|
raise JustimmoClient::MissingConfiguration, missing unless missing.empty?
|
37
|
+
end
|
36
38
|
|
39
|
+
def validate_api_version
|
37
40
|
supported_ver = SUPPORTED_API_VERSIONS.include?(api_ver)
|
38
41
|
raise JustimmoClient::UnsupportedAPIVersion, api_ver unless supported_ver
|
39
42
|
end
|
40
43
|
|
41
44
|
def url
|
45
|
+
validate_credentials
|
42
46
|
"#{secure ? 'https' : 'http'}://#{base_url}/v#{api_ver}"
|
43
47
|
end
|
44
48
|
end
|
@@ -19,36 +19,36 @@ module JustimmoClient::Errors
|
|
19
19
|
|
20
20
|
# Raised when retrieval from the API fails.
|
21
21
|
class RetrievalFailed < JustimmoError
|
22
|
-
def initialize(
|
23
|
-
super
|
22
|
+
def initialize(exception)
|
23
|
+
super "Failed to get data from the API:\n#{exception.class}: #{exception}"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
# Raised when the option parser rejects an option
|
28
28
|
class InvalidOption < OptionParserError
|
29
29
|
def initialize(key)
|
30
|
-
super
|
30
|
+
super "Option '#{key}' not supported"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
# Raised when the option parser rejects a value
|
35
35
|
class InvalidValue < OptionParserError
|
36
36
|
def initialize(value)
|
37
|
-
super
|
37
|
+
super "'#{value}' is not in the list of accepted values"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
# Raised when an unsupported API version is set.
|
42
42
|
class UnsupportedAPIVersion < ConfigurationError
|
43
43
|
def initialize(version)
|
44
|
-
super
|
44
|
+
super "API Version #{version} not supported"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
# Raised on missing required configuration options.
|
49
49
|
class MissingConfiguration < ConfigurationError
|
50
50
|
def initialize(missing)
|
51
|
-
super
|
51
|
+
super "Required configuration missing: #{missing}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: justimmo_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Auernig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -175,7 +175,6 @@ files:
|
|
175
175
|
- ".gitlab-ci.yml"
|
176
176
|
- ".rspec"
|
177
177
|
- ".rubocop.yml"
|
178
|
-
- ".ruby-version"
|
179
178
|
- Gemfile
|
180
179
|
- LICENSE
|
181
180
|
- README.md
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.3
|