NodeJS module for interacting with the Screendoor API via the Request module.
http://dobtco.github.io/screendoor-api-docs/
- GET /sites/:site_id/projects
- GET /sites/:site_id/projects/:project_id
- GET /projects/:project_id/response_fields
- GET /projects/:project_id/responses/:response_id
- PUT /projects/:project_id/responses/:response_id
- POST /projects/:project_id/responses
- POST /form_renderer/
var ScreendoorAPI = require( 'screendoor-api-node' ),
scrndr = new ScreendoorAPI( api_key ),
scrndr.getSiteProjects( site_id, function( err, projects ){
if ( null !== err ) {
return callback( err, null );
}
return callback( null, projects );
} );
scrndr.getProject( site_id, project_id, function( err, project ){
if ( null !== err ) {
return callback( err, null );
}
return callback( null, project );
} );
scrndr.getProjectFields( project_id, function( err, fields ){
if ( null !== err ) {
return callback( err, null );
}
return callback( null, fields );
} );
scrndr.getProjectResponse( project_id, response_id, format, function( err, result ){
if ( null !== err ) {
return callback( err, null );
}
return callback( null, result );
} );
var response_fields = {
"1": "Test Name",
"2": "[email protected]",
"3": "New application for your job on Startuply"
};
var options = {
'skip_email_confirmation': true,
'skip_notifications': true,
'skip_validation': true
};
scrndr.setProjectResponse( project_id, response_fields, options, function( err, result ){
if ( null !== err ) {
return callback( err, null );
}
return callback( null, result );
} );
Note: Arrays do not currently work as POST values, so labels cannot be sent through Set Project Response. However they can be used with Update Project Response.
var response_fields = {
"1": "Test Name",
"2": "[email protected]",
"3": "New application for your job on Startuply"
};
var options = {
force_validation : false,
labels : ['test'],
status : 'Open'
};
scrndr.updateProjectResponse( project_id, response_id, response_fields, options, function( err, result ){
if ( null !== err ) {
return callback( err, null );
}
return callback( null, result );
});
scrndr.uploadFile( field_id, encoded_file, file_options, function( err, result ) {
if ( null !== err ) {
return callback( err, null );
}
return callback( null, result );
} );
encoded_file
should be the Base64 encoded content of the file you want to upload, with everything before the comma removed. Ex:
var encoded_file_parts = uploaded_file.split( ',' ),
encoded_file = encoded_file_parts[1];
file_options
should be an Object containing the filename and the content-type. You can extract the content-type from the Base64 encoded file. Ex:
var matches = encoded_file_parts[0].match( /data:([^;]*);base64/ ),
file_options = {
contentType: matches[1],
filename: 'replace_with_your_filename.xxx'
};
Errors are returned as either null or instances of the NodeJS Error Object with a message.