Skip to content

Instantly share code, notes, and snippets.

@baz8080
Created May 21, 2020 11:29
Show Gist options
  • Save baz8080/3a08b7f20351acd7b1254017e42bd2c0 to your computer and use it in GitHub Desktop.
Save baz8080/3a08b7f20351acd7b1254017e42bd2c0 to your computer and use it in GitHub Desktop.
Getting the Request ID from a newly created request
let createRequest = ZDKCreateRequest()
createRequest.subject = "Hello?"
createRequest.requestDescription = "Is it me you're looking for?"
let requestProvider = ZDKRequestProvider()
requestProvider.createRequest(createRequest) { (response, error) in
if (error != nil) {
// Display / Handle the error
return
}
if let dispatcherResponse = response as? ZDKDispatcherResponse {
// If you want a json string of the response.
let jsonString = String(data: dispatcherResponse.data, encoding: .utf8)
// Or, If you want a ZDKRequest object
// First convert the response to a dictionary
let responseDictionary = try! JSONSerialization.jsonObject(with: dispatcherResponse.data, options: []) as! [String: Any]
// Secondly, initialize a ZDKRequestObject with that dictionary
let createdRequest = ZDKRequest.init(dict: responseDictionary["request"] as? [AnyHashable : Any])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment