Skip to content

Commit 5d6cb5d

Browse files
Hector Rondonajsb85
authored andcommitted
feat(request): create structure to handle parameters in getAllItems
1 parent 397de63 commit 5d6cb5d

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

Glpi.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
0A1CF5B31F97B3D00048E866 /* Routers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CF5B21F97B3D00048E866 /* Routers.swift */; };
1515
0A1CF5B61F97BBF60048E866 /* GlpiRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */; };
1616
0A452E0C1F9F703200CD531A /* ItemType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A452E0B1F9F703200CD531A /* ItemType.swift */; };
17+
0A452E0E1F9F8A4400CD531A /* QueryGetAllItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A452E0D1F9F8A4300CD531A /* QueryGetAllItems.swift */; };
1718
/* End PBXBuildFile section */
1819

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

4345
/* Begin PBXFrameworksBuildPhase section */
@@ -145,6 +147,7 @@
145147
0A1CF5B21F97B3D00048E866 /* Routers.swift */,
146148
0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */,
147149
0A452E0B1F9F703200CD531A /* ItemType.swift */,
150+
0A452E0D1F9F8A4300CD531A /* QueryGetAllItems.swift */,
148151
);
149152
name = Core;
150153
sourceTree = "<group>";
@@ -280,6 +283,7 @@
280283
files = (
281284
0A1CF5B31F97B3D00048E866 /* Routers.swift in Sources */,
282285
0A1CF5B61F97BBF60048E866 /* GlpiRequest.swift in Sources */,
286+
0A452E0E1F9F8A4400CD531A /* QueryGetAllItems.swift in Sources */,
283287
0A452E0C1F9F703200CD531A /* ItemType.swift in Sources */,
284288
);
285289
runOnlyForDeploymentPostprocessing = 0;

Source/QueryGetAllItems.swift

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//
2+
/*
3+
* Copyright © 2017 Teclib. All rights reserved.
4+
*
5+
* QueryGetAllItems.swift is part of Glpi
6+
*
7+
* Glpi is a subproject of Flyve MDM. Flyve MDM is a mobile
8+
* device management software.
9+
*
10+
* Glpi is Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
* ------------------------------------------------------------------------------
22+
* @author Hector Rondon
23+
* @date 24/10/17
24+
* @copyright Copyright © 2017 Teclib. All rights reserved.
25+
* @license Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0
26+
* @link https://github.com/flyve-mdm/[name]
27+
* @link https://flyve-mdm.com
28+
* ------------------------------------------------------------------------------
29+
*/
30+
31+
32+
import Foundation
33+
34+
public enum orderType {
35+
case ASC
36+
case DESC
37+
}
38+
39+
public struct QueryGetAllItems {
40+
public var expandDropdowns: Bool?
41+
public var getHateoas: Bool?
42+
public var onlyId: Bool?
43+
public var range: String?
44+
public var sort: Int?
45+
public var order: orderType?
46+
public var searchText: String?
47+
public var isDeleted: Bool?
48+
49+
public init() {}
50+
51+
var queryString: [String: AnyObject] {
52+
get {
53+
var query = [String: AnyObject]()
54+
if expandDropdowns != nil {
55+
query["expand_dropdowns"] = expandDropdowns as AnyObject
56+
}
57+
if getHateoas != nil {
58+
query["get_hateoas"] = getHateoas as AnyObject
59+
}
60+
if onlyId != nil {
61+
query["only_id"] = onlyId as AnyObject
62+
}
63+
if range != nil {
64+
query["range"] = range as AnyObject
65+
}
66+
if sort != nil {
67+
query["sort"] = sort as AnyObject
68+
}
69+
if order != nil {
70+
query["order"] = order as AnyObject
71+
}
72+
if searchText != nil {
73+
query["searchText"] = searchText as AnyObject
74+
}
75+
if isDeleted != nil {
76+
query["is_deleted"] = isDeleted as AnyObject
77+
}
78+
return query
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)