Skip to content

Models

DestinationWeatherResponse

A class representing the Weather Forecasts for DestinationWeather Api.

new_from_jsondict(data, param_defaults, **kwargs) classmethod

Create a new instance based on a JSON dict. Any kwargs should be supplied by the inherited, calling class.

Parameters:

Name Type Description Default
data dict

A JSON dict, as converted from the JSON in the here API.

required
Source code in herepy/models.py
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
@classmethod
def new_from_jsondict(cls, data, param_defaults, **kwargs):
    """Create a new instance based on a JSON dict. Any kwargs should be
    supplied by the inherited, calling class.

    Args:
        data (dict):
          A JSON dict, as converted from the JSON in the here API.
    """

    json_data = data.copy()
    if kwargs:
        for key, val in kwargs.items():
            json_data[key] = val

    c = cls(param_defaults, **json_data)
    c._json = data
    return c

EVChargingStationsResponse

A class representing the EV Charging Stations response data.

GeocoderAutoCompleteResponse

A class representing the Geocoder Autocomplete Api response data.

GeocoderResponse

A class representing the Geocoder Api response data.

GeocoderReverseResponse

A class representing the Geocoder Reverse Api response data.

HEREModel

Base class from which all here models will inherit.

__str__(self) special

Returns a string representation of HEREModel. By default this is the same as as_json_string().

Source code in herepy/models.py
10
11
12
13
def __str__(self):
    """Returns a string representation of HEREModel. By default
    this is the same as as_json_string()."""
    return self.as_json_string()

as_dict(self)

Create a dictionary representation of the object. Please see inline comments on construction when dictionaries contain HEREModels.

Source code in herepy/models.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def as_dict(self):
    """Create a dictionary representation of the object. Please see inline
    comments on construction when dictionaries contain HEREModels."""
    data = {}

    for (key, value) in self.param_defaults.items():

        # If the value is a list, we need to create a list to hold the
        # dicts created by an object supporting the as_dict() method,
        # i.e., if it inherits from HEREModel. If the item in the list
        # doesn't support the as_dict() method, then we assign the value
        # directly. An example being a list of Media objects contained
        # within a Status object.
        if isinstance(getattr(self, key, None), (list, tuple, set)):
            data[key] = list()
            for subobj in getattr(self, key, None):
                if getattr(subobj, "as_dict", None):
                    data[key].append(subobj.as_dict())
                else:
                    data[key].append(subobj)

        # Not a list, *but still a subclass of HEREModel* and
        # and we can assign the data[key] directly with the as_dict()
        # method of the object. An example being a Status object contained
        # within a User object.
        elif getattr(getattr(self, key, None), "as_dict", None):
            data[key] = getattr(self, key).as_dict()

        # If the value doesn't have an as_dict() method, i.e., it's not
        # something that subclasses HEREModel, then we can use direct
        # assigment.
        elif getattr(self, key, None):
            data[key] = getattr(self, key, None)
    return data

as_json_string(self)

Returns the HEREModel as a JSON string based on key/value pairs returned from the as_dict() method.

Source code in herepy/models.py
21
22
23
24
def as_json_string(self):
    """Returns the HEREModel as a JSON string based on key/value
    pairs returned from the as_dict() method."""
    return json.dumps(self.as_dict(), sort_keys=True)

new_from_jsondict(data, **kwargs) classmethod

Create a new instance based on a JSON dict. Any kwargs should be supplied by the inherited, calling class.

Parameters:

Name Type Description Default
data dict

A JSON dict, as converted from the JSON in the here API.

required
Source code in herepy/models.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@classmethod
def new_from_jsondict(cls, data, **kwargs):
    """Create a new instance based on a JSON dict. Any kwargs should be
    supplied by the inherited, calling class.

    Args:
        data (dict):
          A JSON dict, as converted from the JSON in the here API.
    """

    json_data = data.copy()
    if kwargs:
        for key, val in kwargs.items():
            json_data[key] = val

    c = cls(**json_data)
    c._json = data
    return c

IsolineRoutingResponse

A class representing the Isoline Routing API Flow response data.

PlacesResponse

A class representing the Places (Search) Api response data.

PublicTransitResponse

A class representing the Public Transit Api response data.

RmeResponse

A class representing the RME (Route Matcher) Api response data.

RoutingMatrixResponse

A class representing the Routing Api matrix response data.

RoutingResponse

A class representing the Routing Api response data.

TrafficFlowAvailabilityResponse

A class representing the Traffic API Flow availability response data.

TrafficFlowResponse

A class representing the Traffic API Flow response data.

TrafficIncidentResponse

A class representing the Traffic Incidents response provided by Traffic Api.

WaypointSequenceResponse

A class representing the Fleet Telematics Waypoint Sequence response data.