From 329d833e27ac63b5ad5cba6bfa1f3a00d657b8f4 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Wed, 18 Oct 2017 11:51:34 -0400 Subject: [PATCH 01/28] build(carthage): add dependencie to Alamofire --- .gitignore | 1 + Cartfile | 1 + Cartfile.resolved | 1 + Glpi.xcodeproj/project.pbxproj | 38 ++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 Cartfile create mode 100644 Cartfile.resolved diff --git a/.gitignore b/.gitignore index d861096..8c1125b 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ playground.xcworkspace # Carthage/Checkouts Carthage/Build +Carthage/Checkouts # fastlane # diff --git a/Cartfile b/Cartfile new file mode 100644 index 0000000..8c5b013 --- /dev/null +++ b/Cartfile @@ -0,0 +1 @@ +github "Alamofire/Alamofire" \ No newline at end of file diff --git a/Cartfile.resolved b/Cartfile.resolved new file mode 100644 index 0000000..a8c2ced --- /dev/null +++ b/Cartfile.resolved @@ -0,0 +1 @@ +github "Alamofire/Alamofire" "4.5.1" diff --git a/Glpi.xcodeproj/project.pbxproj b/Glpi.xcodeproj/project.pbxproj index 7adc820..f21444f 100644 --- a/Glpi.xcodeproj/project.pbxproj +++ b/Glpi.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 0A06BB211F913C2C001D53B5 /* Glpi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A06BB171F913C2C001D53B5 /* Glpi.framework */; }; 0A06BB261F913C2C001D53B5 /* GlpiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A06BB251F913C2C001D53B5 /* GlpiTests.swift */; }; 0A06BB281F913C2C001D53B5 /* Glpi.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A06BB1A1F913C2C001D53B5 /* Glpi.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 0A1CF5AC1F97ADF90048E866 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A1CF5AB1F97ADF90048E866 /* Alamofire.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -30,6 +31,7 @@ 0A06BB251F913C2C001D53B5 /* GlpiTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlpiTests.swift; sourceTree = ""; }; 0A06BB271F913C2C001D53B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 0A06BB361F91401D001D53B5 /* Glpi.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = Glpi.podspec; sourceTree = ""; }; + 0A1CF5AB1F97ADF90048E866 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Alamofire.framework; path = Carthage/Build/iOS/Alamofire.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -37,6 +39,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 0A1CF5AC1F97ADF90048E866 /* Alamofire.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -59,6 +62,7 @@ 0A06BB191F913C2C001D53B5 /* Source */, 0A06BB241F913C2C001D53B5 /* Tests */, 0A06BB181F913C2C001D53B5 /* Products */, + 0A1CF5AA1F97ADF90048E866 /* Frameworks */, ); sourceTree = ""; }; @@ -121,6 +125,14 @@ name = Documentation; sourceTree = ""; }; + 0A1CF5AA1F97ADF90048E866 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0A1CF5AB1F97ADF90048E866 /* Alamofire.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 0A87A3151F916A000080622B /* Core */ = { isa = PBXGroup; children = ( @@ -150,6 +162,7 @@ 0A06BB131F913C2C001D53B5 /* Frameworks */, 0A06BB141F913C2C001D53B5 /* Headers */, 0A06BB151F913C2C001D53B5 /* Resources */, + 0A1CF5AE1F97AE440048E866 /* ShellScript */, ); buildRules = ( ); @@ -234,6 +247,23 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 0A1CF5AE1F97AE440048E866 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework", + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/local/bin/carthage copy-frameworks"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 0A06BB121F913C2C001D53B5 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -385,6 +415,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = Source/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.3; @@ -409,6 +443,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = Source/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.3; From c45b9e79518c121d2d282501c3af87fd5390daeb Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Wed, 18 Oct 2017 17:15:03 -0400 Subject: [PATCH 02/28] feat(api): create URLRequest for init session with token --- Glpi.xcodeproj/project.pbxproj | 10 ++++ Source/GlpiRequest.swift | 57 +++++++++++++++++++ Source/Routers.swift | 100 +++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 Source/GlpiRequest.swift create mode 100644 Source/Routers.swift diff --git a/Glpi.xcodeproj/project.pbxproj b/Glpi.xcodeproj/project.pbxproj index f21444f..d589b96 100644 --- a/Glpi.xcodeproj/project.pbxproj +++ b/Glpi.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ 0A06BB261F913C2C001D53B5 /* GlpiTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A06BB251F913C2C001D53B5 /* GlpiTests.swift */; }; 0A06BB281F913C2C001D53B5 /* Glpi.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A06BB1A1F913C2C001D53B5 /* Glpi.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0A1CF5AC1F97ADF90048E866 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A1CF5AB1F97ADF90048E866 /* Alamofire.framework */; }; + 0A1CF5B31F97B3D00048E866 /* Routers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CF5B21F97B3D00048E866 /* Routers.swift */; }; + 0A1CF5B61F97BBF60048E866 /* GlpiRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -32,6 +34,8 @@ 0A06BB271F913C2C001D53B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 0A06BB361F91401D001D53B5 /* Glpi.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = Glpi.podspec; sourceTree = ""; }; 0A1CF5AB1F97ADF90048E866 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Alamofire.framework; path = Carthage/Build/iOS/Alamofire.framework; sourceTree = ""; }; + 0A1CF5B21F97B3D00048E866 /* Routers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Routers.swift; sourceTree = ""; }; + 0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlpiRequest.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -136,6 +140,8 @@ 0A87A3151F916A000080622B /* Core */ = { isa = PBXGroup; children = ( + 0A1CF5B21F97B3D00048E866 /* Routers.swift */, + 0A1CF5B51F97BBF60048E866 /* GlpiRequest.swift */, ); name = Core; sourceTree = ""; @@ -269,6 +275,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0A1CF5B31F97B3D00048E866 /* Routers.swift in Sources */, + 0A1CF5B61F97BBF60048E866 /* GlpiRequest.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -462,6 +470,7 @@ 0A06BB2F1F913C2C001D53B5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = H7XJV96LX2; INFOPLIST_FILE = Tests/Info.plist; @@ -476,6 +485,7 @@ 0A06BB301F913C2C001D53B5 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = H7XJV96LX2; INFOPLIST_FILE = Tests/Info.plist; diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift new file mode 100644 index 0000000..ac769f7 --- /dev/null +++ b/Source/GlpiRequest.swift @@ -0,0 +1,57 @@ +// +/* + * Copyright © 2017 Teclib. All rights reserved. + * + * Request.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 18/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 +import Alamofire + +public class GlpiRequest { + + public init() {} + + /** + Request a session token to uses other api endpoints. + - parameter: user token + */ + public func initSession(userToken: String, completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Router.initSession(userToken)) + .validate() + .responseJSON { response in + switch response.result { + case .success(let data): + completion(data) + case .failure(let error): + print(error.localizedDescription) + completion(nil) + } + } + } +} diff --git a/Source/Routers.swift b/Source/Routers.swift new file mode 100644 index 0000000..c36dd37 --- /dev/null +++ b/Source/Routers.swift @@ -0,0 +1,100 @@ +// +/* + * Copyright © 2017 Teclib. All rights reserved. + * + * Routers.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 18/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 +import Alamofire + +/// Enumerate endpoints methods +public enum Routers: URLRequestConvertible { + + /// GET /initSession + case initSession(String) + + /// get HTTP Method + var method: Alamofire.HTTPMethod { + switch self { + case .initSession: + return .get + } + } + + /// build up and return the URL for each endpoint + var path: String { + + switch self { + case .initSession(_ ) : + return "/initSession" + } + } + + /// build up and return the query for each endpoint + var query: String { + + switch self { + case .initSession(_ ) : + return "" + } + } + + /// build up and return the header for each endpoint + var header: [String: String] { + + switch self { + case .initSession(let userToken) : + + var dictHeader = [String: String]() + dictHeader["Content-Type"] = "application/json" + dictHeader["Authorization"] = "user_token \(userToken)" + + return dictHeader + } + } + + /** + Returns a URL request or throws if an `Error` was encountered + + - throws: An `Error` if the underlying `URLRequest` is `nil`. + - returns: A URL request. + */ + public func asURLRequest() throws -> URLRequest { + + let url = URL(string: "https://dev.flyve.org/glpi/apirest.php")! + var urlRequest = URLRequest(url: url.appendingPathComponent(path)) + + urlRequest.httpMethod = method.rawValue + + for (key, value) in header { + urlRequest.setValue(value, forHTTPHeaderField: key) + } + + return urlRequest + } +} From 6a6a50eb0be077b7177e0352196d3c8bbe47d5ff Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Wed, 18 Oct 2017 17:28:17 -0400 Subject: [PATCH 03/28] feat(api): request to init session with user token --- Source/GlpiRequest.swift | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index ac769f7..c25b69b 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -42,16 +42,39 @@ public class GlpiRequest { */ public func initSession(userToken: String, completion: @escaping (_ result: Any?) -> Void) { - Alamofire.request(Router.initSession(userToken)) + Alamofire.request(Routers.initSession(userToken)) .validate() .responseJSON { response in switch response.result { case .success(let data): completion(data) - case .failure(let error): - print(error.localizedDescription) - completion(nil) + case .failure(_ ): + completion(self.handlerError(response)) } } } + + /** + handler Error + - return: error message + */ + func handlerError(_ response: DataResponse) -> [String: String] { + + var errorObj = [String]() + var errorDict = [String: String]() + + if let data = response.data { + errorObj = try! JSONSerialization.jsonObject(with: data) as? [String] ?? [String]() + } + + if errorObj.count == 2 { + errorDict["error"] = errorObj[0] + errorDict["message"] = errorObj[1] + } else { + errorDict["error"] = "" + errorDict["message"] = "" + } + + return errorDict + } } From 738bffefa5e41d42fc11f515be473e56248ed20c Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Wed, 18 Oct 2017 17:31:23 -0400 Subject: [PATCH 04/28] test(example): add swiftint to sample project --- Example/.swiftlint.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Example/.swiftlint.yml diff --git a/Example/.swiftlint.yml b/Example/.swiftlint.yml new file mode 100644 index 0000000..f82bcce --- /dev/null +++ b/Example/.swiftlint.yml @@ -0,0 +1,8 @@ +disabled_rules: # rule identifiers to exclude from running + - function_body_length + - line_length + - identifier_name + - empty_enum_arguments + - trailing_whitespace +excluded: # paths to ignore during linting. Takes precedence over `included`. + - Pods From 73aac60c163a0c7cc55ef733ded2bbd877113b66 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Wed, 18 Oct 2017 17:32:29 -0400 Subject: [PATCH 05/28] test(example): request to init session with user token --- Example/Source/AppDelegate.swift | 4 ---- Example/Source/ViewController.swift | 13 +++++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Example/Source/AppDelegate.swift b/Example/Source/AppDelegate.swift index 63365f6..1b52ecd 100644 --- a/Example/Source/AppDelegate.swift +++ b/Example/Source/AppDelegate.swift @@ -34,7 +34,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { window = UIWindow(frame: UIScreen.main.bounds) @@ -65,7 +64,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - - } - diff --git a/Example/Source/ViewController.swift b/Example/Source/ViewController.swift index f82e6da..338d5d8 100644 --- a/Example/Source/ViewController.swift +++ b/Example/Source/ViewController.swift @@ -33,15 +33,20 @@ import Glpi class ViewController: UIViewController { override func viewDidLoad() { + + let glpi = GlpiRequest() + + glpi.initSession(userToken: "user_token") { result in + if let data = result { + print(data) + } + } + super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } - - } - From 18559efd06b43968ef4daf290b38c55c97592237 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 14:57:53 -0400 Subject: [PATCH 06/28] feat(api): allow to start session with app token --- Source/GlpiRequest.swift | 5 +++-- Source/Routers.swift | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index c25b69b..4e71e1b 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -39,10 +39,11 @@ public class GlpiRequest { /** Request a session token to uses other api endpoints. - parameter: user token + - parameter: app token (optional) */ - public func initSession(userToken: String, completion: @escaping (_ result: Any?) -> Void) { + public func initSession(userToken: String, appToken: String = "", completion: @escaping (_ result: Any?) -> Void) { - Alamofire.request(Routers.initSession(userToken)) + Alamofire.request(Routers.initSession(userToken, appToken)) .validate() .responseJSON { response in switch response.result { diff --git a/Source/Routers.swift b/Source/Routers.swift index c36dd37..b1c4274 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -36,7 +36,7 @@ import Alamofire public enum Routers: URLRequestConvertible { /// GET /initSession - case initSession(String) + case initSession(String, String) /// get HTTP Method var method: Alamofire.HTTPMethod { @@ -50,7 +50,7 @@ public enum Routers: URLRequestConvertible { var path: String { switch self { - case .initSession(_ ) : + case .initSession: return "/initSession" } } @@ -59,7 +59,7 @@ public enum Routers: URLRequestConvertible { var query: String { switch self { - case .initSession(_ ) : + case .initSession: return "" } } @@ -68,12 +68,16 @@ public enum Routers: URLRequestConvertible { var header: [String: String] { switch self { - case .initSession(let userToken) : + case .initSession(let userToken, let appToken) : var dictHeader = [String: String]() dictHeader["Content-Type"] = "application/json" dictHeader["Authorization"] = "user_token \(userToken)" + if !appToken.isEmpty { + dictHeader["App-Token"] = "user_token \(appToken)" + } + return dictHeader } } From ca8d084d11b2ea944bb86e188d1e0e0423481109 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 15:21:17 -0400 Subject: [PATCH 07/28] feat(api): request init session with basic authorization --- Source/GlpiRequest.swift | 20 ++++++++++++++++++++ Source/Routers.swift | 28 ++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index 4e71e1b..5ee58a7 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -55,6 +55,26 @@ public class GlpiRequest { } } + /** + Request a session token to uses other api endpoints. + - parameter: user + - parameter: password + - parameter: app token (optional) + */ + public func initSession(user: String, password: String, appToken: String = "", completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.initSessionByBasicAuth(user, password, appToken)) + .validate() + .responseJSON { response in + switch response.result { + case .success(let data): + completion(data) + case .failure(_ ): + completion(self.handlerError(response)) + } + } + } + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index b1c4274..6ea94df 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -35,13 +35,15 @@ import Alamofire /// Enumerate endpoints methods public enum Routers: URLRequestConvertible { - /// GET /initSession + /// GET /initSession case initSession(String, String) + /// GET /initSession + case initSessionByBasicAuth(String, String, String) /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { - case .initSession: + case .initSession, .initSessionByBasicAuth: return .get } } @@ -50,7 +52,7 @@ public enum Routers: URLRequestConvertible { var path: String { switch self { - case .initSession: + case .initSession, .initSessionByBasicAuth: return "/initSession" } } @@ -59,7 +61,7 @@ public enum Routers: URLRequestConvertible { var query: String { switch self { - case .initSession: + case .initSession, .initSessionByBasicAuth: return "" } } @@ -67,17 +69,27 @@ public enum Routers: URLRequestConvertible { /// build up and return the header for each endpoint var header: [String: String] { + var dictHeader = [String: String]() + dictHeader["Content-Type"] = "application/json" + switch self { case .initSession(let userToken, let appToken) : - - var dictHeader = [String: String]() - dictHeader["Content-Type"] = "application/json" + dictHeader["Authorization"] = "user_token \(userToken)" if !appToken.isEmpty { - dictHeader["App-Token"] = "user_token \(appToken)" + dictHeader["App-Token"] = appToken } + return dictHeader + case .initSessionByBasicAuth(let user, let password, let appToken): + let credentialData = "\(user):\(password)".data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))! + let base64Credentials = credentialData.base64EncodedString() + dictHeader["Authorization"] = "Basic \(base64Credentials)" + + if !appToken.isEmpty { + dictHeader["App-Token"] = appToken + } return dictHeader } } From 8d4e0a0aa0e8d6f21a26f0b121cd42674a823e2f Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:03:13 -0400 Subject: [PATCH 08/28] refactor(api): convert to class methods --- Example/Source/ViewController.swift | 4 +--- Source/GlpiRequest.swift | 25 ++++++++++++++----------- Source/Routers.swift | 4 ++++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Example/Source/ViewController.swift b/Example/Source/ViewController.swift index 338d5d8..1ac933d 100644 --- a/Example/Source/ViewController.swift +++ b/Example/Source/ViewController.swift @@ -34,9 +34,7 @@ class ViewController: UIViewController { override func viewDidLoad() { - let glpi = GlpiRequest() - - glpi.initSession(userToken: "user_token") { result in + GlpiRequest.initSession(userToken: "user_token") { result in if let data = result { print(data) } diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index 5ee58a7..8659ccc 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -32,25 +32,27 @@ import Foundation import Alamofire +/// Session Token +public var SESSION_TOKEN = String() + public class GlpiRequest { - - public init() {} - + /** Request a session token to uses other api endpoints. - parameter: user token - parameter: app token (optional) */ - public func initSession(userToken: String, appToken: String = "", completion: @escaping (_ result: Any?) -> Void) { + class public func initSession(userToken: String, appToken: String = "", completion: @escaping (_ result: Any?) -> Void) { Alamofire.request(Routers.initSession(userToken, appToken)) .validate() .responseJSON { response in switch response.result { - case .success(let data): - completion(data) + case .success(let result): + completion(result) case .failure(_ ): - completion(self.handlerError(response)) + SESSION_TOKEN = "" + completion(GlpiRequest.handlerError(response)) } } } @@ -67,10 +69,11 @@ public class GlpiRequest { .validate() .responseJSON { response in switch response.result { - case .success(let data): - completion(data) + case .success(let result): + completion(result) case .failure(_ ): - completion(self.handlerError(response)) + SESSION_TOKEN = "" + completion(GlpiRequest.handlerError(response)) } } } @@ -79,7 +82,7 @@ public class GlpiRequest { handler Error - return: error message */ - func handlerError(_ response: DataResponse) -> [String: String] { + class func handlerError(_ response: DataResponse) -> [String: String] { var errorObj = [String]() var errorDict = [String: String]() diff --git a/Source/Routers.swift b/Source/Routers.swift index 6ea94df..dee7540 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -91,6 +91,10 @@ public enum Routers: URLRequestConvertible { dictHeader["App-Token"] = appToken } return dictHeader + default: + + dictHeader["Session-Token"] = "user_token \(SESSION_TOKEN)" + return dictHeader } } From 4a1f6ff59ef6d69154b0d6dd225acbeb2b476870 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:15:04 -0400 Subject: [PATCH 09/28] feat(api): store token session after to start session --- Source/GlpiRequest.swift | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index 8659ccc..2298ee1 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -49,7 +49,19 @@ public class GlpiRequest { .responseJSON { response in switch response.result { case .success(let result): - completion(result) + do { + if let data = (result as AnyObject).data(using: String.Encoding.utf8.rawValue) { + if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] { + + if let session_token = json["session_token"] { + SESSION_TOKEN = session_token + } + completion(result) + } + } + } catch { + completion(GlpiRequest.handlerError(response)) + } case .failure(_ ): SESSION_TOKEN = "" completion(GlpiRequest.handlerError(response)) @@ -63,14 +75,26 @@ public class GlpiRequest { - parameter: password - parameter: app token (optional) */ - public func initSession(user: String, password: String, appToken: String = "", completion: @escaping (_ result: Any?) -> Void) { + class public func initSession(user: String, password: String, appToken: String = "", completion: @escaping (_ result: Any?) -> Void) { Alamofire.request(Routers.initSessionByBasicAuth(user, password, appToken)) .validate() .responseJSON { response in switch response.result { case .success(let result): - completion(result) + do { + if let data = (result as AnyObject).data(using: String.Encoding.utf8.rawValue) { + if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] { + + if let session_token = json["session_token"] { + SESSION_TOKEN = session_token + } + completion(result) + } + } + } catch { + completion(GlpiRequest.handlerError(response)) + } case .failure(_ ): SESSION_TOKEN = "" completion(GlpiRequest.handlerError(response)) From afb9fa1ac244af65502d49454096b4665a0cb6fa Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:22:17 -0400 Subject: [PATCH 10/28] feat(api): request kill current session --- Source/GlpiRequest.swift | 18 ++++++++++++++++++ Source/Routers.swift | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index 2298ee1..cc4a407 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -102,6 +102,24 @@ public class GlpiRequest { } } + /** + Request kill current session + */ + class public func killSession(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.killSession) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + SESSION_TOKEN = "" + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index dee7540..9516b84 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -39,11 +39,13 @@ public enum Routers: URLRequestConvertible { case initSession(String, String) /// GET /initSession case initSessionByBasicAuth(String, String, String) + /// GET /killSession + case killSession /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { - case .initSession, .initSessionByBasicAuth: + case .initSession, .initSessionByBasicAuth, .killSession: return .get } } @@ -54,6 +56,8 @@ public enum Routers: URLRequestConvertible { switch self { case .initSession, .initSessionByBasicAuth: return "/initSession" + case .killSession: + return "/killSession" } } @@ -61,7 +65,7 @@ public enum Routers: URLRequestConvertible { var query: String { switch self { - case .initSession, .initSessionByBasicAuth: + case .initSession, .initSessionByBasicAuth, .killSession: return "" } } From 9c9601961820ea9f7ab1abb1cb9fca7620c671c0 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:25:47 -0400 Subject: [PATCH 11/28] feat(api): request get my profiles --- Source/GlpiRequest.swift | 17 +++++++++++++++++ Source/Routers.swift | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index cc4a407..0397c87 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -120,6 +120,23 @@ public class GlpiRequest { } } + /** + Request get my profiles + */ + class public func getMyProfiles(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.getMyProfiles) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index 9516b84..293be45 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -41,11 +41,13 @@ public enum Routers: URLRequestConvertible { case initSessionByBasicAuth(String, String, String) /// GET /killSession case killSession + /// GET /getMyProfiles + case getMyProfiles /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { - case .initSession, .initSessionByBasicAuth, .killSession: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles: return .get } } @@ -58,6 +60,8 @@ public enum Routers: URLRequestConvertible { return "/initSession" case .killSession: return "/killSession" + case .getMyProfiles: + return "/getMyProfiles" } } @@ -65,7 +69,7 @@ public enum Routers: URLRequestConvertible { var query: String { switch self { - case .initSession, .initSessionByBasicAuth, .killSession: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles: return "" } } From 1d40f0493351551e2a3a06233fa634aa85b73cb2 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:30:08 -0400 Subject: [PATCH 12/28] feat(api): request get active profile --- Source/GlpiRequest.swift | 17 +++++++++++++++++ Source/Routers.swift | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index 0397c87..f761506 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -137,6 +137,23 @@ public class GlpiRequest { } } + /** + Request get active profile + */ + class public func getActiveProfile(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.getActiveProfile) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index 293be45..71db12c 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -43,11 +43,13 @@ public enum Routers: URLRequestConvertible { case killSession /// GET /getMyProfiles case getMyProfiles + /// GET /getActiveProfile + case getActiveProfile /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { - case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile: return .get } } @@ -62,6 +64,8 @@ public enum Routers: URLRequestConvertible { return "/killSession" case .getMyProfiles: return "/getMyProfiles" + case .getActiveProfile: + return "/getActiveProfile" } } @@ -69,7 +73,7 @@ public enum Routers: URLRequestConvertible { var query: String { switch self { - case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile: return "" } } From 8acc8ac69f0c99e5e8040df04cefb5f6bb26fe26 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:34:14 -0400 Subject: [PATCH 13/28] feat(api): request get my entities --- Source/GlpiRequest.swift | 17 +++++++++++++++++ Source/Routers.swift | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index f761506..b5b5647 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -154,6 +154,23 @@ public class GlpiRequest { } } + /** + Request get my entities + */ + class public func getMyEntities(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.getMyEntities) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index 71db12c..557f0b6 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -45,11 +45,13 @@ public enum Routers: URLRequestConvertible { case getMyProfiles /// GET /getActiveProfile case getActiveProfile + /// GET /getMyEntities + case getMyEntities /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { - case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, .getMyEntities: return .get } } @@ -66,6 +68,8 @@ public enum Routers: URLRequestConvertible { return "/getMyProfiles" case .getActiveProfile: return "/getActiveProfile" + case .getMyEntities: + return "/getMyEntities" } } @@ -73,7 +77,7 @@ public enum Routers: URLRequestConvertible { var query: String { switch self { - case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, .getMyEntities: return "" } } From dadbeadc55ca6ce881085a4263d351ba156d2b51 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:37:05 -0400 Subject: [PATCH 14/28] feat(api): request get active entities --- Source/GlpiRequest.swift | 17 +++++++++++++++++ Source/Routers.swift | 10 ++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index b5b5647..fd3c6b3 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -171,6 +171,23 @@ public class GlpiRequest { } } + /** + Request get active entities + */ + class public func getActiveEntities(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.getActiveEntities) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index 557f0b6..e13818e 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -47,11 +47,14 @@ public enum Routers: URLRequestConvertible { case getActiveProfile /// GET /getMyEntities case getMyEntities + /// GET /getActiveEntities + case getActiveEntities /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { - case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, .getMyEntities: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, + .getMyEntities, .getActiveEntities: return .get } } @@ -70,6 +73,8 @@ public enum Routers: URLRequestConvertible { return "/getActiveProfile" case .getMyEntities: return "/getMyEntities" + case .getActiveEntities: + return "/getActiveEntities" } } @@ -77,7 +82,8 @@ public enum Routers: URLRequestConvertible { var query: String { switch self { - case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, .getMyEntities: + case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, + .getMyEntities, .getActiveEntities: return "" } } From 839c62dcb694bd05cd89dce4c5bc0f16c97d2477 Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 16:50:45 -0400 Subject: [PATCH 15/28] feat(api): request get Glpi configuration --- Source/GlpiRequest.swift | 34 ++++++++++++++++++++++++++++++++++ Source/Routers.swift | 12 ++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index fd3c6b3..2a21e20 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -188,6 +188,40 @@ public class GlpiRequest { } } + /** + Request get full session information + */ + class public func getFullSession(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.getFullSession) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + + /** + Request get Glpi Configuration + */ + class public func getGlpiConfig(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.getGlpiConfig) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index e13818e..9ecd07d 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -49,12 +49,16 @@ public enum Routers: URLRequestConvertible { case getMyEntities /// GET /getActiveEntities case getActiveEntities + /// GET /getFullSession + case getFullSession + /// GET /getGlpiConfig + case getGlpiConfig /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, - .getMyEntities, .getActiveEntities: + .getMyEntities, .getActiveEntities, .getFullSession, .getGlpiConfig: return .get } } @@ -75,6 +79,10 @@ public enum Routers: URLRequestConvertible { return "/getMyEntities" case .getActiveEntities: return "/getActiveEntities" + case .getFullSession: + return "/getFullSession" + case .getGlpiConfig: + return "/getGlpiConfig" } } @@ -83,7 +91,7 @@ public enum Routers: URLRequestConvertible { switch self { case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, - .getMyEntities, .getActiveEntities: + .getMyEntities, .getActiveEntities, .getFullSession, .getGlpiConfig: return "" } } From 9e393617767c8c1b4538e8b509b9f5ed212fc11e Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 17:03:29 -0400 Subject: [PATCH 16/28] feat(api): request get multiple items --- Source/GlpiRequest.swift | 18 ++++++++++++++++++ Source/Routers.swift | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Source/GlpiRequest.swift b/Source/GlpiRequest.swift index 2a21e20..33ea8c2 100644 --- a/Source/GlpiRequest.swift +++ b/Source/GlpiRequest.swift @@ -222,6 +222,24 @@ public class GlpiRequest { } } + /** + Request get multiple items + */ + class public func getMultipleItems(completion: @escaping (_ result: Any?) -> Void) { + + Alamofire.request(Routers.getMultipleItems) + .validate() + .responseJSON { response in + switch response.result { + case .success(let result): + completion(result) + case .failure(_ ): + completion(GlpiRequest.handlerError(response)) + } + } + } + + /** handler Error - return: error message diff --git a/Source/Routers.swift b/Source/Routers.swift index 9ecd07d..6b8a2e5 100644 --- a/Source/Routers.swift +++ b/Source/Routers.swift @@ -53,12 +53,14 @@ public enum Routers: URLRequestConvertible { case getFullSession /// GET /getGlpiConfig case getGlpiConfig + /// GET /getMultipleItems + case getMultipleItems /// get HTTP Method var method: Alamofire.HTTPMethod { switch self { case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, - .getMyEntities, .getActiveEntities, .getFullSession, .getGlpiConfig: + .getMyEntities, .getActiveEntities, .getFullSession, .getGlpiConfig, .getMultipleItems: return .get } } @@ -83,6 +85,8 @@ public enum Routers: URLRequestConvertible { return "/getFullSession" case .getGlpiConfig: return "/getGlpiConfig" + case .getMultipleItems: + return "/getMultipleItems" } } @@ -91,7 +95,7 @@ public enum Routers: URLRequestConvertible { switch self { case .initSession, .initSessionByBasicAuth, .killSession, .getMyProfiles, .getActiveProfile, - .getMyEntities, .getActiveEntities, .getFullSession, .getGlpiConfig: + .getMyEntities, .getActiveEntities, .getFullSession, .getGlpiConfig, .getMultipleItems: return "" } } From bcc89db28a1774b225deff4a7df3298bbf900735 Mon Sep 17 00:00:00 2001 From: Naylin Medina Date: Wed, 18 Oct 2017 15:53:25 -0400 Subject: [PATCH 17/28] build(settings): add YAML file for bot settings --- .github/settings.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/settings.yml diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..ad03d83 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,46 @@ +repository: + name: ios-library-glpi + description: GLPI API Client Library for Swift + homepage: http://flyve.org/ios-library-glpi/ + topics: glpi-api, swift, library + private: false + has_issues: true + has_wiki: false + has_downloads: true + default_branch: develop + allow_squash_merge: true + allow_merge_commit: false + allow_rebase_merge: true +labels: + - name: bug + color: f44336 + - name: build + color: 795548 + - name: ci + color: fbca04 + - name: documentation + color: 607d8b + - name: duplicate + color: 9e9e9e + - name: feature + color: 3f51b5 + - name: hacktoberfest + color: ff625f + - name: invalid + color: cddc39 + - name: performance + color: 009688 + - name: question + color: ff5722 + - name: refactor + color: 9c27b0 + - name: style + color: 2196f3 + - name: test + color: 8bc34a + - name: wontfix + color: ffffff + - name: help wanted + color: 33aa3f + - name: good first issue + color: 7057ff From 28fdda8b311893cdcb1d2f9a2ca600f793613907 Mon Sep 17 00:00:00 2001 From: Naylin Medina Date: Wed, 18 Oct 2017 15:56:56 -0400 Subject: [PATCH 18/28] docs(github): add pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..a367521 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,41 @@ +## Checklist +Please check if your PR fulfills the following requirements: + +- [ ] The commit message follows our guidelines: [Conventional Commit](https://github.com/flyve-mdm/ios-library-glpi/blob/develop/CONTRIBUTING.md#submit-a-pull-request) +- [ ] Tests for the changes have been added (for bug fixes / features) +- [ ] Docs have been added / updated (for bug fixes / features) + + +## PR Type +What kind of change does this PR introduce? + + +``` +[ ] Bugfix +[ ] Feature +[ ] Code style update (formatting, local variables) +[ ] Refactoring (no functional changes, no api changes) +[ ] Build related changes +[ ] CI related changes +[ ] Documentation content changes +[ ] Other... Please describe: +``` + +## What is the current behavior? + + +Issue # N/A + + +## What is the new behavior? + + +## Does this PR introduce a breaking change? +``` +[ ] Yes +[ ] No +``` + + + +## Other information From 594a2a530de4718f62d46eb2efae95f363060c6e Mon Sep 17 00:00:00 2001 From: Naylin Medina Date: Wed, 18 Oct 2017 15:58:33 -0400 Subject: [PATCH 19/28] docs(github): add issue template --- .github/ISSUE_TEMPLATE.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..336d752 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,37 @@ + + +## I'm submitting a... + +

