1.2.0 • Published 7 years ago

screendoor-api-node v1.2.0

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
7 years ago

screendoor-api-node

NodeJS module for interacting with the Screendoor API via the Request module.

http://dobtco.github.io/screendoor-api-docs/

Available Endpoints

  • 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/

Example Usage

var ScreendoorAPI 	= require( 'screendoor-api-node' ),
	scrndr			= new ScreendoorAPI( api_key ),

GET /sites/:site_id/projects

See Endpoint in API Docs

scrndr.getSiteProjects( site_id, function( err, projects ){

	if ( null !== err ) {

		return callback( err, null );

	}

	return callback( null, projects );

} );

GET /sites/:site_id/projects/:project_id

See Endpoint in API Docs

scrndr.getProject( site_id, project_id, function( err, project ){

	if ( null !== err ) {

		return callback( err, null );

	}

	return callback( null, project );

} );

GET /projects/:project_id/response_fields

See Endpoint in API Docs

scrndr.getProjectFields( project_id, function( err, fields ){

	if ( null !== err ) {

		return callback( err, null );

	}

	return callback( null, fields );

} );

GET /projects/:project_id/responses/:response_id

See Endpoint in API Docs

scrndr.getProjectResponse( project_id, response_id, format, function( err, result ){

	if ( null !== err ) {

		return callback( err, null );

	}

	return callback( null, result );

} );

POST /projects/:project_id/responses

See Endpoint in API Docs

var response_fields = {
	"1": "Test Name",
    "2": "test@test.com",
    "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.

PUT /projects/:project_id/responses/:response_id

See Endpoint in API Docs

var response_fields = {
	"1": "Test Name",
    "2": "test@test.com",
    "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 );

});

POST /form_renderer/

See Endpoint in API Docs

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

Errors are returned as either null or instances of the NodeJS Error Object with a message.

1.2.0

7 years ago

1.1.0

9 years ago

1.0.1

9 years ago