vogogo 0.1.0 → 0.2.0
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/vogogo/client.rb +52 -0
- data/lib/vogogo/notifications/events.rb +10 -0
- data/lib/vogogo/risk/customers.rb +10 -0
- data/lib/vogogo/risk/occupations.rb +10 -0
- data/lib/vogogo/risk/supported_countries.rb +10 -0
- data/lib/vogogo/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ffeba8157b1bd55f236d3ca1d0146c865e5afb51
|
|
4
|
+
data.tar.gz: 3924c81b9f2c0dc889cc1b7a082eebf0ace31c2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2158bfe52c1712b862811c92c09cc4dfcb320b5ec8ef52ae37e3194f2427ba9f597e34e47b49dc427bb35a5afe8081c75ef3ef32ffdc14ed9dbe8eee04941dd9
|
|
7
|
+
data.tar.gz: 294adcfbd98576401450ba3ba7207ba76c2460b1894dba98bceba214ecdbb62e6c68778d2c25bbc50a70d67d26f68a5dff9e205ebb25068a5fb6108d74094523
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module Vogogo
|
|
2
|
+
class Client
|
|
3
|
+
attr_accessor :uri, :http, :status
|
|
4
|
+
|
|
5
|
+
API_URI = 'https://api.vogogo.com/v3/'
|
|
6
|
+
|
|
7
|
+
include Vogogo::Notifications::Events
|
|
8
|
+
include Vogogo::Risk::Customers
|
|
9
|
+
include Vogogo::Risk::IndustryTypes
|
|
10
|
+
include Vogogo::Risk::Occupations
|
|
11
|
+
include Vogogo::Risk::SupportedCountries
|
|
12
|
+
include Vogogo::Risk::PhoneNumbers
|
|
13
|
+
include Vogogo::Risk::Documents
|
|
14
|
+
|
|
15
|
+
def initialize(username = nil, password = nil)
|
|
16
|
+
@username = username || ENV['VOGOGO_USERNAME']
|
|
17
|
+
@password = password || ENV['VOGOGO_PASSWORD']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
def connection(method)
|
|
22
|
+
@uri = URI.parse(API_URI + "#{method}")
|
|
23
|
+
@http = Net::HTTP.new(uri.host, uri.port)
|
|
24
|
+
@http.use_ssl = true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def request_method(method_name, params = {})
|
|
28
|
+
case method_name
|
|
29
|
+
when 'put'
|
|
30
|
+
request = Net::HTTP::Put.new(@uri.request_uri)
|
|
31
|
+
when 'post'
|
|
32
|
+
request = Net::HTTP::Post.new(@uri.request_uri)
|
|
33
|
+
when 'get'
|
|
34
|
+
request = Net::HTTP::Get.new(@uri.request_uri)
|
|
35
|
+
end
|
|
36
|
+
request["content-type"] = "application/json"
|
|
37
|
+
request.basic_auth(@username, @password)
|
|
38
|
+
request.body = params.to_json
|
|
39
|
+
response = @http.request(request)
|
|
40
|
+
|
|
41
|
+
raise Vogogo::ClientError.new("401 Unauthorized") if response.code.to_i == 401
|
|
42
|
+
raise Vogogo::ClientError.new("400 Bad Request") if response.code.to_i == 400
|
|
43
|
+
raise Vogogo::ClientError.new("500 Internal Sever Error") if response.code.to_i == 500
|
|
44
|
+
raise Vogogo::ClientError.new("501 Not implemented") if response.code.to_i == 501
|
|
45
|
+
raise Vogogo::ClientError.new("Response status code: #{response.code}") unless response.code.to_i == 200
|
|
46
|
+
|
|
47
|
+
JSON.parse(response.body)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class ClientError < StandardError; end
|
|
52
|
+
end
|
data/lib/vogogo/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vogogo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcin Jan Adamczyk
|
|
@@ -54,6 +54,11 @@ files:
|
|
|
54
54
|
- bin/console
|
|
55
55
|
- bin/setup
|
|
56
56
|
- lib/vogogo.rb
|
|
57
|
+
- lib/vogogo/client.rb
|
|
58
|
+
- lib/vogogo/notifications/events.rb
|
|
59
|
+
- lib/vogogo/risk/customers.rb
|
|
60
|
+
- lib/vogogo/risk/occupations.rb
|
|
61
|
+
- lib/vogogo/risk/supported_countries.rb
|
|
57
62
|
- lib/vogogo/version.rb
|
|
58
63
|
- vogogo.gemspec
|
|
59
64
|
homepage: https://github.com/tehplayer/vogogo
|