aupost 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/aupost.rb +26 -24
- data/lib/aupost/version.rb +1 -1
- metadata +1 -2
- data/aupost-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af7c6a247863353961428931de7c84ea63f3441b
|
4
|
+
data.tar.gz: b5d338efdbbef71ea854b7b0b15f6c678b3a4a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 955b77d96e5e720e8fb4f96d3859a25ddef1f905d0fd804f15208109ef1eeebb090281490ad1c054e5da9d80ef87e7cdfd3e250342eeba532948d9cd998222d3
|
7
|
+
data.tar.gz: 8a1aa668fa1fa92af9f5e5d5281a449b4a0102aae9cc8a5f7b5bc049779a7ae76daea655165ae4cb9151058b2218c7a826ea0ce2e1cd0f2d5e9945bee776b4f3
|
data/Gemfile
CHANGED
data/lib/aupost.rb
CHANGED
@@ -1,34 +1,36 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
3
|
require "aupost/version"
|
4
|
+
require "cgi"
|
4
5
|
|
5
6
|
#require "aupost/configuration"
|
6
7
|
|
7
8
|
module Aupost
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
9
|
+
class Client
|
10
|
+
attr_accessor :aupost_key
|
11
|
+
def initialize(aupost_key)
|
12
|
+
self.aupost_key = aupost_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def domestic_postcode_search(text, state = "")
|
16
|
+
|
17
|
+
call URI("#{Aupost::AUPOST_URL}/postcode/search.json?q=#{CGI.escape(text)}&state=#{CGI.escape(state)}")
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
def country(format = "json")
|
23
|
+
call URI("#{Aupost::AUPOST_URL}/postage/country.json")
|
24
|
+
end
|
25
|
+
|
26
|
+
def call(uri)
|
27
|
+
req = Net::HTTP::Get.new(uri)
|
28
|
+
req['AUTH-KEY'] = @aupost_key
|
29
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
30
|
+
return JSON.load(http.request(req).read_body)
|
31
|
+
end
|
32
|
+
|
30
33
|
end
|
31
|
-
|
34
|
+
end
|
32
35
|
|
33
|
-
end
|
34
36
|
end
|
data/lib/aupost/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aupost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyson Cung
|
@@ -53,7 +53,6 @@ files:
|
|
53
53
|
- LICENSE.txt
|
54
54
|
- README.md
|
55
55
|
- Rakefile
|
56
|
-
- aupost-0.1.0.gem
|
57
56
|
- aupost.gemspec
|
58
57
|
- bin/console
|
59
58
|
- bin/setup
|
data/aupost-0.1.0.gem
DELETED
Binary file
|