class AusPostAPI::PAC::Endpoint
Abstract class that defines a PAC::Endpoint
. It implements the ‘uri` & `headers` methods and expects the `api_uri` method to be implemented.
Constants
- FORMATS
- LIVE_URI
- TEST_KEY
- TEST_URI
Public Instance Methods
headers()
click to toggle source
# File lib/aus_post_api/pac/endpoint.rb, line 15 def headers { "AUTH-KEY" => @config[:TEST] ? TEST_KEY : auth_key } end
uri()
click to toggle source
# File lib/aus_post_api/pac/endpoint.rb, line 11 def uri "#{base_uri}/#{api_uri}.#{format}?#{params}" end
Private Instance Methods
api_uri()
click to toggle source
# File lib/aus_post_api/pac/endpoint.rb, line 21 def api_uri raise ImplementationError.new('api_uri') end
auth_key()
click to toggle source
# File lib/aus_post_api/pac/endpoint.rb, line 47 def auth_key if @config[:PAC_AUTH_KEY].nil? && !@config[:TEST] raise NoAuthKeyProvidedError end @config[:PAC_AUTH_KEY] end
base_uri()
click to toggle source
# File lib/aus_post_api/pac/endpoint.rb, line 25 def base_uri @config[:TEST] ? TEST_URI : LIVE_URI end
format()
click to toggle source
# File lib/aus_post_api/pac/endpoint.rb, line 29 def format if @config[:FORMAT].nil? raise NoFormatProvidedError else if !FORMATS.include?(@config[:FORMAT]) raise InvalidFormatError else @config[:FORMAT] end end end
params()
click to toggle source
# File lib/aus_post_api/pac/endpoint.rb, line 41 def params [].tap { |result| @attributes.keys.each { |a| result << "#{a}=#{self.send(a)}" } }.join('&') end