Open and New

This commit is contained in:
Gerrit Linnemann 2016-12-23 08:18:27 +01:00
parent df8845e5fc
commit 39c515d982
4 changed files with 18 additions and 47 deletions

View File

@ -3,38 +3,6 @@
type = "1" type = "1"
version = "2.0"> version = "2.0">
<Breakpoints> <Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OTRS-Watch/OTRS.swift"
timestampString = "503499740.022029"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "60"
endingLineNumber = "60"
landmarkName = "reload(que:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "OTRS-Watch/OTRS.swift"
timestampString = "503572546.154236"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "71"
endingLineNumber = "71"
landmarkName = "reload(que:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy <BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent <BreakpointContent
@ -95,8 +63,8 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "32" startingLineNumber = "32"
endingLineNumber = "32" endingLineNumber = "32"
landmarkName = "configure(baseURL_:username_:password_:)" landmarkName = "OTRS"
landmarkType = "7"> landmarkType = "3">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
</Breakpoints> </Breakpoints>

View File

@ -42,14 +42,12 @@ extension Ticket {
} }
// extract customer ID // extract customer ID
guard let customerID_ = source["CustomerID"] as? String else { var customerID_ = source["CustomerID"] as? String
throw SerializationError.missing("CustomerID") if customerID_ == nil { customerID_ = "" }
}
// extract customer user ID // extract customer user ID
guard let customerUserID_ = source["CustomerUserID"] as? String else { var customerUserID_ = source["CustomerUserID"] as? String
throw SerializationError.missing("CustomerUserID") if customerUserID_ == nil { customerUserID_ = "" }
}
// extract priority // extract priority
guard let priority_ = source["Priority"] as? String else { guard let priority_ = source["Priority"] as? String else {
@ -87,8 +85,8 @@ extension Ticket {
self.ticketNumber = ticketNumber_ self.ticketNumber = ticketNumber_
self.title = title_ self.title = title_
self.owner = owner_ self.owner = owner_
self.customerID = customerID_ self.customerID = customerID_!
self.customerUserID = customerUserID_ self.customerUserID = customerUserID_!
self.priority = priority_ self.priority = priority_
self.queue = queue_ self.queue = queue_
self.queueID = queueID_ self.queueID = queueID_

View File

@ -43,16 +43,22 @@ class OTRS {
let config = URLSessionConfiguration.default // Session configuration let config = URLSessionConfiguration.default // Session configuration
let session = URLSession(configuration: config) // Load configuration into session 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 (data, response, error) in
if error != nil { if error != nil {
print(error!.localizedDescription) print(error!.localizedDescription)
} else { } else {
self.ticketDictionary.removeAll()
do { do {
if let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any] { if let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any] {
// work with json ... // work with json ...
@ -70,7 +76,6 @@ class OTRS {
if let tID:Int = Int(ticketID) { if let tID:Int = Int(ticketID) {
self.fetch(ticket: tID, session: session, isLast: isLast) self.fetch(ticket: tID, session: session, isLast: isLast)
} }
} }
} }