Manos Chorianopoulos

add verifyTicketAsync request

......@@ -581,4 +581,62 @@ public class swiftApi {
public func getProfileAsync(_ getProfileCallback: @escaping (_ profileData: ProfileModel?) -> Void) -> Void {
ProfileDataModel().getProfileData(getProfileCallback)
}
public class VerifyTicketResponseModel {
let result: String?
let status: Int?
init(dictionary: [String: Any]) {
self.result = dictionary["result"] as? String? ?? ""
self.status = dictionary["status"] as? Int? ?? -1
}
public var getResult: String {
get { // getter
return self.result ?? ""
}
}
}
public class VerifyTicketModel {
init() {
}
func verifyTicket(guid: String, ticket: String, _ verifyTicketCallback: @escaping (_ verifyTicketData: VerifyTicketResponseModel?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.verifyTicketAsync(guid, ticket, verifyAsyncCallback, failureBlock: verifyAsyncFailureCallback)
func verifyAsyncCallback(_ verifyTicketData: [AnyHashable: Any]?) -> Void {
if let verifyTicketDataDictionary = verifyTicketData as? [String: Any] {
let tempResponse = VerifyTicketResponseModel(dictionary: verifyTicketDataDictionary)
verifyTicketCallback(tempResponse);
} else {
verifyTicketCallback(nil)
}
}
func verifyAsyncFailureCallback(_ error: Error?) -> Void {
print("verifyTicket error: ")
print(error)
print("====================")
verifyTicketCallback(nil)
}
}
}
public func verifyTicketAsync(guid: String, ticket: String, _ verifyTicketCallback: @escaping (_ verifyTicketData: VerifyTicketResponseModel?) -> Void) -> Void {
VerifyTicketModel().verifyTicket(guid: guid, ticket: ticket, verifyTicketCallback)
}
}
......