+[ ] Regression (a behavior that used to work and stopped working in a new release)
+[ ] Bug report  
+[ ] Feature request
+[ ] Documentation issue or request
+[ ] Support request => Please do not submit support request here, instead see https://github.com/flyve-mdm/ios-library-glpi/blob/develop/CONTRIBUTING.md#questions-or-doubts
+
+ +## Current behavior + + + +## Expected behavior + + + +## Minimal reproduction of the problem with instructions + + +## What is the motivation / use case for changing the behavior? + + + +## Environment +

+Library Version: X.Y.Z
+
+
+ From 7ec60f2d3ae82e0757ba056f51e9e1d43579f6dd Mon Sep 17 00:00:00 2001 From: Naylin Date: Wed, 18 Oct 2017 16:35:38 -0400 Subject: [PATCH 20/28] docs(readme): update content --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 96eec55..3e203c9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,70 @@ -# Glpi -GLPI APIs Client Library for Swift for REST \ No newline at end of file +# GLPI API Library for Swift + +![GLPI banner](https://user-images.githubusercontent.com/29282308/31666160-8ad74b1a-b34b-11e7-839b-043255af4f58.png) + +[![License](https://img.shields.io/badge/license-Apache_v2.0-blue.svg)](https://github.com/flyve-mdm/ios-library-glpi/blob/develop/LICENSE.md) +[![Follow twitter](https://img.shields.io/twitter/follow/FlyveMDM.svg?style=social&label=Twitter&style=flat-square)](https://twitter.com/FlyveMDM) +[![Telegram Group](https://img.shields.io/badge/Telegram-Group-blue.svg)](https://t.me/flyvemdm) +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) + +GLPI (_Gestionnaire Libre de Parc Informatique_) is a free IT Asset Management, issue tracking system and service desk solution. This open source software is written in PHP. + +It helps companies to manage their information system, since it's able to build an inventory of all the organization's assets and to manage administrative and financial tasks. + +## Table of Contents + +* [Synopsis](#synopsis) +* [Build Status](#build-status) +* [Documentation](#documentation) +* [Versioning](#versioning) +* [Contact](#contact) +* [Contribute](#contribute) +* [Copying](#copying) + +## Synopsis + +This library created in Swift features several functionalities common to all GLPI APIs, for example: + +- HTTP transport to APIs +- Error handling +- Authentication +- JSON parsing +- Media download/upload +- Batching + +You will be able to call all the methods that belong to the [GLPI REST API](https://dev.flyve.org/glpi/apirest.php), for more information visit the [projects website](http://flyve.org/ios-library-glpi/). + +This project is a **work in progress**. The information here provided could change at any given time. + +## Build Status + +|**Release channel**|Beta Channel| +|:---:|:---:| +|[![Circle CI build](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/master.svg?style=svg)](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/master)|[![Circle CI build](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/develop.svg?style=svg)](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/develop)| + +## Documentation + +We maintain a detailed documentation of the project in the [project's website](http://flyve.org/ios-library-glpi/). + +## Versioning + +In order to provide transparency on our release cycle and to maintain backward compatibility, Flyve MDM is maintained under [the Semantic Versioning guidelines](http://semver.org/). We are committed to following and complying with the rules, the best we can. + +See [the tags section of our GitHub project](https://github.com/flyve-mdm/ios-library-glpi/tags) for changelogs for each release version of Flyve MDM. Release announcement posts on [the official Teclib' blog](http://www.teclib-edition.com/en/communities/blog-posts/) contain summaries of the most noteworthy changes made in each release. + +## Contact + +For notices about major changes and general discussion of Flyve MDM development, subscribe to the [/r/FlyveMDM](http://www.reddit.com/r/FlyveMDM) subreddit. +You can also chat with us via IRC in [#flyve-mdm on freenode](http://webchat.freenode.net/?channels=flyve-mdm]) or [@flyvemdmdev on Telegram](https://t.me/flyvemdmdev). + +## Contribute + +Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our +guidelines for [contributing](./CONTRIBUTING.md) and then check out one of our issues in the [Issues Dashboard](https://github.com/flyve-mdm/ios-library-glpi/issues). + +## Copying + +* **Name**: [Flyve MDM](https://flyve-mdm.com/) is a registered trademark of [Teclib'](http://www.teclib-edition.com/en/). +* **Code**: you can redistribute it and/or modify + it under the terms of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0). +* **Documentation**: released under Attribution 4.0 International ([CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)). \ No newline at end of file From 593b1ce7847778b90ea141c721f651b5203d5c84 Mon Sep 17 00:00:00 2001 From: Naylin Date: Wed, 18 Oct 2017 16:43:35 -0400 Subject: [PATCH 21/28] docs(contributing): add contribute guidelines --- CONTRIBUTING.md | 132 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2612ebb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,132 @@ +# How to contribute + +Welcome to our ever growing community! We are more than happy to accept external contributions to the project in the form of feedback, bug reports and even better, pull requests! + +As a contributor, we present you the guidelines to start contributing in any of the Flyve MDM projects. + +* [Code of Conduct](#code-of-conduct) +* [Questions or Doubts?](#questions-or-doubts) +* [Bugs](#found-a-bug) +* [Proposed Features](#new-feature) +* [Submitting issues and Pull Requests](#submitting) +* [Coding Rules](#coding-rules) + +### Code of Conduct + +As contributors and maintainers of the Flyve MDM projects, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities. + +Communication through any of our channels (GitHub, Telegram, mailing lists, Google+, Twitter, etc.) must be constructive and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. + +We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the Flyve MDM projects to do the same. + +If any member of the community violates this code of conduct, the maintainers of the Flyve MDM projects may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate. + +If you are subject to or witness unacceptable behavior, or have any other concerns, please email us at ml-flyvemdm@teclib.com + +### Questions or Doubts + +If you require general support assistance, you can find us in [Telegram](https://t.me/flyvemdm), and we'll help you as soon as possible. + +For notices about major changes and general discussion of Flyve MDM development, subscribe to the [/r/FlyveMDM](https://www.reddit.com/r/FlyveMDM/) subreddit. You can also chat with us via IRC in [#flyve-mdm on freenode](http://webchat.freenode.net/?channels=flyve-mdm%5D). + +This is in order to keep GitHub issues for bug reports and new features only. + +### Found a bug? + +You can let us know in our [issue Dashboard](#submit-an-issue). + +Know how to fix it? Great! Then submit a [pull request](#submit-a-pull-request). + +### New feature? + +You can _**request**_ a new feature by submitting an issue, and if you would like to _**implement**_ a new feature, please submit an issue with a proposal for your work first, to be sure that we can use it, this will allow us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. Please consider what kind of change it is: + +- For a Major Feature, first open an issue and outline your proposal so it can be discussed. +- Small Features can be crafted and directly submitted as a Pull Request. + +## Submitting + +### Submit an Issue + +Before submitting the issue please check the [issue tracker](https://github.com/flyve-mdm/ios-library-glpi/issues), there exists the possibility that the bug was already reported by other contributor. + +This way you help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues. + +We'll work very hard to fix all the issues without delay, but before fixing it we need to confirm it, for that we require you to provide us of the following information: + +- Overview of the Issue - if an error is being thrown a description of the problem is extremely helpful +- Motivation for or Use Case - explain why this is a bug for you +- Project Version(s) +- Device Operating System & Model - is this a problem with all devices or only specific ones? +- Reproduce the Error - provide a live example or an unambiguous set of steps. +- Related Issues - has a similar issue been reported before? +- Suggest a Fix - if you can't fix the bug yourself, perhaps you can point to what might be causing the problem (line of code or commit) + +You can file new issues by filling out our [new issue form](https://github.com/flyve-mdm/ios-library-glpi/issues/new). + +### Submit a Pull Request + +Before submitting your Pull Request check for an open or closed PR that relates to your submission. We don't want to duplicate efforts. + +- Make your changes in a new branch, the project is organized according to the branch model [Git Flow](http://git-flow.readthedocs.io/en/latest/), though this is not mandatory it's really useful: + +``` + git checkout -b my-fix-branch develop +``` + +- Follow our [Coding Rules](#coding-rules). + +- Commit your changes using a descriptive commit message that follows the [Conventional Commit](http://conventionalcommits.org/). This is **indispensable** since the release notes and changelogs are automatically generated from these messages. + +- Push your branch to GitHub: + +``` + git push origin my-fix-branch +``` + +- In GitHub, send a pull request to our [Repository](https://github.com/flyve-mdm/ios-library-glpi). +- If we suggest changes then: + + - Make the required updates. + + - Rebase your branch and force push to your GitHub repository (this will update your Pull Request): + + **That's it! :tada: Thank you for your contribution!** + +#### After your pull request is merged + +You can safely delete your branch and pull the changes from the main (upstream) repository: + +- Delete the remote branch on GitHub either through the GitHub web UI or your local shell as you prefer. + +## Coding Rules + +To ensure consistency throughout the source code, keep these rules in mind as you are working: + +- All features or bug fixes must be [tested](#test-and-build) by one or more specs (unit-tests). +- All methods must be documented. + +## Test and Build + +There are currently three ways of running the unit test, you can only select one as you prefer. + +#### From Fastlane + +fastlane scan + +That's all you need to run your tests. If you want more control, here are some available parameters: + +fastlane scan —workspace "Example.xcworkspace" —scheme "AppName" —device "iPhone 6" —clean + +#### From Xcode + +Here is a detailed guide of [Testing with Xcode](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/05-running_tests.html), that will show you the commands and building settings for testing Apps and libraries. + +#### From Command line + + xcodebuild \ + -workspace MyApp.xcworkspace \ + -scheme "MyApp" \ + -sdk iphonesimulator \ + -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \ + test \ No newline at end of file From 00050a31b612093b559fefd521f687db2a9e0be5 Mon Sep 17 00:00:00 2001 From: Naylin Date: Fri, 20 Oct 2017 15:52:28 -0400 Subject: [PATCH 22/28] docs(readme): update content --- README.md | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3e203c9..2facc6b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ ![GLPI banner](https://user-images.githubusercontent.com/29282308/31666160-8ad74b1a-b34b-11e7-839b-043255af4f58.png) -[![License](https://img.shields.io/badge/license-Apache_v2.0-blue.svg)](https://github.com/flyve-mdm/ios-library-glpi/blob/develop/LICENSE.md) -[![Follow twitter](https://img.shields.io/twitter/follow/FlyveMDM.svg?style=social&label=Twitter&style=flat-square)](https://twitter.com/FlyveMDM) -[![Telegram Group](https://img.shields.io/badge/Telegram-Group-blue.svg)](https://t.me/flyvemdm) +[![License](https://img.shields.io/badge/license-Apache_v2.0-blue.svg)](https://github.com/glpi-project/swift-library-glpi/blob/develop/LICENSE.md) +[![Follow twitter](https://img.shields.io/twitter/follow/GLPI_PROJECT.svg?style=social&label=Twitter&style=flat-square)](https://twitter.com/GLPI_PROJECT) +![Project Status: WIP](http://www.repostatus.org/badges/latest/wip.svg) +[![Telegram Group](https://img.shields.io/badge/Telegram-Group-blue.svg)](https://t.me/glpien) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) GLPI (_Gestionnaire Libre de Parc Informatique_) is a free IT Asset Management, issue tracking system and service desk solution. This open source software is written in PHP. @@ -25,46 +26,44 @@ It helps companies to manage their information system, since it's able to build This library created in Swift features several functionalities common to all GLPI APIs, for example: -- HTTP transport to APIs -- Error handling -- Authentication -- JSON parsing -- Media download/upload -- Batching +* HTTP transport to APIs. +* Error handling +* Authentication +* JSON parsing +* Custom Item Types +* Media download/upload +* Batching -You will be able to call all the methods that belong to the [GLPI REST API](https://dev.flyve.org/glpi/apirest.php), for more information visit the [projects website](http://flyve.org/ios-library-glpi/). - -This project is a **work in progress**. The information here provided could change at any given time. +You will be able to call all the methods that belong to the [GLPI REST API](https://dev.flyve.org/glpi/apirest.php), for more information visit the [projects website](https://glpi-project.github.io/swift-library-glpi/). ## Build Status |**Release channel**|Beta Channel| |:---:|:---:| -|[![Circle CI build](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/master.svg?style=svg)](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/master)|[![Circle CI build](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/develop.svg?style=svg)](https://circleci.com/gh/flyve-mdm/ios-library-glpi/tree/develop)| +|[![Circle CI build](https://circleci.com/gh/glpi-project/swift-library-glpi/tree/master.svg?style=svg)](https://circleci.com/gh/glpi-project/swift-library-glpi/tree/master)|[![Circle CI build](https://circleci.com/gh/glpi-project/swift-library-glpi/tree/develop.svg?style=svg)](https://circleci.com/gh/glpi-project/swift-library-glpi/tree/develop)| ## Documentation -We maintain a detailed documentation of the project in the [project's website](http://flyve.org/ios-library-glpi/). +We maintain a detailed documentation of the project in the [project's website](https://glpi-project.github.io/swift-library-glpi/). ## Versioning -In order to provide transparency on our release cycle and to maintain backward compatibility, Flyve MDM is maintained under [the Semantic Versioning guidelines](http://semver.org/). We are committed to following and complying with the rules, the best we can. +In order to provide transparency on our release cycle and to maintain backward compatibility, GLPI is maintained under [the Semantic Versioning guidelines](http://semver.org/). We are committed to following and complying with the rules, the best we can. -See [the tags section of our GitHub project](https://github.com/flyve-mdm/ios-library-glpi/tags) for changelogs for each release version of Flyve MDM. Release announcement posts on [the official Teclib' blog](http://www.teclib-edition.com/en/communities/blog-posts/) contain summaries of the most noteworthy changes made in each release. +See [the tags section of our GitHub project](https://github.com/glpi-project/swift-library-glpi/tags) for changelogs for each release version of GLPI. Release announcement posts on [the official Teclib' blog](http://www.teclib-edition.com/en/communities/blog-posts/) contain summaries of the most noteworthy changes made in each release. ## Contact -For notices about major changes and general discussion of Flyve MDM development, subscribe to the [/r/FlyveMDM](http://www.reddit.com/r/FlyveMDM) subreddit. -You can also chat with us via IRC in [#flyve-mdm on freenode](http://webchat.freenode.net/?channels=flyve-mdm]) or [@flyvemdmdev on Telegram](https://t.me/flyvemdmdev). +For notices about major changes and general discussion of GLPI development, subscribe to the [/r/glpi](http://www.reddit.com/r/glpi) subreddit. +You can also chat with us via IRC in [#GLPI on freenode](http://webchat.freenode.net/?channels=GLPI]) or [@glpien on Telegram](https://t.me/glpien). ## Contribute Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our -guidelines for [contributing](./CONTRIBUTING.md) and then check out one of our issues in the [Issues Dashboard](https://github.com/flyve-mdm/ios-library-glpi/issues). +guidelines for [contributing](./CONTRIBUTING.md) and then check out one of our issues in the [Issues Dashboard](https://github.com/glpi-project/swift-library-glpi/issues). ## Copying -* **Name**: [Flyve MDM](https://flyve-mdm.com/) is a registered trademark of [Teclib'](http://www.teclib-edition.com/en/). * **Code**: you can redistribute it and/or modify it under the terms of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0). * **Documentation**: released under Attribution 4.0 International ([CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)). \ No newline at end of file From dbd9e83640df0fcfd2d1310b5f541e09c3f7e968 Mon Sep 17 00:00:00 2001 From: Naylin Date: Fri, 20 Oct 2017 15:58:57 -0400 Subject: [PATCH 23/28] docs(contributing): update content --- CONTRIBUTING.md | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2612ebb..6a40db8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Welcome to our ever growing community! We are more than happy to accept external contributions to the project in the form of feedback, bug reports and even better, pull requests! -As a contributor, we present you the guidelines to start contributing in any of the Flyve MDM projects. +As a contributor, we present you the guidelines to start contributing in any of the GLPI projects. * [Code of Conduct](#code-of-conduct) * [Questions or Doubts?](#questions-or-doubts) @@ -13,21 +13,21 @@ As a contributor, we present you the guidelines to start contributing in any of ### Code of Conduct -As contributors and maintainers of the Flyve MDM projects, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities. +As contributors and maintainers of the GLPI projects, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities. Communication through any of our channels (GitHub, Telegram, mailing lists, Google+, Twitter, etc.) must be constructive and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. -We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the Flyve MDM projects to do the same. +We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the GLPI projects to do the same. -If any member of the community violates this code of conduct, the maintainers of the Flyve MDM projects may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate. +If any member of the community violates this code of conduct, the maintainers of the GLPI projects may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate. -If you are subject to or witness unacceptable behavior, or have any other concerns, please email us at ml-flyvemdm@teclib.com +If you are subject to or witness unacceptable behavior, or have any other concerns, please email us at glpi@teclib.com ### Questions or Doubts -If you require general support assistance, you can find us in [Telegram](https://t.me/flyvemdm), and we'll help you as soon as possible. +If you require general support assistance, you can find us in [Telegram](https://t.me/glpien), and we'll help you as soon as possible. -For notices about major changes and general discussion of Flyve MDM development, subscribe to the [/r/FlyveMDM](https://www.reddit.com/r/FlyveMDM/) subreddit. You can also chat with us via IRC in [#flyve-mdm on freenode](http://webchat.freenode.net/?channels=flyve-mdm%5D). +For notices about major changes and general discussion of GLPI development, subscribe to the [/r/glpi](https://www.reddit.com/r/glpi/) subreddit. You can also chat with us via IRC in [#GLPI on freenode](http://webchat.freenode.net/?channels=GLPI). This is in order to keep GitHub issues for bug reports and new features only. @@ -41,55 +41,55 @@ Know how to fix it? Great! Then submit a [pull request](#submit-a-pull-request). You can _**request**_ a new feature by submitting an issue, and if you would like to _**implement**_ a new feature, please submit an issue with a proposal for your work first, to be sure that we can use it, this will allow us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project. Please consider what kind of change it is: -- For a Major Feature, first open an issue and outline your proposal so it can be discussed. -- Small Features can be crafted and directly submitted as a Pull Request. +* For a Major Feature, first open an issue and outline your proposal so it can be discussed. +* Small Features can be crafted and directly submitted as a Pull Request. ## Submitting ### Submit an Issue -Before submitting the issue please check the [issue tracker](https://github.com/flyve-mdm/ios-library-glpi/issues), there exists the possibility that the bug was already reported by other contributor. +Before submitting the issue please check the [issue tracker](https://github.com/glpi-project/swift-library-glpi/issues), there exists the possibility that the bug was already reported by other contributor. This way you help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues. We'll work very hard to fix all the issues without delay, but before fixing it we need to confirm it, for that we require you to provide us of the following information: -- Overview of the Issue - if an error is being thrown a description of the problem is extremely helpful -- Motivation for or Use Case - explain why this is a bug for you -- Project Version(s) -- Device Operating System & Model - is this a problem with all devices or only specific ones? -- Reproduce the Error - provide a live example or an unambiguous set of steps. -- Related Issues - has a similar issue been reported before? -- Suggest a Fix - if you can't fix the bug yourself, perhaps you can point to what might be causing the problem (line of code or commit) +* Overview of the Issue - if an error is being thrown a description of the problem is extremely helpful +* Motivation for or Use Case - explain why this is a bug for you +* Library Version(s) +* Device Operating System & Model - is this a problem with all devices or only specific ones? +* Reproduce the Error - provide a live example or an unambiguous set of steps. +* Related Issues - has a similar issue been reported before? +* Suggest a Fix - if you can't fix the bug yourself, perhaps you can point to what might be causing the problem (line of code or commit) -You can file new issues by filling out our [new issue form](https://github.com/flyve-mdm/ios-library-glpi/issues/new). +You can file new issues by filling out our [new issue form](https://github.com/glpi-project/swift-library-glpi/issues/new). ### Submit a Pull Request Before submitting your Pull Request check for an open or closed PR that relates to your submission. We don't want to duplicate efforts. -- Make your changes in a new branch, the project is organized according to the branch model [Git Flow](http://git-flow.readthedocs.io/en/latest/), though this is not mandatory it's really useful: +* Make your changes in a new branch, the project is organized according to the branch model [Git Flow](http://git-flow.readthedocs.io/en/latest/), though this is not mandatory it's really useful: -``` +```console git checkout -b my-fix-branch develop ``` -- Follow our [Coding Rules](#coding-rules). +* Follow our [Coding Rules](#coding-rules). -- Commit your changes using a descriptive commit message that follows the [Conventional Commit](http://conventionalcommits.org/). This is **indispensable** since the release notes and changelogs are automatically generated from these messages. +* Commit your changes using a descriptive commit message that follows the [Conventional Commit](http://conventionalcommits.org/). This is **indispensable** since the release notes and changelogs are automatically generated from these messages. -- Push your branch to GitHub: +* Push your branch to GitHub: -``` +```console git push origin my-fix-branch ``` -- In GitHub, send a pull request to our [Repository](https://github.com/flyve-mdm/ios-library-glpi). -- If we suggest changes then: +* In GitHub, send a pull request to our [Repository](https://github.com/glpi-project/swift-library-glpi/). +* If we suggest changes then: - - Make the required updates. + * Make the required updates. - - Rebase your branch and force push to your GitHub repository (this will update your Pull Request): + * Rebase your branch and force push to your GitHub repository (this will update your Pull Request): **That's it! :tada: Thank you for your contribution!** @@ -97,14 +97,14 @@ Before submitting your Pull Request check for an open or closed PR that relates You can safely delete your branch and pull the changes from the main (upstream) repository: -- Delete the remote branch on GitHub either through the GitHub web UI or your local shell as you prefer. +* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as you prefer. ## Coding Rules To ensure consistency throughout the source code, keep these rules in mind as you are working: -- All features or bug fixes must be [tested](#test-and-build) by one or more specs (unit-tests). -- All methods must be documented. +* All features or bug fixes must be [tested](#test-and-build) by one or more specs (unit-tests). +* All methods must be documented. ## Test and Build From ff87b3522af1cc71d09c97c8d993df5b52b09ade Mon Sep 17 00:00:00 2001 From: Naylin Date: Fri, 20 Oct 2017 16:01:27 -0400 Subject: [PATCH 24/28] build(config): add app to invite contributors --- .github/invite-contributors.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/invite-contributors.yml diff --git a/.github/invite-contributors.yml b/.github/invite-contributors.yml new file mode 100644 index 0000000..3101634 --- /dev/null +++ b/.github/invite-contributors.yml @@ -0,0 +1,2 @@ +# Team Name +contributors \ No newline at end of file From 6abbb18b7a24eeca3267215865f13eccb290f9a1 Mon Sep 17 00:00:00 2001 From: Naylin Date: Fri, 20 Oct 2017 16:05:01 -0400 Subject: [PATCH 25/28] docs(settings): update homepage and name --- .github/settings.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/settings.yml b/.github/settings.yml index ad03d83..13d75fa 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -1,7 +1,7 @@ repository: - name: ios-library-glpi + name: swift-library-glpi description: GLPI API Client Library for Swift - homepage: http://flyve.org/ios-library-glpi/ + homepage: https://glpi-project.github.io/swift-library-glpi/ topics: glpi-api, swift, library private: false has_issues: true From acfa4d4c0553be30e348b6fdbe24cf91ec821c38 Mon Sep 17 00:00:00 2001 From: Naylin Date: Fri, 20 Oct 2017 16:07:58 -0400 Subject: [PATCH 26/28] docs(github): update content fix link change code block for list --- .github/PULL_REQUEST_TEMPLATE.md | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a367521..71819d5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,25 +1,22 @@ ## Checklist Please check if your PR fulfills the following requirements: -- [ ] The commit message follows our guidelines: [Conventional Commit](https://github.com/flyve-mdm/ios-library-glpi/blob/develop/CONTRIBUTING.md#submit-a-pull-request) +- [ ] The commit message follows our guidelines: [Conventional Commit](http://conventionalcommits.org/) - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) - ## PR Type What kind of change does this PR introduce? - -``` -[ ] Bugfix -[ ] Feature -[ ] Code style update (formatting, local variables) -[ ] Refactoring (no functional changes, no api changes) -[ ] Build related changes -[ ] CI related changes -[ ] Documentation content changes -[ ] Other... Please describe: -``` + +- [ ] Bugfix +- [ ] Feature +- [ ] Code style update (formatting, local variables) +- [ ] Refactoring (no functional changes, no api changes) +- [ ] Build related changes +- [ ] CI related changes +- [ ] Documentation content changes +- [ ] Other... Please describe: ## What is the current behavior? @@ -31,10 +28,10 @@ Issue # N/A ## Does this PR introduce a breaking change? -``` -[ ] Yes -[ ] No -``` + +- [ ] Yes +- [ ] No + From e62e5be0ff7471ed30c84b18e920d41227d27a28 Mon Sep 17 00:00:00 2001 From: Naylin Date: Fri, 20 Oct 2017 16:09:40 -0400 Subject: [PATCH 27/28] docs(github): update content fix link change code block for list --- .github/ISSUE_TEMPLATE.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 336d752..eef2e5c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,13 +4,13 @@ PLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATI ## I'm submitting a... -

