Last active
August 29, 2015 14:05
-
-
Save bessey/789b0ac89e520cf44cbd to your computer and use it in GitHub Desktop.
My ideal v3 directory client.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### In my app | |
class Account < DirectoryClient::Base | |
def self.specific_convenient_scope_method | |
where(blah: "blah").order(:bloo) | |
end | |
end | |
Account.all | |
# Handles OAuth authentication and reauthentication on timeout | |
# Introspects class name to work out api endpoint (/api/v3/accounts) | |
#### In client | |
class DirectoryClient::Base | |
# OAuth handling | |
# Ransack compatibile methods | |
end | |
# In short, the client is skinny and, like the API v3 BaseController, implements a generic class that has | |
# all the non unique functionality of every API endpoint baked in. It is then up to the dev to extend | |
# or include that class in their actual endpoint specific classes. | |
# Best of both worlds. Client isn't updated every time theres a new endpoint, but abstract away authentication | |
# into the bowels of the client. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment