From 3859360afcdf41cd7082845bb53fd50079820e4d Mon Sep 17 00:00:00 2001 From: Mark Ryall Date: Tue, 6 Nov 2012 18:23:14 +1000 Subject: [PATCH] added api method to post a new antechamber message --- README.md | 5 +++++ app/controllers/api/antechamber_controller.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 969a2d2..c09b9e9 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,8 @@ To request the message contents of the antechamber for a team (with an optional export TEAM_SLUG=ateam curl "$OCELOTS_URL/api/antechamber/$TEAM_SLUG?auth_token=$OCELOTS_AUTH_TOKEN" curl "$OCELOTS_URL/api/antechamber/$TEAM_SLUG?auth_token=$OCELOTS_AUTH_TOKEN&from=23" + +To add a new message: + + export TEAM_SLUG=ateam + curl -d '{"content":"message"}' "$OCELOTS_URL/api/antechamber/$TEAM_SLUG?auth_token=$OCELOTS_AUTH_TOKEN" \ No newline at end of file diff --git a/app/controllers/api/antechamber_controller.rb b/app/controllers/api/antechamber_controller.rb index 11aaacc..8b0763c 100644 --- a/app/controllers/api/antechamber_controller.rb +++ b/app/controllers/api/antechamber_controller.rb @@ -12,5 +12,17 @@ module Api end render json: messages.map(&:api_attributes) end + + def create + message = nil + with_team do |team| + message = Message.create team: team, person: current_person, content: params[:content] + end + if message and message + render status: :created, json: message.api_attributes + else + render status: :unprocessable_entity + end + end end end \ No newline at end of file