SetupClientResource
Contents
What can I do here?
The SetupClientResource is one of the APIs of the platform. With the SetupClientResource, you can create customers automatically.
The API communicates in JSON.
Who can use the SetupClientResource?
Any partner user. Authentication is done using your username and password. NOTE: Administrative partner users cannot do this.
What data does the API need
The following data is required
Personal details:
- company name
- first name
- last_name
These are the basic details of your company name, and someone we can contact.
The email address will also be the customer's login name.
Country:
In which country the customer is located.
blocked_call_permissions:
- AMUSEMENT
- ASSISTENCE
- COMMUNICATION
- EROTICA
- INFORMATION_FREE
- INFORMATION_PAID
- INTERNATIONAL
- NATIONAL_FIXED
- NATIONAL_MOBILE
- NATIONAL_UNKNOWN
Optional, the types of numbers that CANNOT be set in the account forms.
When this is not specified, the default value is set, this default value is Amusement (0909), and Erotica (0906).
The following data can only be sent if there is a Twinfield connection.
Address details:
- street
- number
- zipcode
- city
Where your company is located and which address we put on the invoice.
Invoice details:
- account_holder
- account_number
From which account we can collect the invoice.
duedays:
How many days until payment is due.
invoice_email_address:
To which email address the invoice is sent.
payavailable:
Whether or not there is automatic direct debit.
Example usage of the API
The source code of "setup_client.php":
<?php
if
(count($argv) !== 3) {
exit
("Please use: setup_client.php <username> <password>
\n
");
}
// Setup en encode the password string.
$userName = $argv[1];
$password = $argv[2];
$encodedPassword = 'Authorization: Basic '
. base64_encode("
${
userName}:${password
}
");
print
("
$encodedPassword\n
");
$json = <<<'EOD'
{
"companyname": "VoIPGRID",
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@voipgrid.nl",
"street": "Lubeckweg",
"number": "2",
"zipcode": "9723 HE",
"city": "Groningen",
"country": "NL",
"account_holder": "VoIPGRID",
"account_number": "NL43INGB0659551425",
"duedays": "21",
"invoice_email_address": "john.doe@voipgrid.nl",
"payavailable": "False",
"blocked_call_permissions": [
"AMUSEMENT",
"ASSISTENCE",
"COMMUNICATION",
"EROTICA",
"INFORMATION_FREE",
"INFORMATION_PAID",
"INTERNATIONAL",
"NATIONAL_FIXED",
"NATIONAL_MOBILE",
"NATIONAL_UNKNOWN"
]
}
EOD;
// Setup curl.
$curl = curl_init();
// Set up the curl headers.
$http_headers = [
// tell the API we provide JSON data
'Content-Type: application/json',
// tell the API we want JSON data
'Accept: application/json',
// authenticate using the string created earlier
$encodedPassword,
];
curl_setopt_array($curl, [
CURLOPT_HTTPHEADER => $http_headers,
CURLOPT_URL => 'https://partner.voipgrid.nl/api/apprelation/setupclient/',
CURLOPT_POSTFIELDS => $json,
CURLOPT_POST =>
true
,
CURLOPT_RETURNTRANSFER =>
true
,
]);
// Make the request.
$response = curl_exec($curl);
print_r(json_decode($response,
true
));