Skip to content

Commit

Permalink
feat(request): create structure to handle parameters in getAllItems
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Rondon authored and ajsb85 committed Oct 27, 2017
1 parent 397de63 commit 5d6cb5d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Glpi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
0A1CF5B31F97B3D00048E866 /* Routers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CF5B21F97B3D00048E866 /* Routers.swift */; };
0A1CF5B61F97BBF60048E866 /* GlpiRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */; };
0A452E0C1F9F703200CD531A /* ItemType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A452E0B1F9F703200CD531A /* ItemType.swift */; };
0A452E0E1F9F8A4400CD531A /* QueryGetAllItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A452E0D1F9F8A4300CD531A /* QueryGetAllItems.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -38,6 +39,7 @@
0A1CF5B21F97B3D00048E866 /* Routers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Routers.swift; sourceTree = "<group>"; };
0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlpiRequest.swift; sourceTree = "<group>"; };
0A452E0B1F9F703200CD531A /* ItemType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemType.swift; sourceTree = "<group>"; };
0A452E0D1F9F8A4300CD531A /* QueryGetAllItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueryGetAllItems.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -145,6 +147,7 @@
0A1CF5B21F97B3D00048E866 /* Routers.swift */,
0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */,
0A452E0B1F9F703200CD531A /* ItemType.swift */,
0A452E0D1F9F8A4300CD531A /* QueryGetAllItems.swift */,
);
name = Core;
sourceTree = "<group>";
Expand Down Expand Up @@ -280,6 +283,7 @@
files = (
0A1CF5B31F97B3D00048E866 /* Routers.swift in Sources */,
0A1CF5B61F97BBF60048E866 /* GlpiRequest.swift in Sources */,
0A452E0E1F9F8A4400CD531A /* QueryGetAllItems.swift in Sources */,
0A452E0C1F9F703200CD531A /* ItemType.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
81 changes: 81 additions & 0 deletions Source/QueryGetAllItems.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
/*
* Copyright © 2017 Teclib. All rights reserved.
*
* QueryGetAllItems.swift is part of Glpi
*
* Glpi is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Glpi is Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ------------------------------------------------------------------------------
* @author Hector Rondon
* @date 24/10/17
* @copyright Copyright © 2017 Teclib. All rights reserved.
* @license Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
* @link https://github.com/flyve-mdm/[name]
* @link https://flyve-mdm.com
* ------------------------------------------------------------------------------
*/


import Foundation

public enum orderType {
case ASC
case DESC
}

public struct QueryGetAllItems {
public var expandDropdowns: Bool?
public var getHateoas: Bool?
public var onlyId: Bool?
public var range: String?
public var sort: Int?
public var order: orderType?
public var searchText: String?
public var isDeleted: Bool?

public init() {}

var queryString: [String: AnyObject] {
get {
var query = [String: AnyObject]()
if expandDropdowns != nil {
query["expand_dropdowns"] = expandDropdowns as AnyObject
}
if getHateoas != nil {
query["get_hateoas"] = getHateoas as AnyObject
}
if onlyId != nil {
query["only_id"] = onlyId as AnyObject
}
if range != nil {
query["range"] = range as AnyObject
}
if sort != nil {
query["sort"] = sort as AnyObject
}
if order != nil {
query["order"] = order as AnyObject
}
if searchText != nil {
query["searchText"] = searchText as AnyObject
}
if isDeleted != nil {
query["is_deleted"] = isDeleted as AnyObject
}
return query
}
}
}

0 comments on commit 5d6cb5d

Please sign in to comment.