Add recipient info and features list to Delivery

This commit is contained in:
Lucidiot 2019-02-03 15:34:25 +01:00
parent c735cbbea6
commit b28d65fe12
No known key found for this signature in database
GPG Key ID: AE3F7205692FA205
1 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,6 @@
from datetime import datetime
from urbantz.base import JSONSerializable, Coordinates
from urbantz.utils import DictObject
from urbantz.exceptions import APIError
import requests
@ -51,6 +52,25 @@ class Delivery(JSONSerializable):
:type: urbantz.base.Coordinates
"""
self.recipient = None
"""
Informations about the recipient (name, language, phone number, etc.)
Does not contain the destination location information.
:type: urbantz.utils.DictObject
"""
self.features = None
"""
Dictionary of booleans indicating which features of the UrbanTZ
tracking software are enabled on this delivery.
For example, ``consumerModifyInstructions`` will indicate whether
the client is allowed to update the delivery instructions after the
driver departs for its round.
:type: urbantz.utils.DictObject
"""
def __repr__(self):
return '{}({})'.format(
self.__class__.__name__, repr(self.tracking_code))
@ -104,6 +124,8 @@ class Delivery(JSONSerializable):
self.position = Coordinates.fromJSON(self.payload['position'])
self.destination = Coordinates.fromJSON(
self.payload['location']['location']['geometry'])
self.recipient = DictObject(self.payload['contact'])
self.features = DictObject(self.payload['features'])
@classmethod
def fromJSON(cls, payload):