firmenwissen 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6adfb097f5362cf6c61da4ab5a1b49501d8bb280c7686a8245478482156b2d5c
|
4
|
+
data.tar.gz: 65a1fc2c1a83192992aff5ed5345b596129e6cb233266f9a39878815833d5a97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e6dc634c6a65a9bcb5913b7d854767b89f9378831897044cd36f5792bd451e17dbef4bfb28342e7b64a4c119bee46be78cc69ecab37d643046a96063bda084
|
7
|
+
data.tar.gz: ab9d35487f11cb5d1086d681d931322e17abbc6a55dd3d52017b30db72aa3518d97a6fa41f30990ca7747dd7fde8aefbc995b165a53931d4b6fe450cae022270
|
data/lib/firmenwissen.rb
CHANGED
@@ -10,6 +10,7 @@ require 'firmenwissen/suggestion'
|
|
10
10
|
require 'firmenwissen/version'
|
11
11
|
|
12
12
|
require 'firmenwissen/errors/credentials_error'
|
13
|
+
require 'firmenwissen/errors/unprocessable_response_error'
|
13
14
|
|
14
15
|
require 'firmenwissen/request/base'
|
15
16
|
require 'firmenwissen/request/mock'
|
@@ -1,18 +1,17 @@
|
|
1
1
|
module Firmenwissen
|
2
2
|
module Response
|
3
3
|
class Base
|
4
|
+
attr_reader :suggestions
|
5
|
+
|
4
6
|
def initialize(http_response)
|
5
7
|
@http_response = http_response
|
6
|
-
|
7
|
-
|
8
|
-
def suggestions
|
9
|
-
@suggestions ||= data.map { |suggestion| Suggestion.new(suggestion) }
|
8
|
+
@suggestions = build_suggestions
|
10
9
|
end
|
11
10
|
|
12
11
|
def data
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
@data ||= parsed_response.map { |hash| map_keys(hash) }
|
13
|
+
rescue JSON::ParserError
|
14
|
+
raise UnprocessableResponseError, "The response from Firmenwissen could not be processed:\n#{body}"
|
16
15
|
end
|
17
16
|
|
18
17
|
def status_code
|
@@ -27,10 +26,20 @@ module Firmenwissen
|
|
27
26
|
|
28
27
|
attr_reader :http_response
|
29
28
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def body
|
30
|
+
http_response.body
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_suggestions
|
34
|
+
data.map { |suggestion| Suggestion.new(suggestion) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def map_keys(hash)
|
38
|
+
KeyMapper.from_api(hash)
|
39
|
+
end
|
40
|
+
|
41
|
+
def parsed_response
|
42
|
+
JSON.parse(body).fetch('companyNameSuggestions', [])
|
34
43
|
end
|
35
44
|
end
|
36
45
|
end
|
data/lib/firmenwissen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firmenwissen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerrit Seger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/firmenwissen.rb
|
94
94
|
- lib/firmenwissen/configuration.rb
|
95
95
|
- lib/firmenwissen/errors/credentials_error.rb
|
96
|
+
- lib/firmenwissen/errors/unprocessable_response_error.rb
|
96
97
|
- lib/firmenwissen/http_request.rb
|
97
98
|
- lib/firmenwissen/key_mapper.rb
|
98
99
|
- lib/firmenwissen/request.rb
|