Hello,
I'm building a website which connects several reporting APIs (like google analytics) and I want to write a centralized class which does stuff like saving the authentication tokens to the database, and then each API would simply extend these features for the specifics that the api is responsible for (like getting the number of visitors to a website and whatnot).
My goal is to make this system very expandable in the future while keeping the core functions very simple. I've used pre-built OOP before, but never actually written one of my own that's this complicated. What kind of approach do I need to take?
Here's one idea I have right now, in pseudocode....
what I'm thinking is, by using the basic structure as shown above, every client would use the same naming conventions, which still performing its own operations pursuant to how each individual api is built, right?
I'm building a website which connects several reporting APIs (like google analytics) and I want to write a centralized class which does stuff like saving the authentication tokens to the database, and then each API would simply extend these features for the specifics that the api is responsible for (like getting the number of visitors to a website and whatnot).
My goal is to make this system very expandable in the future while keeping the core functions very simple. I've used pre-built OOP before, but never actually written one of my own that's this complicated. What kind of approach do I need to take?
Here's one idea I have right now, in pseudocode....
Code:
class apiCore {
public function saveAuthToken ($whichApi = '') {
//query mysql which updates the user record with the token particular to the chosen api
}
public function makeUserAuthenticated() {
$_SESSION['userIsLoggedIn'] = true;
}
}
class googleAnalytics extends apiCore {
public function saveAuthToken() {
parent::saveAuthToken('google');
}
public function authenticate( $args...) {
///individual authentication script...
if ($success == true)
self::saveAuthToken();
parent::makeUserAuthenticated();
}
}
}
$client = new googleAnalytics();
$client->saveAuthToken();
what I'm thinking is, by using the basic structure as shown above, every client would use the same naming conventions, which still performing its own operations pursuant to how each individual api is built, right?