Giter Site home page Giter Site logo

pandadoc-api's People

Contributors

dgalarza avatar euanlau avatar jsperezg avatar mikecx avatar mtvillwock avatar shernade avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pandadoc-api's Issues

Handling response codes in a DRY way

I understand that it's useful to be able to check http response codes once you've received a value from the API. However doing something like this:

response = Pandadoc::Api::Document.download
case response.code
when 429
  # handle rate limiting
when 4xx
  # handle bad client input
when 5xx
  # handle no response

... in my code for every different call seems bad. I'm considering contributing a patch and wondering about direction:

  • expose bang methods Document.download!, Document.create! that raise e.g. Pandadoc::Api::TooManyRequestsError for 429 (I won't just change the original methods... assuming that people will not appreciate it if suddenly this library starts raising errors when they expect to be able to safely inspect response codes)
  • alternatively, adding info to the object returned by the client: response.success? etc. Admittedly I'm not sure what info I'd add for rate limiting if I did this

This was all sparked by finding out that after 9 months of thinking this library was safely giving us PDFs, we found out that most of the "PDF" files we saved were actually just JSON: {"type"=>"request_error", "detail"=>"Request was throttled. Expected available in 1 second."}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.