Skip to content
This repository was archived by the owner on May 11, 2020. It is now read-only.

Commit c7f84fd

Browse files
- Updated links
- The Signal Api has been deprecated, please use the Address api (PostcodeNl_Api_RestClient::lookupAddress() method).
1 parent 0149da2 commit c7f84fd

File tree

4 files changed

+28
-99
lines changed

4 files changed

+28
-99
lines changed

README.md

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Postcode.nl API REST Client
22
=============
33

4-
A PHP 5.2+ class, which offers methods to directly talk with the [Postcode.nl API](https://api.postcode.nl/documentation) through the REST endpoint offered.
5-
You will need to create an account with the [Postcode.nl API](https://api.postcode.nl) service.
4+
A PHP 5.3+ class, which offers methods to directly talk with the [Postcode.nl API](https://api.postcode.nl/documentation) through the REST endpoint offered.
5+
You will need to create an account with the [Postcode.nl API](https://services.postcode.nl/adresdata/api) service.
66

7-
Implements both the [Address service](https://api.postcode.nl/documentation/address-api-description) and the [Signal service](https://api.postcode.nl/documentation/signal-api-description).
7+
Implements both the [Address service](https://services.postcode.nl/adres-api) and the [Signal service](https://services.postcode.nl/adres-api/signaal).
88

99
License
1010
=============
@@ -25,8 +25,8 @@ Include the class in your PHP project, instantiate the PHP class with your authe
2525
You can handle errors by catching the defined Exception classes.
2626
(See the 'library/PostcodeNl/Api/RestClient.php' file for details on which exceptions can be thrown)
2727

28-
* See our [Address API description](https://api.postcode.nl/documentation/address-api-description) for more information
29-
* See our [Address API method documentation](https://api.postcode.nl/documentation/rest-json-endpoint#address-api) for the possible fields
28+
* See our [Address API description](https://services.postcode.nl/adresdata/api) for more information
29+
* See our [Address API method documentation](https://api.postcode.nl/documentation/address-api) for the possible fields
3030

3131
```PHP
3232
<?php
@@ -62,60 +62,4 @@ You can handle errors by catching the defined Exception classes.
6262

6363
// Print the address data
6464
echo var_export($address, true);
65-
```
66-
67-
Usage Signal API
68-
=============
69-
70-
Include the class in your PHP project, instantiate the PHP class with your authentication details and call the 'doSignalCheck' method.
71-
You can handle errors by catching the defined Exception classes.
72-
(See the 'library/PostcodeNl/Api/RestClient.php' file for details on which exceptions can be thrown)
73-
74-
* See our [Signal API description](https://api.postcode.nl/documentation/signal-api-description) for more information
75-
* See our [Signal API check method documentation](https://api.postcode.nl/documentation/rest-json-endpoint#signal-api) for the possible fields to pass.
76-
* See our [basic example](https://api.postcode.nl/documentation/signal-api-example) for a practical example
77-
78-
79-
```PHP
80-
<?php
81-
require_once('/PATH/TO/library/PostcodeNl/Api/RestClient.php';
82-
$client = new PostcodeNl_Api_RestClient('{your key}', '{your secret}');
83-
84-
// Do a Postcode.nl Signal check (information validation, enrichment and fraud warnings)
85-
try
86-
{
87-
$signalCheck = $client->doSignalCheck(
88-
array(
89-
// Customer information (see documentation)
90-
),
91-
array(
92-
// HTTP / Browser access information (see documentation)
93-
),
94-
array(
95-
// Transaction information (see documentation)
96-
),
97-
array(
98-
// Configuration for the signal services to use (see documentation)
99-
)
100-
);
101-
}
102-
catch (PostcodeNl_Api_RestClient_InputInvalidException $e)
103-
{
104-
die('We have input which can never return a valid signal check: '. $e);
105-
}
106-
catch (PostcodeNl_Api_RestClient_ClientException $e)
107-
{
108-
die('We have a problem setting up our client connection: '. $e);
109-
}
110-
catch (PostcodeNl_Api_RestClient_AuthenticationException $e)
111-
{
112-
die('The Postcode.nl API service does not know who we are: '. $e);
113-
}
114-
catch (PostcodeNl_Api_RestClient_ServiceException $e)
115-
{
116-
die('The Postcode.nl API service reported an error: '. $e);
117-
}
118-
119-
// Print the Signal Check info
120-
echo var_export($signalCheck, true);
121-
```
65+
```

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "postcode-nl/api-restclient",
3-
"description": "A client to the Postcode.nl API using the REST endpoint. Implements both the Address (Dutch address verification) and Signal (fraud warnings & data enrichment) API services. You will need to create an account at https://api.postcode.nl.",
4-
"keywords": ["postcode", "netherlands", "api", "rest", "client", "magento", "fraud", "address"],
3+
"description": "A client to the Postcode.nl Address API for Dutch address verification. You will need to create an account at https://api.postcode.nl.",
4+
"keywords": ["postcode", "netherlands", "api", "rest", "client", "magento", "address"],
55
"license": "BSD-2-Clause",
6-
"authors": [{"name": "Daan Broekhof", "role": "Developer"}],
6+
"authors": [{"name": "Maarten Scholder", "role": "Developer"}],
77
"homepage": "https://api.postcode.nl",
88
"support": {
99
"email": "[email protected]",
@@ -28,4 +28,4 @@
2828
"php": ">=5.3.3",
2929
"ext-curl": "*"
3030
}
31-
}
31+
}

library/PostcodeNl/Api/RestClient.php

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
obtain it through the world-wide-web, please send an email
1212
to [email protected] so we can send you a copy immediately.
1313
14-
Copyright (c) 2014 Postcode.nl B.V. (https://www.postcode.nl)
14+
Copyright (c) 2016 Postcode.nl B.V. (https://services.postcode.nl)
1515
*/
1616

1717
/**
@@ -68,7 +68,7 @@ class PostcodeNl_Api_RestClient
6868
/** (string) Default URL where the REST web service is located */
6969
const DEFAULT_URL = 'https://api.postcode.nl/rest';
7070
/** (string) Version of the client */
71-
const VERSION = '1.1.1.0';
71+
const VERSION = '1.1.2.0';
7272
/** (int) Maximum number of seconds allowed to set up the connection. */
7373
const CONNECTTIMEOUT = 3;
7474
/** (int) Maximum number of seconds allowed to receive the response. */
@@ -105,7 +105,7 @@ public function __construct($appKey, $appSecret, $restApiUrl = null)
105105
$this->_restApiUrl = $restApiUrl;
106106

107107
if (empty($this->_appKey) || empty($this->_appSecret))
108-
throw new PostcodeNl_Api_RestClient_ClientException('No application key / secret configured, you can obtain these at https://api.postcode.nl.');
108+
throw new PostcodeNl_Api_RestClient_ClientException('No application key / secret configured, you can obtain these at https://services.postcode.nl.');
109109

110110
if (!extension_loaded('curl'))
111111
throw new PostcodeNl_Api_RestClient_ClientException('Cannot use Postcode.nl API client, the server needs to have the PHP `cURL` extension installed.');
@@ -349,28 +349,7 @@ public function lookupAddress($postcode, $houseNumber, $houseNumberAddition = ''
349349
}
350350

351351
/**
352-
Perform a Postcode.nl Signal check on the given transaction and/or customer information.
353-
354-
Parameters:
355-
customer - (array) Data concerning a customer
356-
access - (array) Data concerning how a customer is accessing a service
357-
transaction - (array) Data concerning a transaction of a customer
358-
config - (array) Configuration for the signal check
359-
360-
Returns:
361-
(array) signals
362-
checkId - (string) Identifier of the check (22 characters)
363-
signals - (array) All signals, each signal is an array, containing:
364-
concerning - (string) Field this signal is about
365-
type - (string) Name of signal type, including vendor, service name and response type
366-
warning - (boolean) If this signal is significant.
367-
message - (string) Human readable explanation for the signal
368-
data - (array|null) Optional data of the signal. See documentation on website for data definitions of the specific signal types.
369-
warningCount - (int) Number of warnings found in signals
370-
reportPdfUrl - (string) URL to a report of the signal check
371-
372-
Reference:
373-
<https://api.postcode.nl/documentation>
352+
Deprecated, will be removed in the future. Please use lookupAddress instead.
374353
*/
375354
public function doSignalCheck(array $customer = null, array $access = null, array $transaction = null, array $config = null)
376355
{

www/index.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,24 @@
2424
<form method="POST">
2525
<fieldset>
2626
<legend>Authentication</legend>
27-
API url:<br />
28-
<input type="text" name="apiUrl" value="<?php echo isset($_POST['apiUrl']) ? htmlspecialchars($_POST['apiUrl']) : PostcodeNl_Api_RestClient::DEFAULT_URL; ?>" size="60"><br />
29-
API key:<br />
30-
<input type="text" name="key" value="<?php echo isset($_POST['key']) ? htmlspecialchars($_POST['key']) : ''; ?>" size="60"><br />
31-
API secret:<br />
32-
<input type="text" name="secret" value="<?php echo isset($_POST['secret']) ? htmlspecialchars($_POST['secret']) : ''; ?>" size="60"><br />
27+
<label>
28+
API url:<br />
29+
<input type="text" name="apiUrl" value="<?php echo isset($_POST['apiUrl']) ? htmlspecialchars($_POST['apiUrl']) : PostcodeNl_Api_RestClient::DEFAULT_URL; ?>" size="60">
30+
</label><br />
31+
<label>
32+
API key:<br />
33+
<input type="text" name="key" value="<?php echo isset($_POST['key']) ? htmlspecialchars($_POST['key']) : ''; ?>" size="60">
34+
</label><br />
35+
<label>
36+
API secret:<br />
37+
<input type="text" name="secret" value="<?php echo isset($_POST['secret']) ? htmlspecialchars($_POST['secret']) : ''; ?>" size="60">
38+
</label><br />
3339
</fieldset>
3440
<br />
3541
<b>Select service:</b><br />
3642
<select name="service">
37-
<option value="Address" <?php echo isset($_POST['service']) && $_POST['service'] == 'Address' ? 'selected' : '' ?>>Postcode.nl Address API: Address lookup</option>
38-
<option value="Signal" <?php echo isset($_POST['service']) && $_POST['service'] == 'Signal' ? 'selected' : '' ?>>Postcode.nl Signal API: Check</option>
43+
<option value="Address" <?php echo !isset($_POST['service']) || $_POST['service'] == 'Address' ? 'selected' : '' ?>>Postcode.nl Address API: Address lookup</option>
44+
<option value="Signal" <?php echo isset($_POST['service']) && $_POST['service'] == 'Signal' ? 'selected' : '' ?>>Postcode.nl Signal API: Check (deprecated)</option>
3945
</select> <input type="submit" value="Select"><br />
4046
<br />
4147
<?php if (isset($_POST['service']) && $_POST['service'] == "Address") {?>

0 commit comments

Comments
 (0)