uber / uber-ios-sdk

Uber iOS SDK (beta)
https://developer.uber.com/docs
MIT License
376 stars 125 forks source link

Driver smsNumber decoding fails #220

Closed nafetswirth closed 6 years ago

nafetswirth commented 6 years ago

First off thanks for the SDK.

When requesting a ride through the SDK the Ride fails to decode for me in the Sandbox. In particular if fails to decode the smsNumber of the driver as it's null for the test rides i generate.

It's this line: smsNumber = try container.decode(String.self, forKey: .smsNumber)

I 'fixed' it by replacing it with an optional decode but I'm not sure if that's the way you want to handle it.

smsNumber = try container.decodeIfPresent(String.self, forKey: .smsNumber) ?? ""

Sample response from server for https://sandbox-api.uber.com/v1.2/requests/current.

{
    "status": "in_progress",
    "product_id": "a1111c8c-c720-46c3-8534-2fcdd730040d",
    "destination": {
        "latitude": 37.7773228,
        "eta": 1,
        "longitude": -122.4272052
    },
    "driver": {
        "phone_number": "(555)555-5555",
        "rating": 4.9,
        "picture_url": "https://d1a3f4spazzrp4.cloudfront.net/uberex-sandbox/images/driver.jpg",
        "name": "John",
        "sms_number": null
    },
    "pickup": {
        "latitude": 37.7752278,
        "region": {
            "latitude": 37.7749295,
            "country_name": "United States",
            "country_code": "US",
            "name": "San Francisco",
            "longitude": -122.4194155
        },
        "eta": 1,
        "longitude": -122.4197513
    },
    "request_id": "6911007d-8075-41ca-9e73-8dd30568ff03",
    "location": {
        "latitude": 37.77617,
        "bearing": -9,
        "longitude": -122.42117
    },
    "vehicle": {
        "make": "Toyota",
        "picture_url": "https://d1a3f4spazzrp4.cloudfront.net/uberex-sandbox/images/prius.jpg",
        "model": "Prius",
        "license_plate": "UBER-PLATE"
    },
    "shared": false
}
nafetswirth commented 6 years ago

I see I am not on the newest version and this has been resolved.