Manos Chorianopoulos

add verifyTicketAsync request

...@@ -581,4 +581,62 @@ public class swiftApi { ...@@ -581,4 +581,62 @@ public class swiftApi {
581 public func getProfileAsync(_ getProfileCallback: @escaping (_ profileData: ProfileModel?) -> Void) -> Void { 581 public func getProfileAsync(_ getProfileCallback: @escaping (_ profileData: ProfileModel?) -> Void) -> Void {
582 ProfileDataModel().getProfileData(getProfileCallback) 582 ProfileDataModel().getProfileData(getProfileCallback)
583 } 583 }
584 +
585 +
586 + public class VerifyTicketResponseModel {
587 + let result: String?
588 + let status: Int?
589 +
590 +
591 + init(dictionary: [String: Any]) {
592 + self.result = dictionary["result"] as? String? ?? ""
593 + self.status = dictionary["status"] as? Int? ?? -1
594 +
595 + }
596 +
597 + public var getResult: String {
598 + get { // getter
599 + return self.result ?? ""
600 + }
601 + }
602 + }
603 +
604 + public class VerifyTicketModel {
605 +
606 + init() {
607 + }
608 +
609 + func verifyTicket(guid: String, ticket: String, _ verifyTicketCallback: @escaping (_ verifyTicketData: VerifyTicketResponseModel?) -> Void) -> Void {
610 +
611 + let instanceOfMyApi = MyApi()
612 + instanceOfMyApi.verifyTicketAsync(guid, ticket, verifyAsyncCallback, failureBlock: verifyAsyncFailureCallback)
613 +
614 + func verifyAsyncCallback(_ verifyTicketData: [AnyHashable: Any]?) -> Void {
615 +
616 + if let verifyTicketDataDictionary = verifyTicketData as? [String: Any] {
617 +
618 + let tempResponse = VerifyTicketResponseModel(dictionary: verifyTicketDataDictionary)
619 +
620 + verifyTicketCallback(tempResponse);
621 +
622 + } else {
623 + verifyTicketCallback(nil)
624 + }
625 +
626 + }
627 +
628 + func verifyAsyncFailureCallback(_ error: Error?) -> Void {
629 + print("verifyTicket error: ")
630 + print(error)
631 + print("====================")
632 + verifyTicketCallback(nil)
633 + }
634 +
635 + }
636 + }
637 +
638 +
639 + public func verifyTicketAsync(guid: String, ticket: String, _ verifyTicketCallback: @escaping (_ verifyTicketData: VerifyTicketResponseModel?) -> Void) -> Void {
640 + VerifyTicketModel().verifyTicket(guid: guid, ticket: ticket, verifyTicketCallback)
641 + }
584 } 642 }
......