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"
version = "2.0">
<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
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
@ -95,8 +63,8 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "32"
endingLineNumber = "32"
landmarkName = "configure(baseURL_:username_:password_:)"
landmarkType = "7">
landmarkName = "OTRS"
landmarkType = "3">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>

View File

@ -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_

View File

@ -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)
}
}
}