1.4 Customer API

1.4.1 Create Customer

Syntax

createCustomer (String username, String emailAddress, String firstname, String lastname, HashMap fieldValues)

Description

This API is used to create new customers in Service Desk.

If the Create Account option is enabled in the application’s setup, this function does not require the User to be logged in.

Parameters

The following are the input parameters for this API:

  1. username: A new user name for this account.

  2. emailAddress: Email address for this user.

  3. firstname: First name of the user.

  4. lastname: Last name of the user.

  5. fieldValues: HashMap of the field values to populate this new account with.

NOTE:All four input parameters are mandatory and have to be unique. Omitting any of these will result in a failure message explaining the cause.

Return Value

This API returns a HashMap containing two fields: success and message.

The values returned in the two fields of the HashMap are:

  1. The value returned in the success field will be a string representation of a boolean (true or false) indicating whether or not the Customer creation attempt was successful.

  2. The value returned in the message field will be a String representation of the new Customer’s ID number.

    NOTE:Make a note of the returned customer number for subsequent web service requests.

1.4.2 Find Customer

Syntax

findCustomer (String emailAddress)

findCustomer (String firstname, String lastname)

findCustomer (String emailAddress, String firstname, String lastname)

findCustomer (String username, String emailAddress, String firstname, String lastname, HashMap customFields)

Description

This API is used to search for a Customer.

Parameters

The following are the input parameters for this API:

  1. Username: User name for this search. It can be either an LDAP user name or a System user name, which uses Service Desk’s built-in authentication.

  2. emailAddress: Email address for this search.

  3. firstname: First name of user to search for.

  4. lastname: Last name of user to search for.

  5. customFields: HashMap of field values to locate this customer.

Return Value

This API returns a HashMap which contains a list of HashMap for each entry. The key of the first map is the Customer ID of the returned user, the HashMap for that entry contains four string fields representing the Customer’s Last Name, Org Unit, Primary E-mail Address and First Name. A null is permitted when using multiple parameter based functions.

Example

function findUser($username,$email,$first,$last) { global $objClient; global $baseService; //switch to the customer api $objClient->SoapClient($baseService . "Customer?wsdl", array('trace' => true)); echo "Searching for " . $username . $email . $first . $last . "n"; # Call findCustomer, using an email address and echo out response # username, email, first, last $results = $objClient->findCustomer($username,$email,$first,$last); $success = $results['success']; if ($success=="false") { echo $results['message'] . "n"; return; } # if we have results lets show them # returns an array of arrays foreach(array_values($results) as $ess) { print_r($ess); }}

1.4.3 Delete Customer

Syntax

deleteCustomerById (String customerId)

deleteCustomerByUsername (String username)

Description

This API is used to delete a Customer. The Customer ID or User name is required and the account will be locked out if the request is successful.

Parameters

The following are the input parameters for this API:

  1. customerId: The unique customer ID of the account.

  2. username: The unique user name of the account.

Return Value

This API returns a HashMap containing the success flag and a message if the request was unsuccessful.

1.4.4 Undelete Customer

Syntax

undeleteCustomerById (String customerId)

undeleteCustomerByUsername (String username)

Description

This API is used to undelete a customer. The Customer ID or user name is required and the account will be re- activated if the request is successful.

Parameters

The following are the input parameters for this API:

  1. customerId: The unique customer ID of the account.

  2. username: The unique user name of the account.

Return Value

This API returns a HashMap containing the success flag and a message if the request was unsuccessful.

1.4.5 Get Customer Information

Syntax

getFieldsForCustomer (String customerId)

Description

This API is used to get the Customer details to the logged in user, based on the supplied Customer ID.

Parameters

The following are the input parameters for this API:

  1. customerId: The unique customer ID of the account.

Return Value

The returned HashMap contains fields that the system knows about the user like First Name, Last Name, Username and contact information.

Note that phone2 refers to the mobile/cell phone number in the LiveTime user interface, and phone3 refers to the fax number as defined in the GUI.

Custom Fields are defined in the administration area of Service desk. When retrieving these fields, they will be returned with the label defined in the custom field, but when calling update methods, these must be passed using the underlying variable name, being custom1 through custom5.

1.4.6 Get Country information

Syntax

getCountries ()

Description

This API is used to return a list of all the Countries.

Parameters

None

Return Value

This API returns a HashMap which contains another HashMap for each entry. The key of the first map is the Country ID of the returned Country, the Map for that entry contains two string fields representing the Country Name and Top Level Domain (TLD).

1.4.7 Get State Information

Syntax

getStatesForCountry (String countryId)

Description

This API is used to search for states or provinces of a Country.

Parameters

The following are the input parameters for this API:

  1. countryId: The unique country ID.

Return Value

This API returns a HashMap containing the State ID and the State Name for each State of the searching Country.

1.4.8 Find Country

Syntax

findCountry (String countryName, String tld)

Description

This API is used to search for a Country, based on either the Country Name or Top Level Domain.

Parameters

The following are the input parameters for this API:

  1. countryName: The unique country name for the search.

  2. tld: The unique Top Level Domain used for the search.

Return Value

This API returns a HashMap containing another HashMap for the Country. The key of the first map is the Country ID of the returned Country, the Map for that entry contains two string fields representing the Country Name and Top Level Domain.

1.4.9 Update Customer

Syntax

updateCustomerById (String customerId, HashMap values)

updateCustomerByUsername (String username, HashMap values)

Description

This API allows logged in users to update Customer information.

Parameters

The following are the input parameters for this API:

  1. customerId: The unique customer ID for the account.

  2. username: The unique user name for the account.

  3. values: The HashMap of values to set for this customer.

Return Value

The fields returned from the ‘get’ equivalent (firstname, lastname, email, address, city, state, etc) can all be inserted into the HashMap that is sent to LiveTime to set new values for those fields.

The returned HashMap will contain success and message values.

The values HashMap is a map of Strings to Strings. Valid keys for Customer web services are the same as those returned in the getFieldsForCustomer method, specifically: firstName, lastName, userName, password, email, orgUnit, address, addressTwo, city, state, country, postalCode, phone, phone2, phone3, webAccess, aliases, emailNotify.

All values should be strings, webAccess and emailNotify should be a 1 or a 0 expressed as a String, and aliases can be a comma-separated list.

1.4.10 Update Location

Syntax

updateLocation (String latitude, String longitude)

Description

This API allows logged in users to update their geographical coordinates by specifying latitude and longitude values.

Parameters

The following are the input parameters for this API:

  1. latitude: The geographical latitude coordinate of the logged in account.

  2. longitude: The geographical longitude coordinate of the logged in account.

Return Value

None

1.4.11 Get Geo Location

Syntax

getGeoLocation (String customerId)

Description

This API retrieves the geo location for the given customer ID.

Parameters

The following are the input parameters for this API:

  1. customerId: The unique customer Id for the account.

Return Value

None