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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11b8ea7176b13c51949309a7d025233ca663b712
4
- data.tar.gz: 5833c9dff886107d7f1dc8c93a8fd1d6b5c9f827
3
+ metadata.gz: ffeba8157b1bd55f236d3ca1d0146c865e5afb51
4
+ data.tar.gz: 3924c81b9f2c0dc889cc1b7a082eebf0ace31c2e
5
5
  SHA512:
6
- metadata.gz: 767ec17fe1949c7dc982780e0ddf6e42238ed725c73d1e3feeb14d03dedd3995adfd644b2748a418fb1c65c14552523dc43b9e9035c965d786cabdf9c9475974
7
- data.tar.gz: e29666b4a9110e2740c70521c8bb8196b2e06964b679ae80fbf784af1784cbc24efb61c2e4d7d12187301db62f416a7b46ae2f56d806b5f2dc7e96277c8d68bb
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
@@ -0,0 +1,10 @@
1
+ module Vogogo
2
+ module Notifications
3
+ module Events
4
+ def get_events
5
+ connection('events')
6
+ request_method('get')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Vogogo
2
+ module Risk
3
+ module Customers
4
+ def get_customers
5
+ connection('customers')
6
+ request_method('get')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Vogogo
2
+ module Risk
3
+ module Occupations
4
+ def get_occupations
5
+ connection('occupations')
6
+ request_method('get')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Vogogo
2
+ module Risk
3
+ module SupportedCountries
4
+ def get_country_codes
5
+ connection('country_codes')
6
+ request_method('get')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Vogogo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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