-[ ] Regression (a behavior that used to work and stopped working in a new release)
-[ ] Bug report  
-[ ] Feature request
-[ ] Documentation issue or request
-[ ] Support request => Please do not submit support request here, instead see https://github.com/flyve-mdm/ios-library-glpi/blob/develop/CONTRIBUTING.md#questions-or-doubts
-
+ +- [ ] Regression (a behavior that used to work and stopped working in a new release) +- [ ] Bug report +- [ ] Feature request +- [ ] Documentation issue or request +- [ ] Support request => Please do not submit support request here, instead see https://github.com/glpi-project/swift-library-glpi/blob/develop/CONTRIBUTING.md#questions-or-doubts + ## Current behavior From 732bb7823fd8f4b182ed262ee0f8d18688163c5c Mon Sep 17 00:00:00 2001 From: Hector Rondon Date: Fri, 20 Oct 2017 17:33:14 -0400 Subject: [PATCH 28/28] ci(circle): configure carthage --- ci/scripts/install.sh | 2 ++ circle.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/ci/scripts/install.sh b/ci/scripts/install.sh index b6616a3..41fbe48 100755 --- a/ci/scripts/install.sh +++ b/ci/scripts/install.sh @@ -39,6 +39,8 @@ gem install bundler brew install node # Install jq for json parse brew install jq +# Install carthage +brew install carthage # Install standard-version scope global npm i -g standard-version # Install conventional-github-releaser scope global diff --git a/circle.yml b/circle.yml index 8920cdc..023f521 100644 --- a/circle.yml +++ b/circle.yml @@ -16,6 +16,7 @@ dependencies: - source "${SCRIPT_PATH}/bundler_config.sh" override: - source "${SCRIPT_PATH}/install.sh" + - carthage update test: pre: - source "${SCRIPT_PATH}/fastlane_config.sh"