ShapeDiver Viewer - Export API
The export api is part of the global API.
It allows to
- get the definition of currently registered exports,
- request exports, and
- add and remove listeners for related events.
Methods
-
addEventListener(type, callback)
-
Add a callback to be invoked when a certain event occurs
Parameters:
Name Type Description type
ExportEventType Type of event to subscribe to
callback
EventListenerCallback Function to be called when the event fires
Returns:
-
Type Description APIResponse APIResponse with an EventListenerToken object. The event listener token can be used to remove the event listener by calling removeEventListener.
-
-
get()
-
Get all export definitions
Returns:
-
Type Description APIResponse APIResponse with an array of export definitions
-
-
removeEventListener(token)
-
Remove an event listener
Parameters:
Name Type Description token
EventListenerToken event listener token for event listener to be removed
Returns:
-
Type Description APIResponse APIResponse with a Boolean data, indicating whether the event listener could be removed.
-
-
requestAsync(requestObject [, payload])
-
Requests an export for current parameter values.
Parameters:
Name Type Argument Description requestObject
ExportRequestObject Object defining the export request.
payload
* <optional>
Payload which will be passed through to the response and events related to a call of this function.
Returns:
-
Type Description Promise.<APIResponse> APIResponse with a export result object.
-
-
updateProperties( [definitions])
-
Update properties of registered exports.
The following properties can be updated: name, order, hidden This function will fail in case no unique export can be found for each export definition given.
Parameters:
Name Type Argument Description definitions
Array.<ExportDefinition> <optional>
updated export definitions
Returns:
-
Type Description APIResponse APIResponse with its data set to a boolean according to success or error
-
Members
-
<readonly> EVENTTYPE :ExportEventType
-
Enum for supported export event types.
Type:
Properties:
Name Type Default Description AVAILABLE
ExportEventType available the result of an export has become available
REGISTERED
ExportEventType registered a new export has been registered
UPDATE
ExportEventType update the definition of an export has been updated, typically one of the properties name or order or hidden
STATUS
ExportEventType status status event for an ongoing export
-
<readonly> RESULT :ExportRequestResult
-
Enum for export request result.
Type:
Properties:
Name Type Default Description EXPORT_NOT_FOUND
ExportRequestResult export_not_found the export was not found
PLUGIN_NOT_FOUND
ExportRequestResult plugin_not_found the plugin responsible to handle the export request was not found
ERROR
ExportRequestResult error the export request failed
CACHE
ExportRequestResult cache the export request can be answered from the local cache
LOAD
ExportRequestResult load the export request needs to be loaded from somewhere
Type Definitions
-
ExportDefinition
-
Definition of an export
Type:
- Object
Properties:
Name Type Argument Description id
String unique id of export
plugin
String plugin runtime id of export
name
String name of export
_name
String <optional>
original name of the export, will be set in case the export name got changed from its original value
type
String type of export, currently we support 'email', 'download', and 'shapeways'
hidden
Boolean <optional>
must exist and be true if the export should be hidden from the ui
order
Number <optional>
optional number used for ordering exports in the ui
-
ExportEventType
-
Export event type, see EVENTTYPE for values
Type:
- String
-
ExportRequestObject
-
Data required for requesting an export
Type:
- Object
Properties:
Name Type Argument Default Description id
String <optional>
id of export, takes precedence over idOrName and name
idOrName
String <optional>
id or name of export, takes precedence over name
name
String <optional>
name of export, last priority after id and idOrName
plugin
String <optional>
runtime id of plugin the export belongs to
silent
Boolean <optional>
false if true, do not display any information about the export to the user
-
ExportRequestResult
-
Export request result, see RESULT for values
Type:
- String
-
ExportResult
-
Definition of the object resulting from a finished export, or from a status of an ongoing export
Type:
- Object
Properties:
Name Type Argument Description id
String unique id of the export
plugin
String plugin runtime id of export
name
String name of the export
type
String type of export, currently we support 'email', 'download', and 'shapeways'
msg
String <optional>
optional status message for the export, e.g. describing server side progress or status
version
String <optional>
version id of the export
filename
String <optional>
optional filename to be used for files which are part of content (FILENAME.FILETYPE)
content
Array.<ExportResultContentItem> <optional>
will be set once the export has been finished for type 'download'. Typically this array has only one entry.
result
Object <optional>
optional object describing the result of the export for types 'email' and 'shapeways'
Properties
Name Type Argument Description msg
String <optional>
optional message to display to the user
err
String <optional>
optional error message to display to the user
href
String <optional>
optional link to direct the user to
modelId
String <optional>
optional ShapeWays model id
resultcode
ExportRequestResult <optional>
result code
-
ExportResultContentItem
-
Export content item of a ExportResult
Type:
- Object
Properties:
Name Type Description format
String format of the exported file, e.g. stl|3dm|dxf|dwg|…
href
String download link to the exported file, time limited to the duration of the session
size
Number size in bytes of the exported file