complyadvantage 0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/complyadvantage.rb +18 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88b107dac97da65ab51f0f82a054d9f1edfaa1bf
|
4
|
+
data.tar.gz: 80da11eb29c13a21fe352308417cc17528d994e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e91683c1c1cb3e487426ea0038eaafcbb63a409ce97b2ff76d0594be2cf1c43e0c08210465c54eea19a16efc4c6ff578126f6a89650434e2a6dfe0362ef0dc
|
7
|
+
data.tar.gz: c38e7a13a2b8ea78eb318db829d5749555debf3512586cd282fccccf7881401e1b9612140ded3834c38783c058d209f34ef0378589ecdbccbf4342e8c3b5a660
|
data/lib/complyadvantage.rb
CHANGED
@@ -19,26 +19,36 @@ class ComplyAdvantage
|
|
19
19
|
raise ArgumentError, "You must pass an array of names"
|
20
20
|
end
|
21
21
|
response = post("/search", {:names => names})
|
22
|
+
return check_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
def get(id)
|
26
|
+
response = _get("/get/#{id}")
|
27
|
+
return check_response(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def check_response(response)
|
22
33
|
case response.code
|
23
34
|
when 200
|
24
35
|
return response.parsed_response
|
25
36
|
when 401
|
26
|
-
raise ComplyAdvantageAuthenticationError, "Invalid API Key"
|
27
|
-
when 500
|
28
|
-
raise ComplyAdvantageError, "There was an error with your input or the complyadvantage API"
|
37
|
+
raise ComplyAdvantageAuthenticationError, "Invalid API Key"
|
29
38
|
end
|
30
|
-
|
31
|
-
return response
|
39
|
+
raise ComplyAdvantageError, "There was an error with your input or the complyadvantage API"
|
32
40
|
end
|
33
41
|
|
34
|
-
private
|
35
|
-
|
36
42
|
# Internal: Fire POST HTTP request.
|
37
|
-
# We only need POST right now
|
38
43
|
def post(path, params, auth=nil)
|
39
44
|
request(:post, path, :body => params.to_json, :basic_auth => @auth)
|
40
45
|
end
|
41
46
|
|
47
|
+
# Internal: Fire GET HTTP request.
|
48
|
+
def _get(path, query=nil, auth=nil)
|
49
|
+
request(:get, path, :query => query, :basic_auth => @auth)
|
50
|
+
end
|
51
|
+
|
42
52
|
# Internal: Does the actual requests.
|
43
53
|
def request(method, path, params)
|
44
54
|
self.class.send(method, path, params)
|