codeforamerica / ohana-pdf

Generator for PDFs from the Ohana API
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Converted to be an external library: API2PDF #4

Closed rebyn closed 11 years ago

rebyn commented 11 years ago

Call:

API2PDF.export(
  url: "http://ohanapi.herokuapp.com/api/organizations/51a9fd0628217f89770003ab",
  h1: "Code for America: Human Services Finder",
  h2: "name"
)

@anselmbradford: I'm going to make a gem out of this library. Generally it saves an API JSON as PDF so that you can download directly upon calling or save the file to S3. One question though: is it intentional for the Ohana API to be wrapped into a "response" field?

screen shot 2013-06-20 at 11 09 29 am

Personally I think it's better for all the fields to be exposed on first level, i.e: @fetch["name"] rather than @fetch["response"]["name"] as the way I do it now.

Let me know what you think. Cheers, Tu.

monfresh commented 11 years ago

@rebyn that's a good a point. I'm currently using the Rocket Pants gem for the API and it structures the response that way, presumably because it also includes pagination info in the response, so it separates the resource info from the pagination info. I've been looking at other API solutions, and I'll probably make some changes to RocketPants or switch to another gem. Instead of including the pagination info in the body, it will be in the headers via the Link header and possibly the X-Pagination header too.

anselmbradford commented 11 years ago

@rebyn, meet @monfresh, he has the best knowledge on the API structure. I imagine we can mask any of this behind the wrapper (https://github.com/codeforamerica/ohanakapa-ruby) till the API migrates to using the headers.