Closed sundeepgupta closed 1 year ago
Hi @sundeepgupta! To make RouteResponse
truly Equatable
, you would need to extend RouteResponse
(and its affiliated properties that also aren't Equatable
) to conform to the Equatable
protocol. I would not recommend comparing only the identifiers since it isn't guaranteed that you can reliably distinguish responses solely on that property. However, comparing other properties in the response should work.
Hi @jill-cardamon, thanks for the reply. Understood - I will look into your suggestion.
Can you tell me more about the identifier and what it represents? Also, the Swift code declares it optional. Under what scenario is it expected to be nil
?
@sundeepgupta Of course. The identifier is generated by the Directions API and represents a unique ID for the request. Every response should have a different value.
The identifier (in the Directions response itself) should always be populated with something, but the exceptions for a RouteResponse
object are initializing a RouteResponse
object from a MapMatchingResponse
and potentially offline generated routes (I can clarify this case). We also don't provide an identifier when initializing a RouteResponse
in some of our tests.
Thanks. If I understand correctly, if RouteResponse
is created via Directions.calculate(...
which makes an HTTP request to the Directions API, identifier
will always be present. Correct?
Yes it should always be present in that case.
Thank you
What is the suggested approach to making
RouteResponse
Equatable
?Would it make sense to simply compare its
identifier
, which is theuuid
in theDirections.calculate
JSON payload?Is this field ever expected to be
nil
?