class Aupost::Client
Attributes
aupost_key[RW]
Public Class Methods
new(aupost_key)
click to toggle source
# File lib/aupost.rb, line 11 def initialize(aupost_key) self.aupost_key = aupost_key end
Public Instance Methods
call(uri)
click to toggle source
# File lib/aupost.rb, line 64 def call(uri) req = Net::HTTP::Get.new(uri) req['AUTH-KEY'] = @aupost_key Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| return JSON.load(http.request(req).read_body) end end
country(format = "json")
click to toggle source
# File lib/aupost.rb, line 22 def country(format = "json") call URI("#{Aupost::AUPOST_URL}/postage/country.json") end
domestic_letter_size()
click to toggle source
# File lib/aupost.rb, line 34 def domestic_letter_size call URI("#{Aupost::AUPOST_URL}/postage/letter/domestic/size.json") end
domestic_letter_thickness()
click to toggle source
# File lib/aupost.rb, line 26 def domestic_letter_thickness call URI("#{Aupost::AUPOST_URL}/postage/letter/domestic/thickness.json") end
domestic_letter_weight()
click to toggle source
# File lib/aupost.rb, line 30 def domestic_letter_weight call URI("#{Aupost::AUPOST_URL}/postage/letter/domestic/weight.json") end
domestic_parcel_type()
click to toggle source
# File lib/aupost.rb, line 50 def domestic_parcel_type call URI("#{Aupost::AUPOST_URL}/postage/parcel/domestic/type.json") end
domestic_parcel_weight()
click to toggle source
# File lib/aupost.rb, line 46 def domestic_parcel_weight call URI("#{Aupost::AUPOST_URL}/postage/parcel/domestic/weight.json") end
domestic_postcode_search(text, state = "")
click to toggle source
# File lib/aupost.rb, line 15 def domestic_postcode_search(text, state = "") call URI("#{Aupost::AUPOST_URL}/postcode/search.json?q=#{CGI.escape(text)}&state=#{CGI.escape(state)}") end
international_letter_weight()
click to toggle source
# File lib/aupost.rb, line 38 def international_letter_weight call URI("#{Aupost::AUPOST_URL}/postage/letter/international/weight.json") end
international_parcel_weight()
click to toggle source
# File lib/aupost.rb, line 42 def international_parcel_weight call URI("#{Aupost::AUPOST_URL}/postage/parcel/international/size.json") end
postage_letter_domestic_service()
click to toggle source
# File lib/aupost.rb, line 58 def postage_letter_domestic_service call URI("#{Aupost::AUPOST_URL}/postage/parcel/domestic/size.json") end