   enum Status: String {
     case Pending = "PENDING"
     case Confirmed = "CONFIRMED"
-    case Canceled = "CANCELED"
+    case Canceled = "CANCELLED"
   }
   
   struct Detail {

    let imageURL: NSURL?
  }
  
  let status: Status
  let provider: Detail?
  let vehicle: Detail?
}

// Swift-only this would be an enum

}

extension TKBookingConfirmation {
  private init?(withDictionary dictionary: [String: AnyObject]) {
    guard let statusString = dictionary["status"] as? String,
          let status = Status(rawValue: statusString) else {
        return nil
    }
    
    let provider = Detail(withDictionary: dictionary["provider"] as? [String: AnyObject])
    let vehicle = Detail(withDictionary: dictionary["vehicle"] as? [String: AnyObject])
    
    let actions: [Action]
    if let rawActions = dictionary["actions"] as? [[String: AnyObject]] {
      actions = rawActions.flatMap { Action(withDictionary: $0) }
    } else {
      actions = []
    }

    self.init(status: status, provider: provider, vehicle: vehicle, actions: actions)
  }
}

extension TKBookingConfirmation.Detail {
  private init?(withDictionary dictionary: [String: AnyObject]?) {
    guard let dictionary = dictionary,
          let title = dictionary["title"] as? String else { return nil }
    
    self.title = title
    self.subtitle = dictionary["subtitle"] as? String
    if let imageURLString = dictionary["imageURL"] as? String,
       let imageURL = NSURL(string: imageURLString) {
      self.imageURL = imageURL
    } else {
      self.imageURL = nil
    }
  }
}

extension TKBookingConfirmation.Action {
  private init?(withDictionary dictionary: [String: AnyObject]?) {
    guard let dictionary = dictionary,
      let title = dictionary["title"] as? String else { return nil }
    
    self.title = title
    if let internalURLString = dictionary["internalURL"] as? String,
      let internalURL = NSURL(string: internalURLString) {
      self.internalURL = internalURL
    } else {
      self.internalURL = nil
    }

    if let externalURLString = dictionary["externalURL"] as? String,
      let externalURL = NSURL(string: externalURLString) {
      self.externalURL = externalURL
    } else {
      self.externalURL = nil
    }
}
}


extension TKBookingConfirmation {
  private static func fake() -> TKBookingConfirmation? {
    let fake = [
      "actions": [
        [
          "externalURL": "phone:(555)555-5555",
          "title": "Call driver"
        ],
        [
          "internalURL": "http://deep-thought:8080/satapp-debug/booking/v1/1204f411-eacb-406c-8fd2-3775c8242b02/cancel?bsb=1",
          "title": "Cancel ride"
        ]
      ],
      "provider": [
        "imageURL": "4.9",
        "subtitle": "John",
        "title": "https://d1a3f4spazzrp4.cloudfront.net/uberex-sandbox/images/driver.jpg"
      ],
      "status": "PENDING",
      "vehicle": [
        "imageURL": "UBER-PLATE",
        "subtitle": "Prius Toyota",
        "title": "https://d1a3f4spazzrp4.cloudfront.net/uberex-sandbox/images/prius.jpg"
      ]
    ]
    return TKBookingConfirmation(withDictionary: fake)
  }
