A node module for accessing the blue state digital api service
$ npm install --save blue-state-digital
import BSD from 'blue-state-digital';
const blueStateDigital = new BSD(options)
Create a new BSD rest client.
Parameters
options
object The BSD API Options.options.baseUrl
String The base url of your bsd instance. IE: https://XYZoptions.apiID
String The App ID for your BSD API Secret.options.apiSecret
String The API Secret for your BSD API App.options.apiVer
Number 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,
})
Returns string Returns authentication response
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
options
object 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
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
params
object The BSD API Options.params.event_id
string Search by Event IDparams.event_type
string Search by Event Typeparams.host_name
string Search by the Host of the Eventparams.day
string Search by the day of the Eventparams.date_start
string Search by the start date of the Eventparams.date_end
string Search by the end date of the Eventparams.create_day
string Search by the created day of the Eventparams.create_date_start
string Search by the created start date of the Eventparams.create_date_end
string Search by the created end date of the Eventparams.country
string Search by events countryparams.zip
string Search by events zipcodeparams.city
string Search by events by cityparams.state
string Search events by stateparams.zip_radius
string Search events in a given zipcode radiusparams.radius_unit
string Search events in a given radiusparams.attendee_cons_id
string Search events by a consituent's ID who is attendingparams.creator_cons_id
string Search events by the consituent that created the Eventparams.order_field
string Search events by order field
Returns Promise BSD JSON Response Promise
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
params
object The BSD API Options.
Returns Promise BSD JSON Response Promise
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
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
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
MIT © Samuel Robertson