Skip to content

Instantly share code, notes, and snippets.

@pskd73
Last active February 24, 2020 18:24
Show Gist options
  • Save pskd73/0bc1d40023d0d753b48c72d38c9556bd to your computer and use it in GitHub Desktop.
Save pskd73/0bc1d40023d0d753b48c72d38c9556bd to your computer and use it in GitHub Desktop.
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