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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b1ef091fc8e8fc107d19409cf3a7f3992ed1893
4
- data.tar.gz: 2dc5135d7e9bc5b26e173520bc6ae44351f41ae7
3
+ metadata.gz: af7c6a247863353961428931de7c84ea63f3441b
4
+ data.tar.gz: b5d338efdbbef71ea854b7b0b15f6c678b3a4a7f
5
5
  SHA512:
6
- metadata.gz: 478371189884256eca849d98985041a2defc4b66dd35fc145afdc226dca28f21121bf66aa2ae99465a6b18c18d43fde6feba5804805213a8e293658df1a60884
7
- data.tar.gz: 1c693c6c0d4863ac43ae8005fe2244f83f476252cda28f45b977edb9fe30e90d41145aaac94c66a480f0b6fe82ed81381c625104863b7454d270f742c40fcfb1
6
+ metadata.gz: 955b77d96e5e720e8fb4f96d3859a25ddef1f905d0fd804f15208109ef1eeebb090281490ad1c054e5da9d80ef87e7cdfd3e250342eeba532948d9cd998222d3
7
+ data.tar.gz: 8a1aa668fa1fa92af9f5e5d5281a449b4a0102aae9cc8a5f7b5bc049779a7ae76daea655165ae4cb9151058b2218c7a826ea0ce2e1cd0f2d5e9945bee776b4f3
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ gemspec
6
6
  gem 'rspec'
7
7
  gem 'autotest'
8
8
  gem 'json'
9
+ gem 'cgi'
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
- class Client
9
- attr_accessor :aupost_key
10
- def initialize(aupost_key)
11
- self.aupost_key = aupost_key
12
- end
13
-
14
- def domestic_postcode_search(text, state = "", format = "json")
15
- uri = URI("#{Aupost::AUPOST_URL}/postcode/search.#{format}?q=#{text}&state=#{state}")
16
- req = Net::HTTP::Get.new(uri)
17
- req['AUTH-KEY'] = @aupost_key
18
- Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
19
- return http.request(req).read_body
20
- end
21
-
22
- end
23
-
24
- def country(format = "json")
25
- uri = URI("#{Aupost::AUPOST_URL}/postage/country.#{format}")
26
- req = Net::HTTP::Get.new(uri)
27
- req['AUTH-KEY'] = @aupost_key
28
- Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
29
- return http.request(req).read_body
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
- end
34
+ end
32
35
 
33
- end
34
36
  end
@@ -1,5 +1,5 @@
1
1
  module Aupost
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  AUPOST_URL = "https://auspost.com.au/api"
4
4
 
5
5
  end
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.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