diff --git a/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate b/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate index 57c8264..8c4f5cc 100644 Binary files a/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate and b/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/OTRS-Watch.xcodeproj/xcuserdata/linnemann.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/OTRS-Watch.xcodeproj/xcuserdata/linnemann.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 52228e6..6911433 100644 --- a/OTRS-Watch.xcodeproj/xcuserdata/linnemann.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/OTRS-Watch.xcodeproj/xcuserdata/linnemann.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,38 +3,6 @@ type = "1" version = "2.0"> - - - - - - - - + landmarkName = "OTRS" + landmarkType = "3"> diff --git a/OTRS-Watch/Model/Extension/TicketExtension.swift b/OTRS-Watch/Model/Extension/TicketExtension.swift index ac89535..861dfb6 100644 --- a/OTRS-Watch/Model/Extension/TicketExtension.swift +++ b/OTRS-Watch/Model/Extension/TicketExtension.swift @@ -42,14 +42,12 @@ extension Ticket { } // extract customer ID - guard let customerID_ = source["CustomerID"] as? String else { - throw SerializationError.missing("CustomerID") - } + var customerID_ = source["CustomerID"] as? String + if customerID_ == nil { customerID_ = "" } // extract customer user ID - guard let customerUserID_ = source["CustomerUserID"] as? String else { - throw SerializationError.missing("CustomerUserID") - } + var customerUserID_ = source["CustomerUserID"] as? String + if customerUserID_ == nil { customerUserID_ = "" } // extract priority guard let priority_ = source["Priority"] as? String else { @@ -87,8 +85,8 @@ extension Ticket { self.ticketNumber = ticketNumber_ self.title = title_ self.owner = owner_ - self.customerID = customerID_ - self.customerUserID = customerUserID_ + self.customerID = customerID_! + self.customerUserID = customerUserID_! self.priority = priority_ self.queue = queue_ self.queueID = queueID_ diff --git a/OTRS-Watch/OTRS.swift b/OTRS-Watch/OTRS.swift index 23c935e..ae30f15 100644 --- a/OTRS-Watch/OTRS.swift +++ b/OTRS-Watch/OTRS.swift @@ -43,16 +43,22 @@ class OTRS { let config = URLSessionConfiguration.default // Session configuration let session = URLSession(configuration: config) // Load configuration into session - let url = URL(string: buildURLForGettingNew(queID: que)) + let urlNew = URL(string: buildURLForGettingNew(queID: que)) + let urlOpen = URL(string: buildURLForGettingOpen(queID: que)) - let task = session.dataTask(with: url!, completionHandler: { + self.ticketDictionary.removeAll() + + reloadByURL(session: session, url: urlNew!) + reloadByURL(session: session, url: urlOpen!) + } + + private func reloadByURL(session:URLSession, url:URL) { + let task = session.dataTask(with: url, completionHandler: { (data, response, error) in if error != nil { print(error!.localizedDescription) } else { - self.ticketDictionary.removeAll() - do { if let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any] { // work with json ... @@ -70,7 +76,6 @@ class OTRS { if let tID:Int = Int(ticketID) { self.fetch(ticket: tID, session: session, isLast: isLast) - } } }