def prepare_person_details(reference: str, name: str, phone: str, email: str, notes: str) -> dict: """ Prepares data of recepient or sender :param reference: Either 'sender' or 'recepient' :param name: name of the recepient or sender :param phone: phone of the recepient or sender :param email: email of the recepient or sender :param notes: notes of the recepient or sender """ if reference == "recepient" or reference == "sender": person_data = check_person_details({ "name": name, "phone": phone, "email": email, "notes": notes }) return { "{}_name".format("recepient"): person_data["name"], "{}_phone".format("recepient"): person_data["phone"], "{}_email".format("recepient"): person_data["email"], "{}_notes".format("recepient"): person_data["notes"] } else: raise SendyException( "Invalid reference for person.Give 'sender' or 'recepient'")
def request_multi_pickup_delivery(self, rider_phone: dict, from_details_one: dict, from_details_two: dict, to_details: dict, recepient: dict, sender: dict, delivery_details: dict, vendor_type=1): """ This call is used to create new multi pickup delivery request, obtaining rates , estimated time of arrival and estimated time of delivery between a set of locations. The main difference with the normal delivery is the number of pickup locations passed , on the from key. In this request pass an array with multiple destination. Multi-Pickup orders cannot be placed alongside multi-delivery orders. """ command = "request" endpoint = "##requestmultipickup" values = { "command": command, "data": { "api_key": self.api_key, "api_username": self.api_username, "vendor_type": vendor_type, "rider_phone": rider_phone, "from": [ check_location_details(from_details_one), check_location_details(from_details_two) ], "to": [check_location_details(to_details)], "recepient": check_person_details(recepient), "sender": check_person_details(sender), "delivery_details": check_delivery_details(delivery_details) } } return self.make_request(url_parameter=endpoint, body=values)
def request_multi_destination_delivery(self, from_details: dict, to_details_first: dict, to_details_second: dict, recepient: dict, sender: dict, delivery_details: dict): """ This call is used to create new multi destination delivery request, obtaining rates , estimated time of arrival and estimated time of delivery between a set of locations. The main difference with the normal delivery is the number of destinations passed, on the to key. In this request pass an array with multiple destination. """ endpoint = "#requestmultidestination" values = { "command": "request", "data": { "api_key": self.api_key, "api_username": self.api_username, "vendor_type": 1, "rider_phone": "0728561783", "from": check_location_details(from_details), "to": [ check_location_details(to_details_first), check_location_details(to_details_second) ], "recepient": check_person_details(recepient), "sender": check_person_details(sender), "delivery_details": check_delivery_details(delivery_details) }, "request_token_id": "request_token_id" } return self.make_request(url_parameter=endpoint, body=values)
def test_check_person_details_2(self): data = self.person_data self.assertIsNotNone(check_person_details(data))
def test_check_person_details_1(self): data = self.person_data self.assertDictEqual(data, check_person_details(data))