postcodepy proxy API¶
Django App to the postcode.nl REST-service¶
This app make use of the postcodepy
module. For details, see: postcode-api-wrapper.readthedocs.org.
-
class
postcodepy_proxy.views.
PostcodepyProxyView
(**kwargs)¶ Bases:
django.views.generic.base.View
PostcodeProxyView - base View class to render a postcode API response.
derive your own View from this class to render postcode API responses.
-
__init__
(**kwargs)¶ Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
as_view
(**initkwargs)¶ Main entry point for a request-response process.
-
get
(request, postcode=None, houseNumber=None, houseNumberAddition=None)¶ get - fetch ‘adres-info’ by ‘postcode/huisnummer’.
Parameters: - request (request) – the django request object
- postcode (str) – postcode formatted as 4 digits 2 characters (no space), ex: 7514BP
- houseNumber (int) – housenumber without additions
- houseNumberAddition (str (optional)) – the housenumber addition as a string. Mostly one character (7514BP,129,A), but also numerical additions may apply (8651AP,1,41).
-
options
(request, *args, **kwargs)¶ Handles responding to requests for the OPTIONS HTTP verb.
-
-
class
postcodepy_proxy.views.
SignalProxyView
(**kwargs)¶ Bases:
django.views.generic.base.View
SignalProxyView - base View class to render a signal API response.
derive your own View from this class to render signal API responses.
-
__init__
(**kwargs)¶ Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
-
as_view
(**initkwargs)¶ Main entry point for a request-response process.
-
get
(request, sar)¶ get - fetch ‘signal-info’ based on specified set of parameters.
Parameters: sar (dict) – the signal-api-request (sar), being a dictionary of parameters relevant for the request. Since all parameters are optional, please take a look at the API documentation: https://api.postcode.nl/documentation
-
options
(request, *args, **kwargs)¶ Handles responding to requests for the OPTIONS HTTP verb.
-
-
class
postcodepy_proxy.signalapi.
SignalRequestData
(_d=None, delimiter=None)¶ Bases:
object
SignalRequestData - map flat formatted structure to nested structure.
Class to map for instance posted form data to a nested dictionary structure. This can be done when fields are named using a convention like: name1_name2_name3, but also: name1.name2.name3 .
Example:
sarArgs = { "customer_email": "test-address@postcode.nl", "customer_phoneNumber": "+31235325689", "customer_address_postcode": "2012ES", "customer_address_houseNumber": "30", "customer_address_country": "NL", "transaction_internalId": "MyID-249084", "transaction_deliveryAddress_postcode": "7514BP", "transaction_deliveryAddress_houseNumber": "129", "transaction_deliveryAddress_houseNumberAddition": "B", "transaction_deliveryAddress_country": "NL" }
with:
print(json.dumps(SignalRequestData(sarArgs)(), sort_keys=True, indent=2))
will be mapped to:
{ "customer": { "address": { "country": "NL", "houseNumber": "30", "postcode": "2012ES" }, "email": "test-address@postcode.nl", "phoneNumber": "+31235325689" }, "transaction": { "deliveryAddress": { "country": "NL", "houseNumber": "129", "houseNumberAddition": "B", "postcode": "7514BP" }, "internalId": "MyID-249084" } }
-
__init__
(_d=None, delimiter=None)¶ Instantiate a SignalRequestData object.
Parameters: d ((dict) optional) –
-