Created
June 14, 2021 15:50
-
-
Save jacobSingh/224159d9eda57d748ce98ccddf4f0b07 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Provider(): | |
def getFollowers(username): | |
pass | |
class LinkedInProvider(Provider): | |
def __init__(self): | |
pass | |
class TwitterProvider(Provider): | |
api = None | |
def __init__(self, **kwargs): | |
self.api = Api(bearer_token=kwargs['bearer_token']) | |
pass | |
class ProviderFactory(): | |
providers = { | |
'twitter': TwitterProvider, | |
'linkedIn': LinkedInProvider, | |
} | |
@classmethod | |
def factory(cls, name: str, **kwargs) -> 'FollowerGetter': | |
""" Factory command to create the executor """ | |
provider_class = cls.providers[name] | |
provider = provider_class(**kwargs) | |
return provider | |
p = ProviderFactory.factory('twitter', bearer_token="foo") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment