Skip to content

Commit

Permalink
add sam.gov
Browse files Browse the repository at this point in the history
  • Loading branch information
ajb committed Oct 7, 2015
1 parent 542fb97 commit 3d9cd08
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"hubot-irc": "^0.2.7",
"hubot-scripts": ">= 2.5.11 < 3.0.0",
"nightmare": "^1.7.0",
"prettyjson": "^1.1.3",
"request": "~2.34.0",
"time": "^0.10.0",
"underscore": "~1.6.0"
Expand Down
34 changes: 34 additions & 0 deletions scripts/sam.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Description:
# Displays our current DUNS number or SAM.gov registration
#
# Configuration:
# You'll need to set HUBOT_GOV_API_TOKEN as an environmental variable.
# To get an token, head over to https://api.data.gov/signup/.
# You just need a name/email combo as it's solely used for rate limiting.
#
# Commands:
# hubot samdotgov me - display's your current Sam.gov registration
# hubot duns me - display's your DUNS registration number

prettyjson = require('prettyjson');

DUNS_NUMBER = "079100078"
API_BASE = "https://api.data.gov/sam/v1/registrations"

module.exports = (robot) ->
robot.respond /samdotgov me$/i, (msg) ->
token = process.env.HUBOT_GOV_API_TOKEN || ""
msg.http("#{API_BASE}/#{DUNS_NUMBER}0000?api_key=#{token}").get() (err, res, body) ->
if err
robot.emit 'error', err, msg
else
try
data = JSON.parse(body).sam_data.registration
msg.send prettyjson.render(data, {
noColor: true
})
catch e
robot.emit 'error', e, msg

robot.respond /duns me$/i, (msg) ->
msg.send "Our DUNS number is #{DUNS_NUMBER}, duh."

0 comments on commit 3d9cd08

Please sign in to comment.