Beispiel #1
0
 def update_values_from_api(self):
     if not self.carrier:
         self.carrier = shapi.determine_carrier(self.tracking_number)
     shipments = shapi.query_tracking(self.tracking_number, self.carrier)
     if shipments:
         #TODO: Currently only supporting one package/shipment being returned from api.
         packages = shipments[0]
         if packages:
             pkg = packages[0]
             self.status = pkg.get('status')
             self.estimated_arrival = pkg.get('eta')
             self.last_checked = datetime.datetime.now()
             self.put()
             return True
     logging.error("An error occured while retrieving fresh values from the shipping API")
     return False
Beispiel #2
0
 def post_determine_carrier(self):
     tracking_number = request.form.get('tracking_number')
     carrier = api.determine_carrier(tracking_number)
     return json.dumps({'carrier': carrier})