Adding a b1 API endpoint for getting Poll by key

miriam Public Seen by 58

Hello, I have been using the new "b1" endpoints that @Rob Guthrie added recently for a Loomio integration I'm working on. I'd like to add a way to get a Poll's data (specifically stance_data is what I care about). I am starting a Poll using the POST b1/polls endpoint, and then waiting for a webhook event to notify me that the poll is closed. At that point I would like to know the stance data of the poll (it is not contained in the webhook event body).

My suggestion is adding index to existing API::B1::PollsController which returns a collection:

GET http://localhost:3000/api/b1/polls?poll_key=[key]&api_key=[key]

returns: Poll.where(key: params[:poll_key])

I already added it locally, so I can open a PR if the general idea sounds OK. Another approach could be to add an endpoint for stances, or to include stance data in the webhook event body.



Rob Guthrie Tue 9 Feb

Hi @miriam I've added new endpoints for show poll and show discussion.

For poll, It's a little different to how you have implemented it, but does the same thing.

You'll need to edit your API endpoint and add support for show_poll, and check out the updated API documentation.

It should include stance data too.


miriam Wed 10 Feb

Perfect, thanks @Rob Guthrie!