The WebAPIs provides a set of basic definitions and interfaces that are used in other Device APIs. The Web API contains filters and sorting modes for query methods, generic success and error event handlers, a generic error interface, and a simple coordinate interface for defining location information.
The main features of the Web API include:
- Filters
You can use filters to search for specific data, limit query results, and make complex queries. The Web API supports the following filter types, which are subtypes of the abstract filter:
- Attribute filter
Matches objects containing a defined attribute or attribute value. The match is determined based on match flags defined with the FilterMatchFlag type definition.
- Attribute range filter
Matches objects containing an attribute whose values are within a particular range.
- Composite filter
Combines several filters into a set.
The attributes you can use with the filter types vary depending on the API you are using. For example, Calendar, Callhistory, Contact, Content, and Messaging query methods each have their own sets of supported filter attributes.
- Attribute filter
- Sorting
You can sort the results of queried data using the SortMode interface. The following sorting modes are supported:
-
"ASC": Ascending sorting order
-
"DESC": Descending sorting order
-
- Location information
You can use the SimpleCoordinates interface to incorporate location information into your application. For example, you can simply use it to define coordinates:
var coordinates = new webapis.SimpleCoordinates(37.5665, 126.9779);
You can also define a latitude and longitude for a calendar event:
var event = new webapis.CalendarEvent( { description:"hospital", geolocation: {latitude: 37.48894320, longitude: 127.08764240}, startDate: new webapis.TZDate(2011, 11, 1, 14, 0), duration: new webapis.TimeDuration(2, "HOURS") });
- Generic error handling
You can throw errors synchronously, or return them in the error event handlers of asynchronous methods, using the WebAPIError interface.
Note Do not use the code attribute of the WebAPIError interface to distinguish errors, because the code of the exception object is set to 0 in case of new error types that are not defined in DOMException. - Generic event handling
You can handle the results of asynchronous operations with the SuccessCallback and ErrorCallback event handlers. The generic event handlers can be used with methods that do not require a return value.