Created
May 21, 2020 11:29
-
-
Save baz8080/3a08b7f20351acd7b1254017e42bd2c0 to your computer and use it in GitHub Desktop.
Getting the Request ID from a newly created request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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