3 ms·
on a whim...do you know of any good guides for integrating an external API? i'm new to rails and working on a rails project that needs to communicate with a thi
by greenie_beans 7y ago
on a whim...do you know of any good guides for integrating an external API? i'm new to rails and working on a rails project that needs to communicate with a third party api -- there are a lot of messy guides, particularly for oauth
- masonhensley 7y agoIf I was starting out fresh, I'd probably try and check out some of the guides that services like stripe and github have for interacting with their own api's if you'd like some real world experience. Here some links: - https://github.com/octokit/octokit.rb https://github.com/octokit/octokit.rb - https://github.com/stripe/stripe-ruby https://github.com/stripe/stripe-ruby Depending on how you set up your app, you should look into organizing your external services like this: https://www.engineyard.com/blog/keeping-your-rails-controllers-dry-with-services https://www.engineyard.com/blog/keeping-your-rails-controlle...
- tra3 7y agoI don't know of a library for external API integration (so I'll be watching this space), but for OAuth specifically, Omniauth has been invaluable. It supports a lot of various strategies [0] which is what it called various OAuth2 implementations. 0: https://github.com/omniauth/omniauth/wiki/List-of-Strategies https://github.com/omniauth/omniauth/wiki/List-of-Strategies
- mr-ron 7y agoI think the pattern of making generic classes that leverage the httparty gem is solid. Depending on your preference have another layer of classes between that and your models. Or have the apis called directly from models or controllers