Document the API
Inspired by https://github.com/thoughtbot/handbook/issues/402, I'd like to update https://github.com/thoughtbot/srs-bsns so that it posts on Constable instead of Basecamp, but I'm having trouble figuring out the API.
The README says the best place to look is the app/stores directory in the https://github.com/thoughtbot/constable/ repo, but that directory doesn't exist.
I don't have enough experience with either Elixr or React to quickly piece together what's going on without a bit more documentation.
Not documentation, but the best place to look at the moment is web/views/api for what payloads will return, and web/router.ex to see the routes.
If you want to jump into #constable on Slack I'm more than willing to help out as much as I can.
Hi George,
I think this is a great idea! The best place to look for the API is in test/controllers/api (https://github.com/thoughtbot/constable-api/tree/master/test/controllers/api). I’ll give a brief rundown of what I would to do to see how to use the API
-
web/routercontains a list of routes that you can call - Take a look in test/controllers/api. For example: https://github.com/thoughtbot/constable-api/blob/master/test/controllers/api/announcement_controller_test.exs has tests for the announcement endpoint
- You'll notice that the tests for #create call
build(:announcement_params). You can see the factories defined inlib/support/factory.ex. That will show you what the announcement_params look like. In this case the announcement params require atitle,bodyanduser_id, which is the id of the author. We would probably want to create an account for Ralph, but for now you could probably look in the production database and use the id from your user. To do that runbin/console productionto start the console. Then typeRepo.get_by!(Constable.User, email: "your_email").id. You'll also need the api_token for your user:Repo.get_by!(Constable.User, email: "your_email").token - You'll also notice that the API expects
interest_namesas a param. It accepts an array of strings for the interests you want to tag the announcement with, e.g.["everyone", "serious-business"] - The api requires authentication. Here are the headers that are needed: https://github.com/thoughtbot/constable-api/blob/master/test/support/conn_case_helper.ex#L9
We should add this to the README, but I'm a bit busy with ExMachina and Bamboo. I hope this helps. Feel free to ping me if you need any help!
@paulcsmith Thanks for the directions! I was able to successfully create announcements on staging, first using curl, and then using https://github.com/thoughtbot/srs-bsns/pull/25
Awesome! I'm glad that it worked!!
Sent from my iPhone
On Apr 22, 2016, at 6:10 PM, George Brocklehurst [email protected] wrote:
@paulcsmith Thanks for the directions! I was able to successfully create announcements on staging, first using curl, and then using thoughtbot/srs-bsns#25
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub