blue-state-digital v0.2.0
blue-state-digital
A node module for accessing the blue state digital api service
Install
$ npm install --save blue-state-digitalUsage
import BSD from 'blue-state-digital';
const blueStateDigital = new BSD(options)API
BSD
Create a new BSD rest client.
Parameters
optionsobject The BSD API Options.options.baseUrlString The base url of your bsd instance. IE: https://XYZoptions.apiIDString The App ID for your BSD API Secret.options.apiSecretString The API Secret for your BSD API App.options.apiVerNumber The API version, default is 2 and 2 is only supported for now.
Examples
The BSD constructor takes a API ID, if specified it will be used as default value for all endpoints that accept a API ID. The default is 2 but is required so you are aware of what version you are using.
const blueStateDigital = new BSD({
baseUrl: 'legislator.bsd.net',
apiID: 'MyApiID',
apiSecret: '43875utihgkfj38563y4uig',
apiVer: 2,
})authenticate
Returns string Returns authentication response
request
This is the main method to handle easy authentication with bsd and node js. API Base Documentation https://secure.bluestatedigital.com/page/api/doc
Parameters
optionsobject Options Object
Examples
async function doRequest() {
try {
const response = await blueStateDigital.request({
method: '|GET|POST|PUT|DELETE|',
path: 'path for the call, see BSD documentation for possible calls',
body: //body parameters as JSON or an XML string
query: {
// query string parameters, {event_id:2, ids:'1,3,5' } is valid for example
},
})
} catch(err) {
// handle error
}
}
const response = blueStateDigital.request({
method: '|GET|POST|PUT|DELETE|',
path: 'path for the call, see BSD documentation for possible calls',
body: // //body parameters as JSON or an XML string
query: {
// query string parameters, {event_id: 2 ids:'1,3,5' } is valid for example
},
}).then(resp => {
// bsd response
})
.catch(err => {
// be sure to handle errors
})Returns Promise BSD Response Promise
searchEvents
Searches all the events and returns the future events unless specified by date_start.
REF: https://secure.bluestatedigital.com/page/api/doc#-------------Event-API-Calls---------
Parameters
paramsobject The BSD API Options.params.event_idstring Search by Event IDparams.event_typestring Search by Event Typeparams.host_namestring Search by the Host of the Eventparams.daystring Search by the day of the Eventparams.date_startstring Search by the start date of the Eventparams.date_endstring Search by the end date of the Eventparams.create_daystring Search by the created day of the Eventparams.create_date_startstring Search by the created start date of the Eventparams.create_date_endstring Search by the created end date of the Eventparams.countrystring Search by events countryparams.zipstring Search by events zipcodeparams.citystring Search by events by cityparams.statestring Search events by stateparams.zip_radiusstring Search events in a given zipcode radiusparams.radius_unitstring Search events in a given radiusparams.attendee_cons_idstring Search events by a consituent's ID who is attendingparams.creator_cons_idstring Search events by the consituent that created the Eventparams.order_fieldstring Search events by order field
Returns Promise BSD JSON Response Promise
sendTriggeredEmail
Searches all the events and returns the future events unless specified by date_start.
REF: https://secure.bluestatedigital.com/page/api/doc (send_triggered_email)
Parameters
paramsobject The BSD API Options.
Returns Promise BSD JSON Response Promise
listForms
This method lists all signup forms and relevant data about those forms. https://secure.bluestatedigital.com/page/api/doc#---------------------list_forms-----------------0.7883351277818669 No Params
Examples
const forms = await blueStateDigital.listForms()Returns Promise BSD XML Response
getFormByID
This method gets all properties of the specified signup form. https://secure.bluestatedigital.com/page/api/doc#---------------------get_form-----------------
Parameters
Examples
const form = await blueStateDigital.getFormByID({ signup_form_id: '105' })Returns Promise BSD XML Response Promise
listFormFields
Retrieves a list of all form fields associated with a specified signup form.
Parameters
Examples
const formFields = await blueStateDigital.listFormFields({ signup_form_id: '105' })Returns Promise BSD XML Response Promise
License
MIT © Samuel Robertson