Skip to content

Commit

Permalink
feat(api): request listSearchOption
Browse files Browse the repository at this point in the history
Signed-off-by: Hector Rondon <hrondon@teclib.com>
  • Loading branch information
Hector Rondon authored and ajsb85 committed Oct 4, 2018
1 parent 7002f19 commit f0a55f9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
10 changes: 10 additions & 0 deletions Source/GlpiRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,16 @@ public class GlpiRequest {
}
}

/**
Request list search option
*/
class public func listSearchOptions(itemType: ItemType, completion: @escaping (_ data: AnyObject?, _ response: HTTPURLResponse?, _ error: Error?) -> Void) {

GlpiRequest.httpRequest(Routers.listSearchOptions(itemType)) { data, response, error in
completion(data, response, error)
}
}

class func httpRequest(_ router: Routers, completion: @escaping (_ data: AnyObject?, _ response: HTTPURLResponse?, _ error: Error?) -> Void) {

let task:URLSessionDataTask = URLSession.shared.dataTask(with: router.request()) { (data, response, error) in
Expand Down
8 changes: 6 additions & 2 deletions Source/Routers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public enum Routers: URLRequestDelegate {
case deleteItems(ItemType, Int?, QueryString.DeleteItems?, [String: AnyObject])
/// PUT /lostPassword
case lostPassword([String: AnyObject])
/// GET /listSearchOptions
case listSearchOptions(ItemType)

/// get HTTP Method
var method: HTTPMethod {
Expand All @@ -75,7 +77,7 @@ public enum Routers: URLRequestDelegate {
.getMyEntities, .getActiveEntities, .getFullSession, .getGlpiConfig,
.getMultipleItems, .getAllItems, .getItem, .getSubItems:
return .get
case .changeActiveProfile, .changeActiveEntities, .addItems:
case .changeActiveProfile, .changeActiveEntities, .addItems, .listSearchOptions:
return .post
case .updateItems, .lostPassword:
return .put
Expand Down Expand Up @@ -132,6 +134,8 @@ public enum Routers: URLRequestDelegate {
}
case .lostPassword:
return "/lostPassword"
case .listSearchOptions(let itemType):
return "/listSearchOptions/\(itemType)"
}
}

Expand All @@ -141,7 +145,7 @@ public enum Routers: URLRequestDelegate {
switch self {
case .initSessionByUserToken, .initSessionByCredentials, .killSession, .getMyProfiles, .getActiveProfile,
.changeActiveProfile, .getMyEntities, .getActiveEntities, .changeActiveEntities,
.getFullSession, .getGlpiConfig, .getMultipleItems, .addItems, .updateItems, .lostPassword:
.getFullSession, .getGlpiConfig, .getMultipleItems, .addItems, .updateItems, .lostPassword, .listSearchOptions:
return nil
case .getAllItems(_, let queryString):
if queryString != nil {
Expand Down

0 comments on commit f0a55f9

Please sign in to comment.