kleber 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b688be07c4561cdebee8e91fe751384ce20c2207
4
+ data.tar.gz: 0d2e556532dd8368c670fc6653e0ccb4d071c2af
5
+ SHA512:
6
+ metadata.gz: 5e5114b8f53fb0a345a6f1fb9d7ebd07c07f48ce13e6f3d12615a504a446f68b4cdbaaff77c0bd1801529d17c7524d38e7f432035836de66ea5684b70da10835
7
+ data.tar.gz: d51a252f577cfe1c955f408928bd84b2d32f095f8043bccef283336c20a4650dda10ea51e50af13d10b50c4b39b6418461568c30b603c7dd430261ad0d365643
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kleber.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Karl Kloppenborg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Kleber
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kleber'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kleber
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/kleber/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kleber/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kleber"
8
+ spec.version = Kleber::VERSION
9
+ spec.authors = ["Karl Kloppenborg"]
10
+ spec.email = ["karl@logicsaas.com"]
11
+ spec.summary = %q{Kleber interfaces with the DataTools Kleber service}
12
+ spec.description = %q{Kleber provides data hydration services for address verification and repair}
13
+ spec.homepage = "https://www.logicsaas.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,20 @@
1
+ require "kleber/version"
2
+ require "kleber/exception"
3
+ require "kleber/methods"
4
+ require "kleber/web_request"
5
+ require "kleber/query/address_verify"
6
+
7
+ class Kleber
8
+ PRODUCTION = 'production'
9
+ DEVELOPMENT = 'development'
10
+ def initialize(request_key, environment)
11
+ @request_key = request_key
12
+ raise Kleber::EnvironmentNotFound, "Environment is either development or production, you specified #{environment}" unless (environment.eql? Kleber::DEVELOPMENT or environment.eql? Kleber::PRODUCTION)
13
+ @environment = environment
14
+ if environment.eql? Kleber::DEVELOPMENT
15
+ @host = "http://kleber-devuat.datatoolscloud.net.au"
16
+ else
17
+ @host = "https://kleber.datatoolscloud.net.au"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ class Kleber::EnvironmentNotFound < StandardError
2
+ end
3
+
4
+ class Kleber::TooManyAddresses < StandardError
5
+ end
6
+
7
+ class Kleber::QueryResponseInvalid < StandardError
8
+ end
@@ -0,0 +1,5 @@
1
+ class Kleber::Methods
2
+ class Verify
3
+ AUPAF_ADDRESS = 'DataTools.Verify.Address.AuPaf.VerifyAddress'
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ module Kleber::Query
2
+ class AddressVerify
3
+ attr_reader :payload
4
+ #
5
+ # This class will provide the json payload for the request.
6
+ #
7
+ def initialize(locality, state, postcode, addressLine1, otherAddresses)
8
+ raise Kleber::TooManyAddresses, "Max of five other address lines, you entered #{otherAddresses.count}" unless otherAddresses.count < 6
9
+ @payload = {
10
+ :Locality => locality,
11
+ :State => state,
12
+ :Postcode => postcode,
13
+ :AddressLine1 => addressLine1
14
+ }
15
+ counter = 2
16
+ otherAddresses.each do |val|
17
+ @payload["AddressLine#{counter}".to_sym] = val
18
+ counter += 1
19
+ end
20
+ end
21
+ #/End Initialize
22
+ end
23
+ end
24
+
25
+ class Kleber
26
+
27
+ def run_address_verification(locality, state, postcode, addressLine1, *otherAddresses)
28
+ query = Kleber::Query::AddressVerify.new(locality, state, postcode, addressLine1, otherAddresses)
29
+ response = get_request(Kleber::Methods::Verify::AUPAF_ADDRESS, query.payload)
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ class Kleber
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ require "net/http"
2
+
3
+ class Kleber
4
+ DEFAULT_SERVER_PATH = '/KleberWebService/DtKleberService.svc/ProcessQueryStringRequest'
5
+ def get_request(method, queryPayload)
6
+ uri = URI.parse(@host)
7
+ uri.path = DEFAULT_SERVER_PATH
8
+
9
+ headerPayload = {
10
+ :Method => method,
11
+ :RequestKey => @request_key,
12
+ :OutputFormat => "json"
13
+ }
14
+ headerPayload.merge! queryPayload
15
+ Rails.logger.debug headerPayload
16
+
17
+ uri.query = URI.encode_www_form(headerPayload)
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+
20
+ if @environment.eql? Kleber::PRODUCTION
21
+ http.use_ssl = true
22
+ end
23
+
24
+ request = Net::HTTP::Get.new(uri)
25
+ response = http.request(request)
26
+ raise Kleber::QueryResponseInvalid, "The query response was #{response.code}, expected 200" unless response.code.to_i.eql? 200
27
+ return ActiveSupport::JSON.decode(response.body)
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kleber
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Karl Kloppenborg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Kleber provides data hydration services for address verification and
42
+ repair
43
+ email:
44
+ - karl@logicsaas.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - kleber.gemspec
55
+ - lib/kleber.rb
56
+ - lib/kleber/exception.rb
57
+ - lib/kleber/methods.rb
58
+ - lib/kleber/query/address_verify.rb
59
+ - lib/kleber/version.rb
60
+ - lib/kleber/web_request.rb
61
+ homepage: https://www.logicsaas.com
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.4
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Kleber interfaces with the DataTools Kleber service
85
+ test_files: []