Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Document the API #165

Open
georgebrock opened this issue Apr 8, 2016 · 4 comments
Open

Document the API #165

georgebrock opened this issue Apr 8, 2016 · 4 comments
Labels
documentation Issues/PRs related to documentation

Comments

@georgebrock
Copy link

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.

@BlakeWilliams
Copy link
Contributor

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.

@paulcsmith
Copy link
Contributor

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/router contains 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 in lib/support/factory.ex. That will show you what the announcement_params look like. In this case the announcement params require a title, body and user_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 run bin/console production to start the console. Then type Repo.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_names as 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!

@georgebrock
Copy link
Author

@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

@paulcsmith
Copy link
Contributor

Awesome! I'm glad that it worked!!

Sent from my iPhone

On Apr 22, 2016, at 6:10 PM, George Brocklehurst notifications@github.com 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

@WilHall WilHall added documentation Issues/PRs related to documentation and removed Beginner labels Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Issues/PRs related to documentation
Projects
None yet
Development

No branches or pull requests

4 participants