Class: AusPostAPI::PAC::Endpoint

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/aus_post_api/pac/endpoint.rb

Overview

Abstract class that defines a PAC::Endpoint. It implements the ‘uri` & `headers` methods and expects the `api_uri` method to be implemented.

Defined Under Namespace

Classes: ImplementationError, InvalidFormatError, NoAuthKeyProvidedError, NoFormatProvidedError

Constant Summary collapse

LIVE_URI =
'https://auspost.com.au/api'
TEST_URI =
'https://test.npe.auspost.com.au'
TEST_KEY =
'28744ed5982391881611cca6cf5c240'
FORMATS =
['json', 'xml']

Instance Method Summary collapse

Methods inherited from Endpoint

#execute, #initialize

Methods included from Endpoint::Attributes

included

Constructor Details

This class inherits a constructor from AusPostAPI::Endpoint

Instance Method Details

#headersObject



15
16
17
# File 'lib/aus_post_api/pac/endpoint.rb', line 15

def headers
  { "AUTH-KEY" => @config[:TEST] ? TEST_KEY : auth_key }
end

#uriObject



11
12
13
# File 'lib/aus_post_api/pac/endpoint.rb', line 11

def uri
  "#{base_uri}/#{api_uri}.#{format}?#{params}"
end