General Online Reference

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help

GetCustomer [GET]

The GetCustomer operation retrieves a customer from the shop based on a unique customer number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a customer number (id) for the customer

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the customer number cannot be null

The customer READ permission is required to perform this operation.

Output

When successful the operation returns a customer.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/GetCustomer

Code examples

C# (Console)

var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var id = "83";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService";
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + id);
try {
	var response =  (HttpWebResponse)request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$endpoint_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Customernumber of existing customer
$customer_id = 83;

$curl = curl_init($service_url . $api_key . "/" . $customer_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);

 

 

GetCustomerByEmail [GET]

The GetCustomerByEmail operation retrieves a customer from the shop based on an email address.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • an email address

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the email address cannot be null

The customer READ permission is required to perform this operation.

Output

When successful the operation returns a customer.

The first customer record is returned (sorted by id ascending) in case of duplicates.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/GetCustomerByEmail

Code examples

C# (Console)

var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var email = "test@test.dk";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService.svc/GetCustomerByEmail";
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + email);
try
{
	var response = (HttpWebResponse) request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService.svc/GetCustomerByEmail";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Email of existing customer
$customer_email = 'test@test.dk';

$curl = curl_init($service_url . '/' . $api_key . '/' . $customer_email);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);

 

 

CreateCustomer [POST]

The CreateCustomer operation creates a new customer in the shop.

Input

The operation takes the following input:

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the customer must be valid, ie.:
    • the name cannot be null
    • the address cannot be null
    • the zipcode cannot be null
    • the city cannot be null
    • the country id cannot be null
    • the email address cannot be null
    • the email address must have a valid format (see below)
    • the password cannot be null

Depending on the shop settings it may not be possible to create customers with duplicate email addresses.

The format of the email address is checked with the regular expression “[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}”.

The customer CREATE permission is required to perform this operation.

Output

When successful the operation returns a customer.

The result will contain the unique customer number assigned to the new customer.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/CreateCustomer

Code examples

C# (Console)

var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService";
var password = Guid.NewGuid();
var customer = new
	{
		address = "Test address 2",
		address2 = "",
		attention = "Test Attention",
		city = "TestCity",
		comments = "Comment to customer",
		countryId = 2397,
		email = "test@test.dk",
		fax = "88888888",
		name = "Test name",
		password = password.ToString(),
		phone = "88888888",
		zipcode = "8888",
                b2bGroupId = 0
	};
var jSon = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(customer);
var request = WebRequest.Create(endpointUrl + "/" + key);
request.Method = "POST";
request.ContentType = "text/json";
using (var writeStream = new StreamWriter(request.GetRequestStream()))
{
	writeStream.Write(jSon);
	writeStream.Flush();
	writeStream.Close();
}
try
{
	var response = (HttpWebResponse) request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurlo}/admin/webapi/Endpoints/v1_0/CustomerService";
//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
//Data for new customer 
$customer = array ( "address" => "Test address 2",
		"address2" => "",
		"attention" => "Test Attention",
		"city" => "TestCity",
		"comments" => "Comment to customer",
		"countryId" => 2397,
		"email" => "testx@test.dk",
		"fax" => "88888888",
		"name" => "Test name",
		"password" => "testpassword",
		"phone" => "88888888",
		"zipcode" => "8888",
                "b2bGroupId" => "0"
	);

$data_string = json_encode($customer);
$ch = curl_init($service_url . '/' . $api_key);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
var_export($result);

 

 

UpdateCustomer [PUT]

The UpdateCustomer operation updates an existing customer in the shop.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a customer number (id) for the customer
  • a customer

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the customer number cannot be null
  • the customer must be valid, ie.:
    • the name cannot be null
    • the address cannot be null
    • the zipcode cannot be null
    • the city cannot be null
    • the country id cannot be null
    • the email address cannot be null
    • the email address must have a valid format (see below)
    • the password cannot be null

Depending on the shop settings it may not be possible to update customers with duplicate email addresses.

The format of the email address is checked with the regular expression “[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}”.

The customer UPDATE permission is required to perform this operation.

Output

When successful the operation returns true, otherwise false.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/UpdateCustomer

Code examples

C# (Console)

var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService.svc";
var customerId = 86;
var password = Guid.NewGuid();
var customer = new
{
	id = customerId,
	address = "Test address",
	address2 = "",
	attention = "Test Attention",
	city = "TestCity",
	comments = "Comment to customer",
	countryId = 2397,
	email = "testx@test.dk",
	fax = "88888888",
	name = "Test name Updated",
	password = password.ToString(),
	phone = "88888888",
	zipcode = "8888"
};
var jSon = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(customer);
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + customerId);
request.Method = "PUT";
request.ContentType = "application/json";
using (var writeStream = new StreamWriter(request.GetRequestStream()))
{
	writeStream.Write(jSon);
	writeStream.Flush();
	writeStream.Close();
}
try
{
	var response = (HttpWebResponse)request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php 
//Endpoint url 
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService";
//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
//Customernumber of existing customer in the shop
$customer_id = 86;
//Data to update existing customer with
$customer = array ( "id" => $customer_id,
		"address" => "Test address 2",
		"address2" => "",
		"attention" => "Test Attention",
		"city" => "TestCity",
		"comments" => "Comment to customer",
		"countryId" => 2397,
		"email" => "testx@test.dk",
		"fax" => "88888888",
		"name" => "Test name",
		"password" => "testpassword",
		"phone" => "88888888",
		"zipcode" => "8888"
	);

$data_string = json_encode($customer);
$ch = curl_init($service_url . '/' . $api_key . '/' . $customer_id);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
var_export($result);

 

 

DeleteCustomer [DELETE]

The DeleteCustomer operation deletes a customer from the shop based on a unique customer number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a customer number (id) for the customer

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the customer number cannot be null

The customer DELETE permission is required to perform this operation.

Output

When successful the operation returns true.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/DeleteCustomer

Code examples

C# (Console)

var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var id = "86";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService";
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + id);
request.Method = "DELETE";
try
{
	var response = (HttpWebResponse) request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Customernumber of existing customer in the shop
$customer_id = 85;

$curl = curl_init($service_url . $api_key . "/" . $customer_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);

 

 

GetCustomerGroups [GET]

The GetCustomerGroups operation retrieves a complete list of customer groups from the shop.

Input

The operation takes the following input:

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)

The customer READ permission is required to perform this operation.

Output

When successful the operation returns a list of customer groups.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/GetCustomerGroups

Code examples

C# (Console)

var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService";
var request = WebRequest.Create(endpointUrl + "/" + key + "/CustomerGroup");
try
{
	var response = (HttpWebResponse) request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/CustomerService/";
//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

$curl = curl_init($service_url . $api_key . "/CustomerGroup");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//Make request
$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);

//Print to stdout
var_export($decoded);

 

 

UpdateCustomerDiscount[POST]

The UpdateCustomerDiscount operation updates discount specified for the customer

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a customer number (id) for the customer

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the customer number cannot be null

The customer UPDATE permission is required to perform this operation.

Output

The operation returns boolean.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/UpdateCustomerDiscount

 

 

GetCustomerDiscount[GET]

The GetCustomerDiscount operation gets discount specified for the customer

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a customer number (id) for the customer

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the customer number cannot be null

The customer READ permission is required to perform this operation.

Output

The operation returns details about the customer discount.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/CustomerService/help/operations/GetCustomerDiscount