Last active
February 24, 2020 18:24
-
-
Save pskd73/0bc1d40023d0d753b48c72d38c9556bd to your computer and use it in GitHub Desktop.
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
class LogisticService: | |
def is_serviceable(self, postal_code) -> bool: | |
mn, mx = self.get_postal_code_range() | |
if mn <= postal_code <= mx: | |
return True | |
return False | |
@abstractmethod | |
def get_postal_code_range(self) -> Tuple(int, int): | |
pass | |
@abstractmethod | |
def make_shipping_request(self, order): | |
pass | |
class DoneTodayLogisticService(LogisticService): | |
def get_postal_code_range(self): | |
return (690034, 695000) | |
def make_shipping_request(self, order): | |
# make http requests | |
logistic_services = [DoneTodayLogisticService()] | |
def assign_logistic_service(order): | |
for logistic in logistic_services: | |
if logistic.is_serviceable(order.postal_code): | |
logistic.make_shipping_request() | |
return logistic.__class__.__name__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment