diff --git a/JAMFKit/.swiftlint.yml b/JAMFKit/.swiftlint.yml index 3d4b557..9b335bb 100644 --- a/JAMFKit/.swiftlint.yml +++ b/JAMFKit/.swiftlint.yml @@ -2,3 +2,4 @@ included: - Sources line_length: 200 +function_body_length: 50 # JSS objects can get be pretty big diff --git a/JAMFKit/JAMFKit.xcodeproj/project.pbxproj b/JAMFKit/JAMFKit.xcodeproj/project.pbxproj index 1b0df55..6edddee 100644 --- a/JAMFKit/JAMFKit.xcodeproj/project.pbxproj +++ b/JAMFKit/JAMFKit.xcodeproj/project.pbxproj @@ -9,18 +9,16 @@ /* Begin PBXBuildFile section */ 52D6D9871BEFF229002C0205 /* JAMFKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6D97C1BEFF229002C0205 /* JAMFKit.framework */; }; DD7502881C68FEDE006590AF /* JAMFKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6DA0F1BF000BD002C0205 /* JAMFKit.framework */; }; - ED071F4E1FB33275003FAB0E /* HardwareGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F4D1FB33275003FAB0E /* HardwareGeneral.swift */; }; - ED071F4F1FB33275003FAB0E /* HardwareGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F4D1FB33275003FAB0E /* HardwareGeneral.swift */; }; - ED071F521FB33399003FAB0E /* HardwareTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F511FB33399003FAB0E /* HardwareTests.swift */; }; - ED071F531FB33399003FAB0E /* HardwareTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F511FB33399003FAB0E /* HardwareTests.swift */; }; - ED071F551FB333A6003FAB0E /* HardwareGeneralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F541FB333A6003FAB0E /* HardwareGeneralTests.swift */; }; - ED071F561FB333A6003FAB0E /* HardwareGeneralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F541FB333A6003FAB0E /* HardwareGeneralTests.swift */; }; - ED071F581FB333AF003FAB0E /* HardwareLocationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F571FB333AF003FAB0E /* HardwareLocationTests.swift */; }; - ED071F591FB333AF003FAB0E /* HardwareLocationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F571FB333AF003FAB0E /* HardwareLocationTests.swift */; }; - ED071F5B1FB33D11003FAB0E /* HardwareRemoteManagement.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5A1FB33D11003FAB0E /* HardwareRemoteManagement.swift */; }; - ED071F5C1FB33D11003FAB0E /* HardwareRemoteManagement.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5A1FB33D11003FAB0E /* HardwareRemoteManagement.swift */; }; - ED071F5E1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5D1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift */; }; - ED071F5F1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5D1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift */; }; + ED071F4E1FB33275003FAB0E /* ComputerGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F4D1FB33275003FAB0E /* ComputerGeneral.swift */; }; + ED071F4F1FB33275003FAB0E /* ComputerGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F4D1FB33275003FAB0E /* ComputerGeneral.swift */; }; + ED071F551FB333A6003FAB0E /* ComputerGeneralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F541FB333A6003FAB0E /* ComputerGeneralTests.swift */; }; + ED071F561FB333A6003FAB0E /* ComputerGeneralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F541FB333A6003FAB0E /* ComputerGeneralTests.swift */; }; + ED071F581FB333AF003FAB0E /* ComputerLocationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F571FB333AF003FAB0E /* ComputerLocationTests.swift */; }; + ED071F591FB333AF003FAB0E /* ComputerLocationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F571FB333AF003FAB0E /* ComputerLocationTests.swift */; }; + ED071F5B1FB33D11003FAB0E /* ComputerRemoteManagement.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5A1FB33D11003FAB0E /* ComputerRemoteManagement.swift */; }; + ED071F5C1FB33D11003FAB0E /* ComputerRemoteManagement.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5A1FB33D11003FAB0E /* ComputerRemoteManagement.swift */; }; + ED071F5E1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5D1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift */; }; + ED071F5F1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F5D1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift */; }; ED071F611FB34222003FAB0E /* PreciseDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F601FB34222003FAB0E /* PreciseDate.swift */; }; ED071F621FB34222003FAB0E /* PreciseDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED071F601FB34222003FAB0E /* PreciseDate.swift */; }; ED1B70E31FEA973A00005658 /* Department.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1B70E21FEA973A00005658 /* Department.swift */; }; @@ -33,16 +31,22 @@ ED1D930F1FA20FB6005589F5 /* BaseObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1D930C1FA20FB0005589F5 /* BaseObject.swift */; }; ED1D93101FA20FB9005589F5 /* BaseObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1D93081FA20F86005589F5 /* BaseObjectTests.swift */; }; ED1D93111FA20FB9005589F5 /* BaseObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1D93081FA20F86005589F5 /* BaseObjectTests.swift */; }; + ED326B821FFD1B3900809793 /* MobileDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B811FFD1B3900809793 /* MobileDevice.swift */; }; + ED326B831FFD1B3900809793 /* MobileDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B811FFD1B3900809793 /* MobileDevice.swift */; }; + ED326B861FFD1D6200809793 /* MobileDeviceGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B851FFD1D6200809793 /* MobileDeviceGeneral.swift */; }; + ED326B871FFD1D6200809793 /* MobileDeviceGeneral.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B851FFD1D6200809793 /* MobileDeviceGeneral.swift */; }; + ED326B8A1FFD2AAA00809793 /* MobileDeviceGeneralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B891FFD2AAA00809793 /* MobileDeviceGeneralTests.swift */; }; + ED326B8B1FFD2AAA00809793 /* MobileDeviceGeneralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B891FFD2AAA00809793 /* MobileDeviceGeneralTests.swift */; }; + ED326B8D1FFD2AB500809793 /* MobileDeviceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B8C1FFD2AB500809793 /* MobileDeviceTests.swift */; }; + ED326B8E1FFD2AB500809793 /* MobileDeviceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED326B8C1FFD2AB500809793 /* MobileDeviceTests.swift */; }; ED3597831FAA11B6006E3B66 /* JSONHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED3597821FAA11B6006E3B66 /* JSONHelper.swift */; }; ED3597841FAA11B6006E3B66 /* JSONHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED3597821FAA11B6006E3B66 /* JSONHelper.swift */; }; ED3E04801FFCCA58001600CA /* NetworkSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED3E047F1FFCCA58001600CA /* NetworkSegment.swift */; }; ED3E04811FFCCA58001600CA /* NetworkSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED3E047F1FFCCA58001600CA /* NetworkSegment.swift */; }; ED3E04831FFCCDAD001600CA /* NetworkSegmentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED3E04821FFCCDAD001600CA /* NetworkSegmentTests.swift */; }; ED3E04841FFCCDAD001600CA /* NetworkSegmentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED3E04821FFCCDAD001600CA /* NetworkSegmentTests.swift */; }; - ED56BB7C1FB1B15700416C1A /* Hardware.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED56BB7B1FB1B15700416C1A /* Hardware.swift */; }; - ED56BB7D1FB1B15700416C1A /* Hardware.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED56BB7B1FB1B15700416C1A /* Hardware.swift */; }; - ED56BB7F1FB1B24B00416C1A /* HardwareLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED56BB7E1FB1B24B00416C1A /* HardwareLocation.swift */; }; - ED56BB801FB1B24B00416C1A /* HardwareLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED56BB7E1FB1B24B00416C1A /* HardwareLocation.swift */; }; + ED56BB7F1FB1B24B00416C1A /* ComputerLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED56BB7E1FB1B24B00416C1A /* ComputerLocation.swift */; }; + ED56BB801FB1B24B00416C1A /* ComputerLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED56BB7E1FB1B24B00416C1A /* ComputerLocation.swift */; }; ED5B01471FB357F8005F0C47 /* PreciseDateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5B01461FB357F8005F0C47 /* PreciseDateTests.swift */; }; ED5B01481FB357F8005F0C47 /* PreciseDateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5B01461FB357F8005F0C47 /* PreciseDateTests.swift */; }; ED6C4AE31FAC61DF007B7026 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7383A01FAB75CE006259FC /* User.swift */; }; @@ -59,8 +63,8 @@ ED7BF1061FFCD9C100F47566 /* Computer.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7BF1041FFCD9C100F47566 /* Computer.swift */; }; ED7BF1081FFCDA9100F47566 /* ComputerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7BF1071FFCDA9100F47566 /* ComputerTests.swift */; }; ED7BF1091FFCDA9100F47566 /* ComputerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7BF1071FFCDA9100F47566 /* ComputerTests.swift */; }; - ED7BF10B1FFCE03400F47566 /* HardwarePurchasingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7BF10A1FFCE03400F47566 /* HardwarePurchasingTests.swift */; }; - ED7BF10C1FFCE03400F47566 /* HardwarePurchasingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7BF10A1FFCE03400F47566 /* HardwarePurchasingTests.swift */; }; + ED7BF10B1FFCE03400F47566 /* ComputerPurchasingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7BF10A1FFCE03400F47566 /* ComputerPurchasingTests.swift */; }; + ED7BF10C1FFCE03400F47566 /* ComputerPurchasingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED7BF10A1FFCE03400F47566 /* ComputerPurchasingTests.swift */; }; ED9826F51FEAB14300DD5411 /* Printer.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED9826F41FEAB14300DD5411 /* Printer.swift */; }; ED9826F61FEAB14300DD5411 /* Printer.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED9826F41FEAB14300DD5411 /* Printer.swift */; }; ED9EF3F11FEABC7E00676AB3 /* PrinterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED9EF3F01FEABC7E00676AB3 /* PrinterTests.swift */; }; @@ -73,8 +77,8 @@ EDB698FC1FECEF6000C021E6 /* NetbootServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDB698FA1FECEF6000C021E6 /* NetbootServer.swift */; }; EDB698FE1FECF20800C021E6 /* NetbootServerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDB698FD1FECF20800C021E6 /* NetbootServerTests.swift */; }; EDB698FF1FECF20800C021E6 /* NetbootServerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDB698FD1FECF20800C021E6 /* NetbootServerTests.swift */; }; - EDCE84B01FC3152E0066AA75 /* HardwarePurchasing.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDCE84AF1FC3152E0066AA75 /* HardwarePurchasing.swift */; }; - EDCE84B11FC3152E0066AA75 /* HardwarePurchasing.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDCE84AF1FC3152E0066AA75 /* HardwarePurchasing.swift */; }; + EDCE84B01FC3152E0066AA75 /* ComputerPurchasing.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDCE84AF1FC3152E0066AA75 /* ComputerPurchasing.swift */; }; + EDCE84B11FC3152E0066AA75 /* ComputerPurchasing.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDCE84AF1FC3152E0066AA75 /* ComputerPurchasing.swift */; }; EDFE806E1FEA76EA00169C39 /* Building.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDFE806D1FEA76EA00169C39 /* Building.swift */; }; EDFE806F1FEA76EA00169C39 /* Building.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDFE806D1FEA76EA00169C39 /* Building.swift */; }; EDFE80711FEA773600169C39 /* BuildingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDFE80701FEA773600169C39 /* BuildingTests.swift */; }; @@ -105,23 +109,25 @@ AD2FAA261CD0B6D800659CF4 /* JAMFKit.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = JAMFKit.plist; sourceTree = ""; }; AD2FAA281CD0B6E100659CF4 /* JAMFKitTests.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = JAMFKitTests.plist; sourceTree = ""; }; DD75027A1C68FCFC006590AF /* JAMFKit-macOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "JAMFKit-macOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - ED071F4D1FB33275003FAB0E /* HardwareGeneral.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwareGeneral.swift; sourceTree = ""; }; - ED071F511FB33399003FAB0E /* HardwareTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwareTests.swift; sourceTree = ""; }; - ED071F541FB333A6003FAB0E /* HardwareGeneralTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwareGeneralTests.swift; sourceTree = ""; }; - ED071F571FB333AF003FAB0E /* HardwareLocationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwareLocationTests.swift; sourceTree = ""; }; - ED071F5A1FB33D11003FAB0E /* HardwareRemoteManagement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwareRemoteManagement.swift; sourceTree = ""; }; - ED071F5D1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwareRemoteManagementTests.swift; sourceTree = ""; }; + ED071F4D1FB33275003FAB0E /* ComputerGeneral.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerGeneral.swift; sourceTree = ""; }; + ED071F541FB333A6003FAB0E /* ComputerGeneralTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerGeneralTests.swift; sourceTree = ""; }; + ED071F571FB333AF003FAB0E /* ComputerLocationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerLocationTests.swift; sourceTree = ""; }; + ED071F5A1FB33D11003FAB0E /* ComputerRemoteManagement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerRemoteManagement.swift; sourceTree = ""; }; + ED071F5D1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerRemoteManagementTests.swift; sourceTree = ""; }; ED071F601FB34222003FAB0E /* PreciseDate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreciseDate.swift; sourceTree = ""; }; ED1B70E21FEA973A00005658 /* Department.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Department.swift; sourceTree = ""; }; ED1B70E51FEA981800005658 /* DepartmentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepartmentTests.swift; sourceTree = ""; }; ED1D93081FA20F86005589F5 /* BaseObjectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseObjectTests.swift; sourceTree = ""; }; ED1D930A1FA20FAB005589F5 /* Identifiable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Identifiable.swift; sourceTree = ""; }; ED1D930C1FA20FB0005589F5 /* BaseObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseObject.swift; sourceTree = ""; }; + ED326B811FFD1B3900809793 /* MobileDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileDevice.swift; sourceTree = ""; }; + ED326B851FFD1D6200809793 /* MobileDeviceGeneral.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MobileDeviceGeneral.swift; path = ../../../../JamfKit/Sources/Models/MobileDevice/MobileDeviceGeneral.swift; sourceTree = ""; }; + ED326B891FFD2AAA00809793 /* MobileDeviceGeneralTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MobileDeviceGeneralTests.swift; path = ../../../../JamfKit/Tests/Models/MobileDevice/MobileDeviceGeneralTests.swift; sourceTree = ""; }; + ED326B8C1FFD2AB500809793 /* MobileDeviceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileDeviceTests.swift; sourceTree = ""; }; ED3597821FAA11B6006E3B66 /* JSONHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONHelper.swift; sourceTree = ""; }; ED3E047F1FFCCA58001600CA /* NetworkSegment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = NetworkSegment.swift; path = ../../../JamfKit/Sources/Models/NetworkSegment.swift; sourceTree = ""; }; ED3E04821FFCCDAD001600CA /* NetworkSegmentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkSegmentTests.swift; sourceTree = ""; }; - ED56BB7B1FB1B15700416C1A /* Hardware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hardware.swift; sourceTree = ""; }; - ED56BB7E1FB1B24B00416C1A /* HardwareLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwareLocation.swift; sourceTree = ""; }; + ED56BB7E1FB1B24B00416C1A /* ComputerLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerLocation.swift; sourceTree = ""; }; ED5B01461FB357F8005F0C47 /* PreciseDateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreciseDateTests.swift; sourceTree = ""; }; ED71F2B41FA9ED890056790C /* Mocks.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Mocks.bundle; sourceTree = ""; }; ED73839A1FAB5AD9006259FC /* Site.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Site.swift; sourceTree = ""; }; @@ -130,14 +136,14 @@ ED7383A21FAB7D5A006259FC /* UserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserTests.swift; sourceTree = ""; }; ED7BF1041FFCD9C100F47566 /* Computer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Computer.swift; sourceTree = ""; }; ED7BF1071FFCDA9100F47566 /* ComputerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerTests.swift; sourceTree = ""; }; - ED7BF10A1FFCE03400F47566 /* HardwarePurchasingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwarePurchasingTests.swift; sourceTree = ""; }; + ED7BF10A1FFCE03400F47566 /* ComputerPurchasingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerPurchasingTests.swift; sourceTree = ""; }; ED9826F41FEAB14300DD5411 /* Printer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Printer.swift; sourceTree = ""; }; ED9EF3F01FEABC7E00676AB3 /* PrinterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrinterTests.swift; sourceTree = ""; }; EDA3CFD11FFC100500B22D36 /* SMTPServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SMTPServer.swift; path = ../../../JamfKit/Sources/Models/SMTPServer.swift; sourceTree = ""; }; EDA3CFD41FFC195100B22D36 /* SMTPServerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SMTPServerTests.swift; path = ../../../JamfKit/Tests/Models/SMTPServerTests.swift; sourceTree = ""; }; EDB698FA1FECEF6000C021E6 /* NetbootServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetbootServer.swift; sourceTree = ""; }; EDB698FD1FECF20800C021E6 /* NetbootServerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetbootServerTests.swift; sourceTree = ""; }; - EDCE84AF1FC3152E0066AA75 /* HardwarePurchasing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HardwarePurchasing.swift; sourceTree = ""; }; + EDCE84AF1FC3152E0066AA75 /* ComputerPurchasing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComputerPurchasing.swift; sourceTree = ""; }; EDFE806D1FEA76EA00169C39 /* Building.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Building.swift; sourceTree = ""; }; EDFE80701FEA773600169C39 /* BuildingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuildingTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -241,16 +247,16 @@ name = Tests; sourceTree = ""; }; - ED071F501FB33386003FAB0E /* Hardware */ = { + ED071F501FB33386003FAB0E /* Computer */ = { isa = PBXGroup; children = ( - ED071F541FB333A6003FAB0E /* HardwareGeneralTests.swift */, - ED071F571FB333AF003FAB0E /* HardwareLocationTests.swift */, - ED7BF10A1FFCE03400F47566 /* HardwarePurchasingTests.swift */, - ED071F5D1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift */, - ED071F511FB33399003FAB0E /* HardwareTests.swift */, + ED071F541FB333A6003FAB0E /* ComputerGeneralTests.swift */, + ED071F571FB333AF003FAB0E /* ComputerLocationTests.swift */, + ED7BF10A1FFCE03400F47566 /* ComputerPurchasingTests.swift */, + ED071F5D1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift */, + ED7BF1071FFCDA9100F47566 /* ComputerTests.swift */, ); - path = Hardware; + path = Computer; sourceTree = ""; }; ED1D93051FA20F43005589F5 /* Models */ = { @@ -258,9 +264,9 @@ children = ( ED1D930C1FA20FB0005589F5 /* BaseObject.swift */, EDFE806D1FEA76EA00169C39 /* Building.swift */, - ED7BF1041FFCD9C100F47566 /* Computer.swift */, + ED56BB7A1FB1B14400416C1A /* Computer */, ED1B70E21FEA973A00005658 /* Department.swift */, - ED56BB7A1FB1B14400416C1A /* Hardware */, + ED326B841FFD1CA800809793 /* MobileDevice */, EDB698FA1FECEF6000C021E6 /* NetbootServer.swift */, ED3E047F1FFCCA58001600CA /* NetworkSegment.swift */, ED071F601FB34222003FAB0E /* PreciseDate.swift */, @@ -285,9 +291,9 @@ children = ( ED1D93081FA20F86005589F5 /* BaseObjectTests.swift */, EDFE80701FEA773600169C39 /* BuildingTests.swift */, - ED7BF1071FFCDA9100F47566 /* ComputerTests.swift */, + ED071F501FB33386003FAB0E /* Computer */, ED1B70E51FEA981800005658 /* DepartmentTests.swift */, - ED071F501FB33386003FAB0E /* Hardware */, + ED326B881FFD2A9700809793 /* MobileDevice */, EDB698FD1FECF20800C021E6 /* NetbootServerTests.swift */, ED3E04821FFCCDAD001600CA /* NetworkSegmentTests.swift */, ED5B01461FB357F8005F0C47 /* PreciseDateTests.swift */, @@ -299,6 +305,24 @@ path = Models; sourceTree = ""; }; + ED326B841FFD1CA800809793 /* MobileDevice */ = { + isa = PBXGroup; + children = ( + ED326B811FFD1B3900809793 /* MobileDevice.swift */, + ED326B851FFD1D6200809793 /* MobileDeviceGeneral.swift */, + ); + path = MobileDevice; + sourceTree = ""; + }; + ED326B881FFD2A9700809793 /* MobileDevice */ = { + isa = PBXGroup; + children = ( + ED326B891FFD2AAA00809793 /* MobileDeviceGeneralTests.swift */, + ED326B8C1FFD2AB500809793 /* MobileDeviceTests.swift */, + ); + path = MobileDevice; + sourceTree = ""; + }; ED3597811FAA1182006E3B66 /* Helpers */ = { isa = PBXGroup; children = ( @@ -307,16 +331,16 @@ path = Helpers; sourceTree = ""; }; - ED56BB7A1FB1B14400416C1A /* Hardware */ = { + ED56BB7A1FB1B14400416C1A /* Computer */ = { isa = PBXGroup; children = ( - ED56BB7B1FB1B15700416C1A /* Hardware.swift */, - ED071F4D1FB33275003FAB0E /* HardwareGeneral.swift */, - ED56BB7E1FB1B24B00416C1A /* HardwareLocation.swift */, - EDCE84AF1FC3152E0066AA75 /* HardwarePurchasing.swift */, - ED071F5A1FB33D11003FAB0E /* HardwareRemoteManagement.swift */, + ED7BF1041FFCD9C100F47566 /* Computer.swift */, + ED071F4D1FB33275003FAB0E /* ComputerGeneral.swift */, + ED56BB7E1FB1B24B00416C1A /* ComputerLocation.swift */, + EDCE84AF1FC3152E0066AA75 /* ComputerPurchasing.swift */, + ED071F5A1FB33D11003FAB0E /* ComputerRemoteManagement.swift */, ); - path = Hardware; + path = Computer; sourceTree = ""; }; ED71F2B31FA9ED720056790C /* Resources */ = { @@ -538,21 +562,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - ED071F5B1FB33D11003FAB0E /* HardwareRemoteManagement.swift in Sources */, + ED326B861FFD1D6200809793 /* MobileDeviceGeneral.swift in Sources */, + ED071F5B1FB33D11003FAB0E /* ComputerRemoteManagement.swift in Sources */, ED7383A11FAB75CE006259FC /* User.swift in Sources */, ED1D930B1FA20FAB005589F5 /* Identifiable.swift in Sources */, EDFE806E1FEA76EA00169C39 /* Building.swift in Sources */, - ED56BB7C1FB1B15700416C1A /* Hardware.swift in Sources */, ED9826F51FEAB14300DD5411 /* Printer.swift in Sources */, ED73839B1FAB5AD9006259FC /* Site.swift in Sources */, - ED56BB7F1FB1B24B00416C1A /* HardwareLocation.swift in Sources */, + ED56BB7F1FB1B24B00416C1A /* ComputerLocation.swift in Sources */, ED071F611FB34222003FAB0E /* PreciseDate.swift in Sources */, - EDCE84B01FC3152E0066AA75 /* HardwarePurchasing.swift in Sources */, - ED071F4E1FB33275003FAB0E /* HardwareGeneral.swift in Sources */, + EDCE84B01FC3152E0066AA75 /* ComputerPurchasing.swift in Sources */, + ED071F4E1FB33275003FAB0E /* ComputerGeneral.swift in Sources */, ED1D930D1FA20FB0005589F5 /* BaseObject.swift in Sources */, ED3E04801FFCCA58001600CA /* NetworkSegment.swift in Sources */, EDB698FB1FECEF6000C021E6 /* NetbootServer.swift in Sources */, EDA3CFD21FFC100500B22D36 /* SMTPServer.swift in Sources */, + ED326B821FFD1B3900809793 /* MobileDevice.swift in Sources */, ED7BF1051FFCD9C100F47566 /* Computer.swift in Sources */, ED1B70E31FEA973A00005658 /* Department.swift in Sources */, ); @@ -565,16 +590,17 @@ ED7BF1081FFCDA9100F47566 /* ComputerTests.swift in Sources */, ED3E04831FFCCDAD001600CA /* NetworkSegmentTests.swift in Sources */, EDB698FE1FECF20800C021E6 /* NetbootServerTests.swift in Sources */, - ED071F5E1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift in Sources */, + ED071F5E1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift in Sources */, ED5B01471FB357F8005F0C47 /* PreciseDateTests.swift in Sources */, - ED071F551FB333A6003FAB0E /* HardwareGeneralTests.swift in Sources */, + ED071F551FB333A6003FAB0E /* ComputerGeneralTests.swift in Sources */, ED1B70E61FEA981800005658 /* DepartmentTests.swift in Sources */, ED9EF3F11FEABC7E00676AB3 /* PrinterTests.swift in Sources */, ED7383A31FAB7D5A006259FC /* UserTests.swift in Sources */, - ED7BF10B1FFCE03400F47566 /* HardwarePurchasingTests.swift in Sources */, - ED071F521FB33399003FAB0E /* HardwareTests.swift in Sources */, + ED326B8A1FFD2AAA00809793 /* MobileDeviceGeneralTests.swift in Sources */, + ED7BF10B1FFCE03400F47566 /* ComputerPurchasingTests.swift in Sources */, ED73839E1FAB5B09006259FC /* SiteTests.swift in Sources */, - ED071F581FB333AF003FAB0E /* HardwareLocationTests.swift in Sources */, + ED071F581FB333AF003FAB0E /* ComputerLocationTests.swift in Sources */, + ED326B8D1FFD2AB500809793 /* MobileDeviceTests.swift in Sources */, EDA3CFD51FFC195100B22D36 /* SMTPServerTests.swift in Sources */, ED1D93111FA20FB9005589F5 /* BaseObjectTests.swift in Sources */, ED3597831FAA11B6006E3B66 /* JSONHelper.swift in Sources */, @@ -586,21 +612,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - ED071F5C1FB33D11003FAB0E /* HardwareRemoteManagement.swift in Sources */, + ED326B871FFD1D6200809793 /* MobileDeviceGeneral.swift in Sources */, + ED071F5C1FB33D11003FAB0E /* ComputerRemoteManagement.swift in Sources */, ED6C4AE31FAC61DF007B7026 /* User.swift in Sources */, ED1D930F1FA20FB6005589F5 /* BaseObject.swift in Sources */, EDFE806F1FEA76EA00169C39 /* Building.swift in Sources */, - ED56BB7D1FB1B15700416C1A /* Hardware.swift in Sources */, ED9826F61FEAB14300DD5411 /* Printer.swift in Sources */, ED73839C1FAB5AD9006259FC /* Site.swift in Sources */, - ED56BB801FB1B24B00416C1A /* HardwareLocation.swift in Sources */, + ED56BB801FB1B24B00416C1A /* ComputerLocation.swift in Sources */, ED071F621FB34222003FAB0E /* PreciseDate.swift in Sources */, - EDCE84B11FC3152E0066AA75 /* HardwarePurchasing.swift in Sources */, - ED071F4F1FB33275003FAB0E /* HardwareGeneral.swift in Sources */, + EDCE84B11FC3152E0066AA75 /* ComputerPurchasing.swift in Sources */, + ED071F4F1FB33275003FAB0E /* ComputerGeneral.swift in Sources */, ED1D930E1FA20FB3005589F5 /* Identifiable.swift in Sources */, ED3E04811FFCCA58001600CA /* NetworkSegment.swift in Sources */, EDB698FC1FECEF6000C021E6 /* NetbootServer.swift in Sources */, EDA3CFD31FFC100500B22D36 /* SMTPServer.swift in Sources */, + ED326B831FFD1B3900809793 /* MobileDevice.swift in Sources */, ED7BF1061FFCD9C100F47566 /* Computer.swift in Sources */, ED1B70E41FEA973A00005658 /* Department.swift in Sources */, ); @@ -613,16 +640,17 @@ ED7BF1091FFCDA9100F47566 /* ComputerTests.swift in Sources */, ED3E04841FFCCDAD001600CA /* NetworkSegmentTests.swift in Sources */, EDB698FF1FECF20800C021E6 /* NetbootServerTests.swift in Sources */, - ED071F5F1FB33DF9003FAB0E /* HardwareRemoteManagementTests.swift in Sources */, + ED071F5F1FB33DF9003FAB0E /* ComputerRemoteManagementTests.swift in Sources */, ED5B01481FB357F8005F0C47 /* PreciseDateTests.swift in Sources */, - ED071F561FB333A6003FAB0E /* HardwareGeneralTests.swift in Sources */, + ED071F561FB333A6003FAB0E /* ComputerGeneralTests.swift in Sources */, ED1B70E71FEA981800005658 /* DepartmentTests.swift in Sources */, ED9EF3F21FEABC7E00676AB3 /* PrinterTests.swift in Sources */, ED7383A41FAB7D5A006259FC /* UserTests.swift in Sources */, - ED7BF10C1FFCE03400F47566 /* HardwarePurchasingTests.swift in Sources */, - ED071F531FB33399003FAB0E /* HardwareTests.swift in Sources */, + ED326B8B1FFD2AAA00809793 /* MobileDeviceGeneralTests.swift in Sources */, + ED7BF10C1FFCE03400F47566 /* ComputerPurchasingTests.swift in Sources */, ED73839F1FAB5B09006259FC /* SiteTests.swift in Sources */, - ED071F591FB333AF003FAB0E /* HardwareLocationTests.swift in Sources */, + ED071F591FB333AF003FAB0E /* ComputerLocationTests.swift in Sources */, + ED326B8E1FFD2AB500809793 /* MobileDeviceTests.swift in Sources */, EDA3CFD61FFC195100B22D36 /* SMTPServerTests.swift in Sources */, ED1D93101FA20FB9005589F5 /* BaseObjectTests.swift in Sources */, ED3597841FAA11B6006E3B66 /* JSONHelper.swift in Sources */, diff --git a/JAMFKit/Sources/Models/BaseObject.swift b/JAMFKit/Sources/Models/BaseObject.swift index 3232714..5babc6a 100644 --- a/JAMFKit/Sources/Models/BaseObject.swift +++ b/JAMFKit/Sources/Models/BaseObject.swift @@ -5,6 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // +/// Represents the common denominator between all the JSS objects which must contains at least an `identifier` and a `name` properties. public class BaseObject: Identifiable, CustomStringConvertible { // MARK: - Constants diff --git a/JAMFKit/Sources/Models/Building.swift b/JAMFKit/Sources/Models/Building.swift index ec4f098..6e581a5 100644 --- a/JAMFKit/Sources/Models/Building.swift +++ b/JAMFKit/Sources/Models/Building.swift @@ -5,6 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // +/// Represents a physical building. public final class Building: BaseObject { // MARK: - Properties diff --git a/JAMFKit/Sources/Models/Computer.swift b/JAMFKit/Sources/Models/Computer.swift deleted file mode 100644 index f954f57..0000000 --- a/JAMFKit/Sources/Models/Computer.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// Computer.swift -// JAMFKit -// -// Copyright © 2018 JAMFKit. All rights reserved. -// - -public final class Computer: Hardware, CustomStringConvertible { - - // MARK: - Properties - - public var description: String { - let baseDescription = "[\(String(describing: Computer.self))]" - - if let general = self.general { - return "\(baseDescription)[\(general.identifier). \(general.name)]" - } - - return baseDescription - } -} diff --git a/JAMFKit/Sources/Models/Department.swift b/JAMFKit/Sources/Models/Department.swift index 1aa3d9b..7ee6688 100644 --- a/JAMFKit/Sources/Models/Department.swift +++ b/JAMFKit/Sources/Models/Department.swift @@ -5,6 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // +/// Represents a physical department. public final class Department: BaseObject { // MARK: - Properties diff --git a/JAMFKit/Sources/Models/Hardware/Hardware.swift b/JAMFKit/Sources/Models/Hardware/Hardware.swift deleted file mode 100644 index 551dd6a..0000000 --- a/JAMFKit/Sources/Models/Hardware/Hardware.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// Hardware.swift -// JAMFKit -// -// Copyright © 2017 JAMFKit. All rights reserved. -// - -public class Hardware: Identifiable { - - // MARK: - Constants - - static let GeneralKey = "general" - static let LocationKey = "location" - static let PurchasingKey = "purchasing" - - // MARK: - Properties - - public var general: HardwareGeneral? - public var location: HardwareLocation? - public var purchasing: HardwarePurchasing? - - // MARK: - Initialization - - public required init?(json: [String: Any], node: String = "") { - self.general = HardwareGeneral(json: json, node: Hardware.GeneralKey) - self.location = HardwareLocation(json: json, node: Hardware.LocationKey) - self.purchasing = HardwarePurchasing(json: json, node: Hardware.PurchasingKey) - } - - // MARK: - Functions - - func toJSON() -> [String: Any] { - var json = [String: Any]() - - if let general = general { json[Hardware.GeneralKey] = general.toJSON() } - if let location = location { json[Hardware.LocationKey] = location.toJSON() } - if let purchasing = purchasing { json[Hardware.PurchasingKey] = purchasing.toJSON() } - - return json - } -} diff --git a/JAMFKit/Sources/Models/NetbootServer.swift b/JAMFKit/Sources/Models/NetbootServer.swift index 94306d1..dca6899 100644 --- a/JAMFKit/Sources/Models/NetbootServer.swift +++ b/JAMFKit/Sources/Models/NetbootServer.swift @@ -5,6 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // +/// Represents a physical netboot server, contains information about the server and it's configuration. public final class NetbootServer: BaseObject { // MARK: - Constants diff --git a/JAMFKit/Sources/Models/NetworkSegment.swift b/JAMFKit/Sources/Models/NetworkSegment.swift index 6f23b91..a72cb92 100644 --- a/JAMFKit/Sources/Models/NetworkSegment.swift +++ b/JAMFKit/Sources/Models/NetworkSegment.swift @@ -5,6 +5,7 @@ // Copyright © 2018 JAMFKit. All rights reserved. // +/// Represents a physical network segment, contains information about the segment and it's configuration. public final class NetworkSegment: BaseObject { // MARK: - Constants diff --git a/JAMFKit/Sources/Models/PreciseDate.swift b/JAMFKit/Sources/Models/PreciseDate.swift index ac185c6..1f8e31e 100644 --- a/JAMFKit/Sources/Models/PreciseDate.swift +++ b/JAMFKit/Sources/Models/PreciseDate.swift @@ -7,6 +7,7 @@ import Foundation +/// Represents a logical date within JSS api, contains 3 properties, the date itself, an epoch version of the date and an UTC version of the date. public final class PreciseDate: Identifiable { // MARK: - Constants diff --git a/JAMFKit/Sources/Models/Printer.swift b/JAMFKit/Sources/Models/Printer.swift index 5c37d60..74bd73b 100644 --- a/JAMFKit/Sources/Models/Printer.swift +++ b/JAMFKit/Sources/Models/Printer.swift @@ -5,6 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // +/// Represents a physical printer, contains information about the printer and it's configuration. public final class Printer: BaseObject { // MARK: - Constants diff --git a/JAMFKit/Sources/Models/SMTPServer.swift b/JAMFKit/Sources/Models/SMTPServer.swift index 3c87c85..1c727e8 100644 --- a/JAMFKit/Sources/Models/SMTPServer.swift +++ b/JAMFKit/Sources/Models/SMTPServer.swift @@ -5,6 +5,7 @@ // Copyright © 2018 JAMFKit. All rights reserved. // +/// Represents a physical SMTP server, contains information about the server and it's configuration. public final class SMTPServer: Identifiable, CustomStringConvertible { // MARK: - Constants diff --git a/JAMFKit/Sources/Models/Site.swift b/JAMFKit/Sources/Models/Site.swift index c0f4937..4f816cb 100644 --- a/JAMFKit/Sources/Models/Site.swift +++ b/JAMFKit/Sources/Models/Site.swift @@ -5,6 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // +/// Represents a physical location (building, office, etc.). public final class Site: BaseObject { // MARK: - Properties diff --git a/JAMFKit/Sources/Models/User.swift b/JAMFKit/Sources/Models/User.swift index 46c25b9..20ac986 100644 --- a/JAMFKit/Sources/Models/User.swift +++ b/JAMFKit/Sources/Models/User.swift @@ -5,6 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // +/// Represents a Jamf user and contains the identification properties that are required to contact the actual user and identify the hardware devices assigned to him / her. public final class User: BaseObject { // MARK: - Constants diff --git a/JAMFKit/Tests/Models/Hardware/HardwareTests.swift b/JAMFKit/Tests/Models/Hardware/HardwareTests.swift deleted file mode 100644 index 6c7f84b..0000000 --- a/JAMFKit/Tests/Models/Hardware/HardwareTests.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// HardwareTests.swift -// JAMFKit -// -// Copyright © 2017 JAMFKit. All rights reserved. -// - -import XCTest - -@testable import JAMFKit - -class HardwareTests: XCTestCase { - - // MARK: - Tests - - func testShouldInitializeFromJSON() { - let payload = self.payload(for: "hardware")! - - let actualValue = Hardware(json: payload) - - XCTAssertNotNil(actualValue) - XCTAssertNotNil(actualValue?.general) - XCTAssertNotNil(actualValue?.location) - XCTAssertNotNil(actualValue?.purchasing) - } - - func testShouldEncodeToJSON() { - let payload = self.payload(for: "hardware")! - - let actualValue = Hardware(json: payload) - let encodedObject = actualValue?.toJSON() - - XCTAssertNotNil(encodedObject) - XCTAssertEqual(encodedObject?.count, 3) - XCTAssertNotNil(encodedObject?[Hardware.GeneralKey]) - XCTAssertNotNil(encodedObject?[Hardware.LocationKey]) - XCTAssertNotNil(encodedObject?[Hardware.PurchasingKey]) - } -} diff --git a/JAMFKit/Tests/Resources/Mocks.bundle/hardware.json b/JAMFKit/Tests/Resources/Mocks.bundle/hardware.json deleted file mode 100644 index 730bec4..0000000 --- a/JAMFKit/Tests/Resources/Mocks.bundle/hardware.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "general": { - "id": 0, - "name": "hardware", - "mac_address": "E0:AC:CB:97:36:G4", - "alt_mac_address": "E0:AC:CB:97:36:G4", - "ip_address": "10.1.1.1", - "last_reported_ip": "192.0.0.1", - "serial_number": "C02Q7KHTGFWF", - "udid": "55900BDC-347C-58B1-D249-F32244B11D30", - "jamf_version": "9.99.0-t1494340586", - "platform": "Mac", - "barcode_1": "string", - "barcode_2": "string", - "asset_tag": "string", - "remote_management": { - "managed": true, - "management_username": "casperadmin" - }, - "mdm_capable": true, - "mdm_capable_users": { - "mdm_capable_user": "string" - }, - "report_date": "2017-07-07T18:37:04.000Z", - "report_date_epoch": 1499470624555, - "report_date_utc": "2017-07-07T18:37:04.555-0500", - "last_contact_time": "2017-07-07T18:37:04.000Z", - "last_contact_time_epoch": 1499470624555, - "last_contact_time_utc": "2017-07-07T18:37:04.555-0500", - "initial_entry_date": "2017-07-07T18:37:04.000Z", - "initial_entry_date_epoch": 1499470624555, - "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", - "last_cloud_backup_date_epoch": 1499470624555, - "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", - "last_enrolled_date_epoch": 1499470624555, - "last_enrolled_date_utc": "2017-07-07T18:37:04.555-0500", - "distribution_point": "string", - "sus": "string", - "netboot_server": "string", - "site": { - "id": 0, - "name": "None" - }, - "itunes_store_account_is_active": true - }, - "location": { - "username": "JBetty", - "realname": "Betty Jackson", - "real_name": "Betty Jackson", - "email_address": "jbetty@company.com", - "position": "Systems Engineer", - "phone": "123-555-6789", - "phone_number": "123-555-6789", - "department": "Sales Staff", - "building": "New York Office", - "room": 1159 - }, - "purchasing": { - "is_purchased": true, - "is_leased": true, - "po_number": "string", - "vendor": "string", - "applecare_id": "string", - "purchase_price": "string", - "purchasing_account": "string", - "po_date": "string", - "po_date_epoch": 0, - "po_date_utc": "string", - "warranty_expires": "string", - "warranty_expires_epoch": 0, - "warranty_expires_utc": "string", - "lease_expires": "string", - "lease_expires_epoch": 0, - "lease_expires_utc": "string", - "life_expectancy": 0, - "purchasing_contact": "string" - } -} diff --git a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_incomplete.json b/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_incomplete.json deleted file mode 100644 index e6439ac..0000000 --- a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_incomplete.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "general": { - "id": 12345, - "name": "hardware", - "mac_address": "E0:AC:CB:97:36:G4", - "alt_mac_address": "E0:AC:CB:97:36:G4", - "ip_address": "10.1.1.1", - "last_reported_ip": "192.0.0.1", - "serial_number": "C02Q7KHTGFWF", - "udid": "55900BDC-347C-58B1-D249-F32244B11D30", - "jamf_version": "9.99.0-t1494340586", - "platform": "Mac", - "mdm_capable": true, - "report_date": "2017-07-07T18:37:04.000Z", - "report_date_epoch": 1499470624555, - "report_date_utc": "2017-07-07T18:37:04.555-0500", - "last_contact_time": "2017-07-07T18:37:04.000Z", - "last_contact_time_epoch": 1499470624555, - "last_contact_time_utc": "2017-07-07T18:37:04.555-0500", - "initial_entry_date": "2017-07-07T18:37:04.000Z", - "initial_entry_date_epoch": 1499470624555, - "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", - "last_cloud_backup_date_epoch": 1499470624555, - "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", - "distribution_point": "string", - "sus": "string", - "netboot_server": "string", - "itunes_store_account_is_active": true - } -} diff --git a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_invalid.json b/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_invalid.json deleted file mode 100644 index 0e604ce..0000000 --- a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_invalid.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "general": { - "id": 12345, - "mac_address": "E0:AC:CB:97:36:G4", - "alt_mac_address": "E0:AC:CB:97:36:G4", - "ip_address": "10.1.1.1", - "last_reported_ip": "192.0.0.1", - "serial_number": "C02Q7KHTGFWF", - "udid": "55900BDC-347C-58B1-D249-F32244B11D30", - "jamf_version": "9.99.0-t1494340586", - "platform": "Mac", - "barcode_1": "string", - "barcode_2": "string", - "asset_tag": "string", - "remote_management": { - "managed": true, - "management_username": "casperadmin" - }, - "mdm_capable": true, - "mdm_capable_users": { - "mdm_capable_user": "string" - }, - "report_date": "2017-07-07T18:37:04.000Z", - "report_date_epoch": 1499470624555, - "report_date_utc": "2017-07-07T18:37:04.555-0500", - "last_contact_time": "2017-07-07T18:37:04.000Z", - "last_contact_time_epoch": 1499470624555, - "last_contact_time_utc": "2017-07-07T18:37:04.555-0500", - "initial_entry_date": "2017-07-07T18:37:04.000Z", - "initial_entry_date_epoch": 1499470624555, - "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", - "last_cloud_backup_date_epoch": 1499470624555, - "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", - "last_enrolled_date_epoch": 1499470624555, - "last_enrolled_date_utc": "2017-07-07T18:37:04.555-0500", - "distribution_point": "string", - "sus": "string", - "netboot_server": "string", - "site": { - "id": 0, - "name": "None" - }, - "itunes_store_account_is_active": true - } -} diff --git a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_valid.json b/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_valid.json deleted file mode 100644 index 49a98f2..0000000 --- a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_valid.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "general": { - "id": 12345, - "name": "hardware", - "mac_address": "E0:AC:CB:97:36:G4", - "alt_mac_address": "E0:AC:CB:97:36:G4", - "ip_address": "10.1.1.1", - "last_reported_ip": "192.0.0.1", - "serial_number": "C02Q7KHTGFWF", - "udid": "55900BDC-347C-58B1-D249-F32244B11D30", - "jamf_version": "9.99.0-t1494340586", - "platform": "Mac", - "barcode_1": "string", - "barcode_2": "string", - "asset_tag": "string", - "remote_management": { - "managed": true, - "management_username": "username" - }, - "mdm_capable": true, - "mdm_capable_users": { - "mdm_capable_user": "string" - }, - "report_date": "2017-07-07T18:37:04.000Z", - "report_date_epoch": 1499470624555, - "report_date_utc": "2017-07-07T18:37:04.555-0500", - "last_contact_time": "2017-07-07T18:37:04.000Z", - "last_contact_time_epoch": 1499470624555, - "last_contact_time_utc": "2017-07-07T18:37:04.555-0500", - "initial_entry_date": "2017-07-07T18:37:04.000Z", - "initial_entry_date_epoch": 1499470624555, - "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", - "last_cloud_backup_date_epoch": 1499470624555, - "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", - "last_enrolled_date_epoch": 1499470624555, - "last_enrolled_date_utc": "2017-07-07T18:37:04.555-0500", - "distribution_point": "string", - "sus": "string", - "netboot_server": "string", - "site": { - "id": 0, - "name": "None" - }, - "itunes_store_account_is_active": true - } -} diff --git a/JamfKit/Sources/Models/Computer/Computer.swift b/JamfKit/Sources/Models/Computer/Computer.swift new file mode 100644 index 0000000..29579db --- /dev/null +++ b/JamfKit/Sources/Models/Computer/Computer.swift @@ -0,0 +1,60 @@ +// +// Computer.swift +// JAMFKit +// +// Copyright © 2018 JAMFKit. All rights reserved. +// + +/// Represents a Jamf managed computer, contains the general / location / purchasing information about the hardware. +public final class Computer: Identifiable, CustomStringConvertible { + + // MARK: - Constants + + static let GeneralKey = "general" + static let LocationKey = "location" + static let PurchasingKey = "purchasing" + + // MARK: - Properties + + public var general: ComputerGeneral? + public var location: ComputerLocation? + public var purchasing: ComputerPurchasing? + + public var description: String { + let baseDescription = "[\(String(describing: Computer.self))]" + + if let general = self.general { + return "\(baseDescription)[\(general.identifier). \(general.name)]" + } + + return baseDescription + } + + // MARK: - Initialization + + public required init?(json: [String: Any], node: String = "") { + if let generalNode = json[Computer.GeneralKey] as? [String: Any] { + general = ComputerGeneral(json: generalNode) + } + + if let locationNode = json[Computer.LocationKey] as? [String: Any] { + location = ComputerLocation(json: locationNode) + } + + if let purchasingNode = json[Computer.PurchasingKey] as? [String: Any] { + purchasing = ComputerPurchasing(json: purchasingNode) + } + } + + // MARK: - Functions + + func toJSON() -> [String: Any] { + var json = [String: Any]() + + if let general = general { json[Computer.GeneralKey] = general.toJSON() } + if let location = location { json[Computer.LocationKey] = location.toJSON() } + if let purchasing = purchasing { json[Computer.PurchasingKey] = purchasing.toJSON() } + + return json + } +} diff --git a/JAMFKit/Sources/Models/Hardware/HardwareGeneral.swift b/JamfKit/Sources/Models/Computer/ComputerGeneral.swift similarity index 52% rename from JAMFKit/Sources/Models/Hardware/HardwareGeneral.swift rename to JamfKit/Sources/Models/Computer/ComputerGeneral.swift index 93ce5c3..a772fa9 100644 --- a/JAMFKit/Sources/Models/Hardware/HardwareGeneral.swift +++ b/JamfKit/Sources/Models/Computer/ComputerGeneral.swift @@ -1,11 +1,11 @@ // -// HardwareGeneral.swift +// ComputerGeneral.swift // JAMFKit // // Copyright © 2017 JAMFKit. All rights reserved. // -public final class HardwareGeneral: BaseObject { +public final class ComputerGeneral: BaseObject { // MARK: - Constants @@ -47,7 +47,7 @@ public final class HardwareGeneral: BaseObject { public var barcode1: String? public var barcode2: String? public var assetTag: String? - public var remoteManagement: HardwareRemoteManagement? + public var remoteManagement: ComputerRemoteManagement? public var isMdmCapable: Bool? public var mdmCapableUsers: [String]? public var reportDate: PreciseDate? @@ -64,36 +64,32 @@ public final class HardwareGeneral: BaseObject { // MARK: - Initialization public required init?(json: [String: Any], node: String = "") { - guard let rootNode = json[node] as? [String: Any] else { - return nil - } - - macAddress = rootNode[HardwareGeneral.MacAddressKey] as? String - alternativeMacAddress = rootNode[HardwareGeneral.AlternativeMacAddressKey] as? String - ipAddress = rootNode[HardwareGeneral.IpAddressKey] as? String - lastReportedIpAddress = rootNode[HardwareGeneral.LastReportedIPAddressKey] as? String - serialNumber = rootNode[HardwareGeneral.SerialNumberKey] as? String - udid = rootNode[HardwareGeneral.UDIDKey] as? String - jamfVersion = rootNode[HardwareGeneral.JAMFVersionKey] as? String - platform = rootNode[HardwareGeneral.PlatformKey] as? String - barcode1 = rootNode[HardwareGeneral.Barcode1Key] as? String - barcode2 = rootNode[HardwareGeneral.Barcode2Key] as? String - assetTag = rootNode[HardwareGeneral.AssetTagKey] as? String - remoteManagement = HardwareGeneral.parseRemoteManagement(from: rootNode) - isMdmCapable = rootNode[HardwareGeneral.MdmCapableKey] as? Bool - mdmCapableUsers = HardwareGeneral.parseMdmCapableUsers(from: rootNode) - reportDate = PreciseDate(json: rootNode, node: HardwareGeneral.ReportDateKey) - lastContactTime = PreciseDate(json: rootNode, node: HardwareGeneral.LastContactTimeKey) - initialEntryDate = PreciseDate(json: rootNode, node: HardwareGeneral.InitialEntryDateKey) - lastCloudBackupDate = PreciseDate(json: rootNode, node: HardwareGeneral.LastCloudBackupDateKey) - lastEnrolledDate = PreciseDate(json: rootNode, node: HardwareGeneral.LastEnrolledDateKey) - distributionPoint = rootNode[HardwareGeneral.DistributionPointKey] as? String - sus = rootNode[HardwareGeneral.SusKey] as? String - netbootServer = rootNode[HardwareGeneral.NetbootServerKey] as? String - site = HardwareGeneral.parseSite(from: rootNode) - isITunesStoreAcccountActivated = rootNode[HardwareGeneral.ItunesStoreAccountIsActiveKey] as? Bool - - super.init(json: rootNode) + macAddress = json[ComputerGeneral.MacAddressKey] as? String + alternativeMacAddress = json[ComputerGeneral.AlternativeMacAddressKey] as? String + ipAddress = json[ComputerGeneral.IpAddressKey] as? String + lastReportedIpAddress = json[ComputerGeneral.LastReportedIPAddressKey] as? String + serialNumber = json[ComputerGeneral.SerialNumberKey] as? String + udid = json[ComputerGeneral.UDIDKey] as? String + jamfVersion = json[ComputerGeneral.JAMFVersionKey] as? String + platform = json[ComputerGeneral.PlatformKey] as? String + barcode1 = json[ComputerGeneral.Barcode1Key] as? String + barcode2 = json[ComputerGeneral.Barcode2Key] as? String + assetTag = json[ComputerGeneral.AssetTagKey] as? String + remoteManagement = ComputerGeneral.parseRemoteManagement(from: json) + isMdmCapable = json[ComputerGeneral.MdmCapableKey] as? Bool + mdmCapableUsers = ComputerGeneral.parseMdmCapableUsers(from: json) + reportDate = PreciseDate(json: json, node: ComputerGeneral.ReportDateKey) + lastContactTime = PreciseDate(json: json, node: ComputerGeneral.LastContactTimeKey) + initialEntryDate = PreciseDate(json: json, node: ComputerGeneral.InitialEntryDateKey) + lastCloudBackupDate = PreciseDate(json: json, node: ComputerGeneral.LastCloudBackupDateKey) + lastEnrolledDate = PreciseDate(json: json, node: ComputerGeneral.LastEnrolledDateKey) + distributionPoint = json[ComputerGeneral.DistributionPointKey] as? String + sus = json[ComputerGeneral.SusKey] as? String + netbootServer = json[ComputerGeneral.NetbootServerKey] as? String + site = ComputerGeneral.parseSite(from: json) + isITunesStoreAcccountActivated = json[ComputerGeneral.ItunesStoreAccountIsActiveKey] as? Bool + + super.init(json: json) } // MARK: - Functions @@ -101,20 +97,20 @@ public final class HardwareGeneral: BaseObject { override func toJSON() -> [String: Any] { var json = super.toJSON() - json[HardwareGeneral.MacAddressKey] = macAddress - json[HardwareGeneral.AlternativeMacAddressKey] = alternativeMacAddress - json[HardwareGeneral.IpAddressKey] = ipAddress - json[HardwareGeneral.LastReportedIPAddressKey] = lastReportedIpAddress - json[HardwareGeneral.SerialNumberKey] = serialNumber - json[HardwareGeneral.UDIDKey] = udid - json[HardwareGeneral.JAMFVersionKey] = jamfVersion - json[HardwareGeneral.PlatformKey] = platform - json[HardwareGeneral.Barcode1Key] = barcode1 - json[HardwareGeneral.Barcode2Key] = barcode2 - json[HardwareGeneral.AssetTagKey] = assetTag - json[HardwareRemoteManagement.ContainerKey] = remoteManagement ?? remoteManagement?.toJSON() - json[HardwareGeneral.MdmCapableKey] = isMdmCapable - json[HardwareGeneral.MdmCapableUsersKey] = mdmCapableUsers + json[ComputerGeneral.MacAddressKey] = macAddress + json[ComputerGeneral.AlternativeMacAddressKey] = alternativeMacAddress + json[ComputerGeneral.IpAddressKey] = ipAddress + json[ComputerGeneral.LastReportedIPAddressKey] = lastReportedIpAddress + json[ComputerGeneral.SerialNumberKey] = serialNumber + json[ComputerGeneral.UDIDKey] = udid + json[ComputerGeneral.JAMFVersionKey] = jamfVersion + json[ComputerGeneral.PlatformKey] = platform + json[ComputerGeneral.Barcode1Key] = barcode1 + json[ComputerGeneral.Barcode2Key] = barcode2 + json[ComputerGeneral.AssetTagKey] = assetTag + json[ComputerRemoteManagement.ContainerKey] = remoteManagement ?? remoteManagement?.toJSON() + json[ComputerGeneral.MdmCapableKey] = isMdmCapable + json[ComputerGeneral.MdmCapableUsersKey] = mdmCapableUsers if let reportDate = reportDate { json.merge(reportDate.toJSON()) { (_, new) in new } @@ -136,21 +132,21 @@ public final class HardwareGeneral: BaseObject { json.merge(lastEnrolledDate.toJSON()) { (_, new) in new } } - json[HardwareGeneral.DistributionPointKey] = distributionPoint - json[HardwareGeneral.SusKey] = sus - json[HardwareGeneral.NetbootServerKey] = netbootServer - json[HardwareGeneral.SiteKey] = site?.toJSON() - json[HardwareGeneral.ItunesStoreAccountIsActiveKey] = isITunesStoreAcccountActivated + json[ComputerGeneral.DistributionPointKey] = distributionPoint + json[ComputerGeneral.SusKey] = sus + json[ComputerGeneral.NetbootServerKey] = netbootServer + json[ComputerGeneral.SiteKey] = site?.toJSON() + json[ComputerGeneral.ItunesStoreAccountIsActiveKey] = isITunesStoreAcccountActivated return json } // MARK: - Helpers - private static func parseRemoteManagement(from json: [String: Any]) -> HardwareRemoteManagement? { + private static func parseRemoteManagement(from json: [String: Any]) -> ComputerRemoteManagement? { guard - let remoteManagementContainer = json[HardwareRemoteManagement.ContainerKey] as? [String: Any], - let remoteManagement = HardwareRemoteManagement(json: remoteManagementContainer) + let remoteManagementContainer = json[ComputerRemoteManagement.ContainerKey] as? [String: Any], + let remoteManagement = ComputerRemoteManagement(json: remoteManagementContainer) else { return nil } @@ -159,7 +155,7 @@ public final class HardwareGeneral: BaseObject { } private static func parseMdmCapableUsers(from json: [String: Any]) -> [String]? { - guard let rawMdmCapableUsers = json[HardwareGeneral.MdmCapableUsersKey] as? [String: String] else { + guard let rawMdmCapableUsers = json[ComputerGeneral.MdmCapableUsersKey] as? [String: String] else { return nil } @@ -168,7 +164,7 @@ public final class HardwareGeneral: BaseObject { private static func parseSite(from json: [String: Any]) -> Site? { guard - let rawSite = json[HardwareGeneral.SiteKey] as? [String: Any], + let rawSite = json[ComputerGeneral.SiteKey] as? [String: Any], let site = Site(json: rawSite) else { return nil } diff --git a/JAMFKit/Sources/Models/Hardware/HardwareLocation.swift b/JamfKit/Sources/Models/Computer/ComputerLocation.swift similarity index 50% rename from JAMFKit/Sources/Models/Hardware/HardwareLocation.swift rename to JamfKit/Sources/Models/Computer/ComputerLocation.swift index fab1348..7dd2415 100644 --- a/JAMFKit/Sources/Models/Hardware/HardwareLocation.swift +++ b/JamfKit/Sources/Models/Computer/ComputerLocation.swift @@ -5,7 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // -public final class HardwareLocation: Identifiable { +public final class ComputerLocation: Identifiable { // MARK: - Constants @@ -32,14 +32,14 @@ public final class HardwareLocation: Identifiable { // MARK: - Initialization init?(json: [String: Any], node: String = "") { - username = json[HardwareLocation.UsernameKey] as? String ?? "" - realName = json[HardwareLocation.RealNameKey] as? String ?? "" - emailAddress = json[HardwareLocation.EmailAddressKey] as? String ?? "" - position = json[HardwareLocation.PositionKey] as? String ?? "" - phoneNumber = json[HardwareLocation.PhoneNumberKey] as? String ?? "" - department = json[HardwareLocation.DepartementKey] as? String ?? "" - building = json[HardwareLocation.BuildingKey] as? String ?? "" - room = json[HardwareLocation.RoomKey] as? UInt ?? 0 + username = json[ComputerLocation.UsernameKey] as? String ?? "" + realName = json[ComputerLocation.RealNameKey] as? String ?? "" + emailAddress = json[ComputerLocation.EmailAddressKey] as? String ?? "" + position = json[ComputerLocation.PositionKey] as? String ?? "" + phoneNumber = json[ComputerLocation.PhoneNumberKey] as? String ?? "" + department = json[ComputerLocation.DepartementKey] as? String ?? "" + building = json[ComputerLocation.BuildingKey] as? String ?? "" + room = json[ComputerLocation.RoomKey] as? UInt ?? 0 } // MARK: - Functions @@ -47,14 +47,14 @@ public final class HardwareLocation: Identifiable { func toJSON() -> [String: Any] { var json = [String: Any]() - json[HardwareLocation.UsernameKey] = username - json[HardwareLocation.RealNameKey] = realName - json[HardwareLocation.EmailAddressKey] = emailAddress - json[HardwareLocation.PositionKey] = position - json[HardwareLocation.PhoneNumberKey] = phoneNumber - json[HardwareLocation.DepartementKey] = department - json[HardwareLocation.BuildingKey] = building - json[HardwareLocation.RoomKey] = room + json[ComputerLocation.UsernameKey] = username + json[ComputerLocation.RealNameKey] = realName + json[ComputerLocation.EmailAddressKey] = emailAddress + json[ComputerLocation.PositionKey] = position + json[ComputerLocation.PhoneNumberKey] = phoneNumber + json[ComputerLocation.DepartementKey] = department + json[ComputerLocation.BuildingKey] = building + json[ComputerLocation.RoomKey] = room return json } diff --git a/JAMFKit/Sources/Models/Hardware/HardwarePurchasing.swift b/JamfKit/Sources/Models/Computer/ComputerPurchasing.swift similarity index 59% rename from JAMFKit/Sources/Models/Hardware/HardwarePurchasing.swift rename to JamfKit/Sources/Models/Computer/ComputerPurchasing.swift index 1ab2a17..9256b77 100644 --- a/JAMFKit/Sources/Models/Hardware/HardwarePurchasing.swift +++ b/JamfKit/Sources/Models/Computer/ComputerPurchasing.swift @@ -5,7 +5,7 @@ // Copyright © 2017 JAMFKit. All rights reserved. // -public final class HardwarePurchasing: Identifiable { +public final class ComputerPurchasing: Identifiable { // MARK: - Constants @@ -40,18 +40,18 @@ public final class HardwarePurchasing: Identifiable { // MARK: - Initialization init?(json: [String: Any], node: String = "") { - isPurchased = json[HardwarePurchasing.IsPurchasedKey] as? Bool ?? false - isLeased = json[HardwarePurchasing.IsLeasedKey] as? Bool ?? false - poNumber = json[HardwarePurchasing.PoNumberKey] as? String ?? "" - vendor = json[HardwarePurchasing.VendorKey] as? String ?? "" - appleCareIdentifier = json[HardwarePurchasing.AppleCareIdentifierKey] as? String ?? "" - purchasePrice = json[HardwarePurchasing.PurchasePriceKey] as? String ?? "" - purchasingAccount = json[HardwarePurchasing.PurchasingAccountKey] as? String ?? "" - purchasingContact = json[HardwarePurchasing.PurchasingContactKey] as? String ?? "" - poDate = PreciseDate(json: json, node: HardwarePurchasing.PoDateKey) - warrantyExpires = PreciseDate(json: json, node: HardwarePurchasing.WarrantyExpiresKey) - leaseExpires = PreciseDate(json: json, node: HardwarePurchasing.LeaseExpiresKey) - lifeExpectancy = json[HardwarePurchasing.LifeExpectancyKey] as? UInt ?? 0 + isPurchased = json[ComputerPurchasing.IsPurchasedKey] as? Bool ?? false + isLeased = json[ComputerPurchasing.IsLeasedKey] as? Bool ?? false + poNumber = json[ComputerPurchasing.PoNumberKey] as? String ?? "" + vendor = json[ComputerPurchasing.VendorKey] as? String ?? "" + appleCareIdentifier = json[ComputerPurchasing.AppleCareIdentifierKey] as? String ?? "" + purchasePrice = json[ComputerPurchasing.PurchasePriceKey] as? String ?? "" + purchasingAccount = json[ComputerPurchasing.PurchasingAccountKey] as? String ?? "" + purchasingContact = json[ComputerPurchasing.PurchasingContactKey] as? String ?? "" + poDate = PreciseDate(json: json, node: ComputerPurchasing.PoDateKey) + warrantyExpires = PreciseDate(json: json, node: ComputerPurchasing.WarrantyExpiresKey) + leaseExpires = PreciseDate(json: json, node: ComputerPurchasing.LeaseExpiresKey) + lifeExpectancy = json[ComputerPurchasing.LifeExpectancyKey] as? UInt ?? 0 } // MARK: - Functions @@ -59,14 +59,14 @@ public final class HardwarePurchasing: Identifiable { func toJSON() -> [String: Any] { var json = [String: Any]() - json[HardwarePurchasing.IsPurchasedKey] = isPurchased - json[HardwarePurchasing.IsLeasedKey] = isLeased - json[HardwarePurchasing.PoNumberKey] = poNumber - json[HardwarePurchasing.VendorKey] = vendor - json[HardwarePurchasing.AppleCareIdentifierKey] = appleCareIdentifier - json[HardwarePurchasing.PurchasePriceKey] = purchasePrice - json[HardwarePurchasing.PurchasingAccountKey] = purchasingAccount - json[HardwarePurchasing.PurchasingContactKey] = purchasingContact + json[ComputerPurchasing.IsPurchasedKey] = isPurchased + json[ComputerPurchasing.IsLeasedKey] = isLeased + json[ComputerPurchasing.PoNumberKey] = poNumber + json[ComputerPurchasing.VendorKey] = vendor + json[ComputerPurchasing.AppleCareIdentifierKey] = appleCareIdentifier + json[ComputerPurchasing.PurchasePriceKey] = purchasePrice + json[ComputerPurchasing.PurchasingAccountKey] = purchasingAccount + json[ComputerPurchasing.PurchasingContactKey] = purchasingContact if let poDate = poDate { json.merge(poDate.toJSON()) { (_, new) in new } @@ -80,7 +80,7 @@ public final class HardwarePurchasing: Identifiable { json.merge(leaseExpires.toJSON()) { (_, new) in new } } - json[HardwarePurchasing.LifeExpectancyKey] = lifeExpectancy + json[ComputerPurchasing.LifeExpectancyKey] = lifeExpectancy return json } diff --git a/JAMFKit/Sources/Models/Hardware/HardwareRemoteManagement.swift b/JamfKit/Sources/Models/Computer/ComputerRemoteManagement.swift similarity index 59% rename from JAMFKit/Sources/Models/Hardware/HardwareRemoteManagement.swift rename to JamfKit/Sources/Models/Computer/ComputerRemoteManagement.swift index 3aed5cd..29e1f05 100644 --- a/JAMFKit/Sources/Models/Hardware/HardwareRemoteManagement.swift +++ b/JamfKit/Sources/Models/Computer/ComputerRemoteManagement.swift @@ -1,11 +1,11 @@ // -// HardwareRemoteManagement.swift +// ComputerRemoteManagement.swift // JAMFKit // // Copyright © 2017 JAMFKit. All rights reserved. // -public final class HardwareRemoteManagement: Identifiable { +public final class ComputerRemoteManagement: Identifiable { // MARK: - Constants @@ -20,9 +20,9 @@ public final class HardwareRemoteManagement: Identifiable { // MARK: - Initialization - init?(json: [String: Any], node: String = HardwareRemoteManagement.ContainerKey) { - isManaged = json[HardwareRemoteManagement.ManagedKey] as? Bool ?? false - managementUsername = json[HardwareRemoteManagement.ManagementUsernameKey] as? String ?? "" + init?(json: [String: Any], node: String = ComputerRemoteManagement.ContainerKey) { + isManaged = json[ComputerRemoteManagement.ManagedKey] as? Bool ?? false + managementUsername = json[ComputerRemoteManagement.ManagementUsernameKey] as? String ?? "" } // MARK: - Functions @@ -30,8 +30,8 @@ public final class HardwareRemoteManagement: Identifiable { func toJSON() -> [String: Any] { var json = [String: Any]() - json[HardwareRemoteManagement.ManagedKey] = isManaged - json[HardwareRemoteManagement.ManagementUsernameKey] = managementUsername + json[ComputerRemoteManagement.ManagedKey] = isManaged + json[ComputerRemoteManagement.ManagementUsernameKey] = managementUsername return json } diff --git a/JamfKit/Sources/Models/MobileDevice/MobileDevice.swift b/JamfKit/Sources/Models/MobileDevice/MobileDevice.swift new file mode 100644 index 0000000..6820714 --- /dev/null +++ b/JamfKit/Sources/Models/MobileDevice/MobileDevice.swift @@ -0,0 +1,46 @@ +// +// MobileDevice.swift +// JAMFKit +// +// Copyright © 2018 JAMFKit. All rights reserved. +// + +/// Represents a Jamf managed mobile device, contains the general information about the device. +public final class MobileDevice: Identifiable, CustomStringConvertible { + + // MARK: - Constants + + static let GeneralKey = "general" + + // MARK: - Properties + + public var general: MobileDeviceGeneral? + + public var description: String { + let baseDescription = "[\(String(describing: MobileDevice.self))]" + + if let general = self.general { + return "\(baseDescription)[\(general.identifier). \(general.name)]" + } + + return baseDescription + } + + // MARK: - Initialization + + public required init?(json: [String: Any], node: String = "") { + if let generalNode = json[MobileDevice.GeneralKey] as? [String: Any] { + general = MobileDeviceGeneral(json: generalNode) + } + } + + // MARK: - Functions + + func toJSON() -> [String: Any] { + var json = [String: Any]() + + if let general = general { json[MobileDevice.GeneralKey] = general.toJSON() } + + return json + } +} diff --git a/JamfKit/Sources/Models/MobileDevice/MobileDeviceGeneral.swift b/JamfKit/Sources/Models/MobileDevice/MobileDeviceGeneral.swift new file mode 100644 index 0000000..c0642b0 --- /dev/null +++ b/JamfKit/Sources/Models/MobileDevice/MobileDeviceGeneral.swift @@ -0,0 +1,210 @@ +// +// MobileDeviceGeneral.swift +// JAMFKit +// +// Copyright © 2018 JAMFKit. All rights reserved. +// + +public final class MobileDeviceGeneral: BaseObject { + + // MARK: - Constants + + static let DisplayNameKey = "display_name" + static let DeviceNameKey = "device_name" + static let AssetTagNameKey = "asset_tag" + static let LastInventoryUpdateKey = "last_inventory_update" + static let CapacityKey = "capacity" + static let CapacityMbKey = "capacity_mb" + static let AvailableKey = "available" + static let AvailableMbKey = "available_mb" + static let PercentageUsedKey = "percentage_used" + static let OSTypeKey = "os_type" + static let OSVersionKey = "os_version" + static let OSBuildKey = "os_build" + static let SerialNumberKey = "serial_number" + static let UDIDKey = "udid" + static let InitialEntryDateKey = "initial_entry_date" + static let PhoneNumberKey = "phone_number" + static let IPAddressKey = "ip_address" + static let WifiMacAddressKey = "wifi_mac_address" + static let BluetoothMacAddressKey = "bluetooth_mac_address" + static let ModemFirmwareKey = "modem_firmware" + static let ModelKey = "model" + static let ModelIdentifierKey = "model_identifier" + static let ModelNumberKey = "model_number" + static let ModelDisplayKey = "model_display" + static let DeviceOwnershipLevelKey = "device_ownership_level" + static let LastEnrollmentKey = "last_enrollment" + static let ManagedKey = "managed" + static let SupervisedKey = "supervised" + static let ExchangeActiveSyncDeviceIdentifierKey = "exchange_activesync_device_identifier" + static let SharedKey = "shared" + static let TetheredKey = "tethered" + static let BatteryLevelKey = "battery_level" + static let BluetoothCapableKey = "ble_capable" + static let DeviceLocatorServiceEnabledKey = "device_locator_service_enabled" + static let DoNotDisturbEnabledKey = "do_not_disturb_enabled" + static let CloudBackupEnabledKey = "cloud_backup_enabled" + static let LastCloudBackupDateKey = "last_cloud_backup_date" + static let LocationServicesEnabledKey = "location_services_enabled" + static let ITunesStoreAccountIsActiveKey = "itunes_store_account_is_active" + static let LastBackupTimeKey = "last_backup_time" + + // MARK: - Properties + + public var displayName: String + public var deviceName: String + public var assetTag: String + public var lastInventoryUpdate: PreciseDate? + public var capacity: UInt + public var capacityMb: UInt + public var available: UInt + public var availableMb: UInt + public var percentageUsed: UInt + public var osType: String + public var osVersion: String + public var osBuild: String + public var serialNumber: String + public var udid: String + public var initialEntryDate: PreciseDate? + public var phoneNumber: String + public var ipAddress: String + public var wifiMacAddress: String + public var bluetoothMacAddress: String + public var modemFirmware: String + public var model: String + public var modelIdentifier: String + public var modelNumber: String + public var modelDisplay: String + public var deviceOwnershipLevel: String + public var lastEnrollment: PreciseDate? + public var isManaged: Bool + public var isSupervised: Bool + public var exchangeActiveSyncDeviceIdentifier: String + public var shared: String + public var tethered: String + public var batteryLevel: UInt + public var isBluetoothCapable: Bool + public var isDeviceLocatorServiceEnabled: Bool + public var isDoNotDisturbEnabled: Bool + public var isCloudBackupEnabled: Bool + public var lastCloudBackupDate: PreciseDate? + public var isLocationServicesEnabled: Bool + public var isITunesStoreAccountActive: Bool + public var lastBackupTime: PreciseDate? + + // MARK: - Initialization + + public required init?(json: [String : Any], node: String = "") { + displayName = json[MobileDeviceGeneral.DisplayNameKey] as? String ?? "" + deviceName = json[MobileDeviceGeneral.DeviceNameKey] as? String ?? "" + assetTag = json[MobileDeviceGeneral.AssetTagNameKey] as? String ?? "" + lastInventoryUpdate = PreciseDate(json: json, node: MobileDeviceGeneral.LastInventoryUpdateKey) + capacity = json[MobileDeviceGeneral.CapacityKey] as? UInt ?? 0 + capacityMb = json[MobileDeviceGeneral.CapacityMbKey] as? UInt ?? 0 + available = json[MobileDeviceGeneral.AvailableKey] as? UInt ?? 0 + availableMb = json[MobileDeviceGeneral.AvailableMbKey] as? UInt ?? 0 + percentageUsed = json[MobileDeviceGeneral.PercentageUsedKey] as? UInt ?? 0 + osType = json[MobileDeviceGeneral.OSTypeKey] as? String ?? "" + osVersion = json[MobileDeviceGeneral.OSVersionKey] as? String ?? "" + osBuild = json[MobileDeviceGeneral.OSBuildKey] as? String ?? "" + serialNumber = json[MobileDeviceGeneral.SerialNumberKey] as? String ?? "" + udid = json[MobileDeviceGeneral.UDIDKey] as? String ?? "" + initialEntryDate = PreciseDate(json: json, node: MobileDeviceGeneral.InitialEntryDateKey) + phoneNumber = json[MobileDeviceGeneral.PhoneNumberKey] as? String ?? "" + ipAddress = json[MobileDeviceGeneral.IPAddressKey] as? String ?? "" + wifiMacAddress = json[MobileDeviceGeneral.WifiMacAddressKey] as? String ?? "" + bluetoothMacAddress = json[MobileDeviceGeneral.BluetoothMacAddressKey] as? String ?? "" + modemFirmware = json[MobileDeviceGeneral.ModemFirmwareKey] as? String ?? "" + model = json[MobileDeviceGeneral.ModelKey] as? String ?? "" + modelIdentifier = json[MobileDeviceGeneral.ModelIdentifierKey] as? String ?? "" + modelNumber = json[MobileDeviceGeneral.ModelNumberKey] as? String ?? "" + modelDisplay = json[MobileDeviceGeneral.ModelDisplayKey] as? String ?? "" + deviceOwnershipLevel = json[MobileDeviceGeneral.DeviceOwnershipLevelKey] as? String ?? "" + lastEnrollment = PreciseDate(json: json, node: MobileDeviceGeneral.LastEnrollmentKey) + isManaged = json[MobileDeviceGeneral.ManagedKey] as? Bool ?? false + isSupervised = json[MobileDeviceGeneral.SupervisedKey] as? Bool ?? false + exchangeActiveSyncDeviceIdentifier = json[MobileDeviceGeneral.ExchangeActiveSyncDeviceIdentifierKey] as? String ?? "" + shared = json[MobileDeviceGeneral.SharedKey] as? String ?? "" + tethered = json[MobileDeviceGeneral.TetheredKey] as? String ?? "" + batteryLevel = json[MobileDeviceGeneral.BatteryLevelKey] as? UInt ?? 0 + isBluetoothCapable = json[MobileDeviceGeneral.BluetoothCapableKey] as? Bool ?? false + isDeviceLocatorServiceEnabled = json[MobileDeviceGeneral.DeviceLocatorServiceEnabledKey] as? Bool ?? false + isDoNotDisturbEnabled = json[MobileDeviceGeneral.DoNotDisturbEnabledKey] as? Bool ?? false + isCloudBackupEnabled = json[MobileDeviceGeneral.CloudBackupEnabledKey] as? Bool ?? false + lastCloudBackupDate = PreciseDate(json: json, node: MobileDeviceGeneral.LastCloudBackupDateKey) + isLocationServicesEnabled = json[MobileDeviceGeneral.LocationServicesEnabledKey] as? Bool ?? false + isITunesStoreAccountActive = json[MobileDeviceGeneral.ITunesStoreAccountIsActiveKey] as? Bool ?? false + lastBackupTime = PreciseDate(json: json, node: MobileDeviceGeneral.LastBackupTimeKey) + + super.init(json: json) + } + + // MARK: - Functions + + override func toJSON() -> [String : Any] { + var json = super.toJSON() + + json[MobileDeviceGeneral.DisplayNameKey] = displayName + json[MobileDeviceGeneral.DeviceNameKey] = deviceName + json[MobileDeviceGeneral.AssetTagNameKey] = assetTag + + if let lastInventoryUpdate = lastInventoryUpdate { + json.merge(lastInventoryUpdate.toJSON()) { (_, new) in new } + } + + json[MobileDeviceGeneral.CapacityKey] = capacity + json[MobileDeviceGeneral.CapacityMbKey] = capacityMb + json[MobileDeviceGeneral.AvailableKey] = available + json[MobileDeviceGeneral.AvailableMbKey] = availableMb + json[MobileDeviceGeneral.PercentageUsedKey] = percentageUsed + json[MobileDeviceGeneral.OSTypeKey] = osType + json[MobileDeviceGeneral.OSVersionKey] = osVersion + json[MobileDeviceGeneral.OSBuildKey] = osBuild + json[MobileDeviceGeneral.SerialNumberKey] = serialNumber + json[MobileDeviceGeneral.UDIDKey] = udid + + if let initialEntryDate = initialEntryDate { + json.merge(initialEntryDate.toJSON()) { (_, new) in new } + } + + json[MobileDeviceGeneral.PhoneNumberKey] = phoneNumber + json[MobileDeviceGeneral.IPAddressKey] = ipAddress + json[MobileDeviceGeneral.WifiMacAddressKey] = wifiMacAddress + json[MobileDeviceGeneral.BluetoothMacAddressKey] = bluetoothMacAddress + json[MobileDeviceGeneral.ModemFirmwareKey] = modemFirmware + json[MobileDeviceGeneral.ModelKey] = model + json[MobileDeviceGeneral.ModelIdentifierKey] = modelIdentifier + json[MobileDeviceGeneral.ModelNumberKey] = modelNumber + json[MobileDeviceGeneral.ModelDisplayKey] = modelDisplay + json[MobileDeviceGeneral.DeviceOwnershipLevelKey] = deviceOwnershipLevel + + if let lastEnrollment = lastEnrollment { + json.merge(lastEnrollment.toJSON()) { (_, new) in new } + } + + json[MobileDeviceGeneral.ManagedKey] = isManaged + json[MobileDeviceGeneral.SupervisedKey] = isSupervised + json[MobileDeviceGeneral.ExchangeActiveSyncDeviceIdentifierKey] = exchangeActiveSyncDeviceIdentifier + json[MobileDeviceGeneral.SharedKey] = shared + json[MobileDeviceGeneral.TetheredKey] = tethered + json[MobileDeviceGeneral.BatteryLevelKey] = batteryLevel + json[MobileDeviceGeneral.BluetoothCapableKey] = isBluetoothCapable + json[MobileDeviceGeneral.DeviceLocatorServiceEnabledKey] = isDeviceLocatorServiceEnabled + json[MobileDeviceGeneral.DoNotDisturbEnabledKey] = isDoNotDisturbEnabled + json[MobileDeviceGeneral.CloudBackupEnabledKey] = isCloudBackupEnabled + + if let lastCloudBackupDate = lastCloudBackupDate { + json.merge(lastCloudBackupDate.toJSON()) { (_, new) in new } + } + + json[MobileDeviceGeneral.LocationServicesEnabledKey] = isLocationServicesEnabled + json[MobileDeviceGeneral.ITunesStoreAccountIsActiveKey] = isITunesStoreAccountActive + + if let lastBackupTime = lastBackupTime { + json.merge(lastBackupTime.toJSON()) { (_, new) in new } + } + + return json + } +} diff --git a/JAMFKit/Tests/Models/Hardware/HardwareGeneralTests.swift b/JamfKit/Tests/Models/Computer/ComputerGeneralTests.swift similarity index 57% rename from JAMFKit/Tests/Models/Hardware/HardwareGeneralTests.swift rename to JamfKit/Tests/Models/Computer/ComputerGeneralTests.swift index c1710e7..0a40332 100644 --- a/JAMFKit/Tests/Models/Hardware/HardwareGeneralTests.swift +++ b/JamfKit/Tests/Models/Computer/ComputerGeneralTests.swift @@ -9,12 +9,12 @@ import XCTest @testable import JAMFKit -class HardwareGeneralTests: XCTestCase { +class ComputerGeneralTests: XCTestCase { // MARK: - Constants let defaultIdentifier: UInt = 12345 - let defaultName = "hardware" + let defaultName = "computer" let defaultMacAddress = "E0:AC:CB:97:36:G4" let defaultAlternativeMacAddress = "E0:AC:CB:97:36:G4" let defaultIpAddress = "10.1.1.1" @@ -38,19 +38,15 @@ class HardwareGeneralTests: XCTestCase { // MARK: - Tests func testShouldInitializeFromJSON() { - let payload = self.payload(for: "hardware_general_valid")! - guard let generalPayload = payload[Hardware.GeneralKey] as? [String: AnyObject] else { - XCTFail() - return - } + let payload = self.payload(for: "computer_general_valid")! - let defaultReportDate = PreciseDate(json: generalPayload, node: "report_date") - let defaultLastContactTime = PreciseDate(json: generalPayload, node: "last_contact_time") - let defaultInitialEntryDate = PreciseDate(json: generalPayload, node: "initial_entry_date") - let defaultLastCloudBackupDate = PreciseDate(json: generalPayload, node: "last_cloud_backup_date") - let defaultLastEnrolledDate = PreciseDate(json: generalPayload, node: "last_enrolled_date") + let defaultReportDate = PreciseDate(json: payload, node: "report_date") + let defaultLastContactTime = PreciseDate(json: payload, node: "last_contact_time") + let defaultInitialEntryDate = PreciseDate(json: payload, node: "initial_entry_date") + let defaultLastCloudBackupDate = PreciseDate(json: payload, node: "last_cloud_backup_date") + let defaultLastEnrolledDate = PreciseDate(json: payload, node: "last_enrolled_date") - let actualValue = HardwareGeneral(json: payload, node: Hardware.GeneralKey) + let actualValue = ComputerGeneral(json: payload) XCTAssertNotNil(actualValue) XCTAssertEqual(actualValue?.identifier, defaultIdentifier) @@ -94,19 +90,15 @@ class HardwareGeneralTests: XCTestCase { } func testShouldInitializeFromIncompleteJSON() { - let payload = self.payload(for: "hardware_general_incomplete")! - guard let generalPayload = payload[Hardware.GeneralKey] as? [String: AnyObject] else { - XCTFail() - return - } + let payload = self.payload(for: "computer_general_incomplete")! - let defaultReportDate = PreciseDate(json: generalPayload, node: "report_date") - let defaultLastContactTime = PreciseDate(json: generalPayload, node: "last_contact_time") - let defaultInitialEntryDate = PreciseDate(json: generalPayload, node: "initial_entry_date") - let defaultLastCloudBackupDate = PreciseDate(json: generalPayload, node: "last_cloud_backup_date") - let defaultLastEnrolledDate = PreciseDate(json: generalPayload, node: "last_enrolled_date") + let defaultReportDate = PreciseDate(json: payload, node: "report_date") + let defaultLastContactTime = PreciseDate(json: payload, node: "last_contact_time") + let defaultInitialEntryDate = PreciseDate(json: payload, node: "initial_entry_date") + let defaultLastCloudBackupDate = PreciseDate(json: payload, node: "last_cloud_backup_date") + let defaultLastEnrolledDate = PreciseDate(json: payload, node: "last_enrolled_date") - let actualValue = HardwareGeneral(json: payload, node: Hardware.GeneralKey) + let actualValue = ComputerGeneral(json: payload) XCTAssertNotNil(actualValue) XCTAssertEqual(actualValue?.identifier, defaultIdentifier) @@ -142,100 +134,92 @@ class HardwareGeneralTests: XCTestCase { } func testShouldNotInitializeFromInvalidJSON() { - let payload = self.payload(for: "hardware_general_invalid")! + let payload = self.payload(for: "computer_general_invalid")! - let site = HardwareGeneral(json: payload, node: Hardware.GeneralKey) - - XCTAssertNil(site) - } - - func testShouldNotInitializeFromMalformedJSON() { - let payload = self.payload(for: "hardware_general_malformed")! - - let site = HardwareGeneral(json: payload, node: Hardware.GeneralKey) + let site = ComputerGeneral(json: payload) XCTAssertNil(site) } func testShouldEncodeToJSON() { - let payload = self.payload(for: "hardware_general_valid")! + let payload = self.payload(for: "computer_general_valid")! - let actualValue = HardwareGeneral(json: payload, node: Hardware.GeneralKey) + let actualValue = ComputerGeneral(json: payload) let encodedObject = actualValue?.toJSON() XCTAssertNotNil(encodedObject) XCTAssertEqual(encodedObject?.count, 34) - XCTAssertNotNil(encodedObject?[HardwareGeneral.IdentifierKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.NameKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.MacAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.AlternativeMacAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.IpAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastReportedIPAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.SerialNumberKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.UDIDKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.JAMFVersionKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.PlatformKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.Barcode1Key]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.Barcode2Key]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.AssetTagKey]) - XCTAssertNotNil(encodedObject?[HardwareRemoteManagement.ContainerKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.MdmCapableKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.MdmCapableUsersKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ReportDateKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ReportDateKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ReportDateKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastContactTimeKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastContactTimeKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastContactTimeKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.InitialEntryDateKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.InitialEntryDateKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.InitialEntryDateKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastCloudBackupDateKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastCloudBackupDateKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastEnrolledDateKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastEnrolledDateKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.DistributionPointKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.SusKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.NetbootServerKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.SiteKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ItunesStoreAccountIsActiveKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.IdentifierKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.NameKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.MacAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.AlternativeMacAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.IpAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastReportedIPAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.SerialNumberKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.UDIDKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.JAMFVersionKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.PlatformKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.Barcode1Key]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.Barcode2Key]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.AssetTagKey]) + XCTAssertNotNil(encodedObject?[ComputerRemoteManagement.ContainerKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.MdmCapableKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.MdmCapableUsersKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ReportDateKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ReportDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ReportDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastContactTimeKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastContactTimeKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastContactTimeKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.InitialEntryDateKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.InitialEntryDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.InitialEntryDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastCloudBackupDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastCloudBackupDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastEnrolledDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastEnrolledDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.DistributionPointKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.SusKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.NetbootServerKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.SiteKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ItunesStoreAccountIsActiveKey]) } func testIncompleteShouldEncodeToJSON() { - let payload = self.payload(for: "hardware_general_incomplete")! + let payload = self.payload(for: "computer_general_incomplete")! - let actualValue = HardwareGeneral(json: payload, node: Hardware.GeneralKey) + let actualValue = ComputerGeneral(json: payload) let encodedObject = actualValue?.toJSON() XCTAssertNotNil(encodedObject) XCTAssertEqual(encodedObject?.count, 26) - XCTAssertNotNil(encodedObject?[HardwareGeneral.IdentifierKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.NameKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.MacAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.AlternativeMacAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.IpAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastReportedIPAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.SerialNumberKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.UDIDKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.JAMFVersionKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.PlatformKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.MdmCapableKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ReportDateKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ReportDateKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ReportDateKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastContactTimeKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastContactTimeKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastContactTimeKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.InitialEntryDateKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.InitialEntryDateKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.InitialEntryDateKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastCloudBackupDateKey + PreciseDate.EpochKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.LastCloudBackupDateKey + PreciseDate.UTCKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.DistributionPointKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.SusKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.NetbootServerKey]) - XCTAssertNotNil(encodedObject?[HardwareGeneral.ItunesStoreAccountIsActiveKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.IdentifierKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.NameKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.MacAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.AlternativeMacAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.IpAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastReportedIPAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.SerialNumberKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.UDIDKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.JAMFVersionKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.PlatformKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.MdmCapableKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ReportDateKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ReportDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ReportDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastContactTimeKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastContactTimeKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastContactTimeKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.InitialEntryDateKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.InitialEntryDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.InitialEntryDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastCloudBackupDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.LastCloudBackupDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.DistributionPointKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.SusKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.NetbootServerKey]) + XCTAssertNotNil(encodedObject?[ComputerGeneral.ItunesStoreAccountIsActiveKey]) } } diff --git a/JAMFKit/Tests/Models/Hardware/HardwareLocationTests.swift b/JamfKit/Tests/Models/Computer/ComputerLocationTests.swift similarity index 50% rename from JAMFKit/Tests/Models/Hardware/HardwareLocationTests.swift rename to JamfKit/Tests/Models/Computer/ComputerLocationTests.swift index cfb12a3..7ee2daa 100644 --- a/JAMFKit/Tests/Models/Hardware/HardwareLocationTests.swift +++ b/JamfKit/Tests/Models/Computer/ComputerLocationTests.swift @@ -9,7 +9,7 @@ import XCTest @testable import JAMFKit -class HardwareLocationTests: XCTestCase { +class ComputerLocationTests: XCTestCase { // MARK: - Constants @@ -25,9 +25,9 @@ class HardwareLocationTests: XCTestCase { // MARK: - Tests func testShouldInitializeFromJSON() { - let payload = self.payload(for: "hardware_location")! + let payload = self.payload(for: "computer_location")! - let actualValue = HardwareLocation(json: payload) + let actualValue = ComputerLocation(json: payload) XCTAssertNotNil(actualValue) XCTAssertEqual(actualValue?.username, defaultUsername) @@ -40,21 +40,35 @@ class HardwareLocationTests: XCTestCase { XCTAssertEqual(actualValue?.room, defaultRoom) } + func testShouldInitializeFromEmptyJSON() { + let actualValue = ComputerLocation(json: [String: Any]()) + + XCTAssertNotNil(actualValue) + XCTAssertEqual(actualValue?.username, "") + XCTAssertEqual(actualValue?.realName, "") + XCTAssertEqual(actualValue?.emailAddress, "") + XCTAssertEqual(actualValue?.position, "") + XCTAssertEqual(actualValue?.phoneNumber, "") + XCTAssertEqual(actualValue?.department, "") + XCTAssertEqual(actualValue?.building, "") + XCTAssertEqual(actualValue?.room, 0) + } + func testShouldEncodeToJSON() { - let payload = self.payload(for: "hardware_location")! + let payload = self.payload(for: "computer_location")! - let actualValue = HardwareLocation(json: payload) + let actualValue = ComputerLocation(json: payload) let encodedObject = actualValue?.toJSON() XCTAssertNotNil(encodedObject) XCTAssertEqual(encodedObject?.count, 8) - XCTAssertNotNil(encodedObject?[HardwareLocation.UsernameKey]) - XCTAssertNotNil(encodedObject?[HardwareLocation.RealNameKey]) - XCTAssertNotNil(encodedObject?[HardwareLocation.EmailAddressKey]) - XCTAssertNotNil(encodedObject?[HardwareLocation.PositionKey]) - XCTAssertNotNil(encodedObject?[HardwareLocation.PhoneNumberKey]) - XCTAssertNotNil(encodedObject?[HardwareLocation.DepartementKey]) - XCTAssertNotNil(encodedObject?[HardwareLocation.BuildingKey]) - XCTAssertNotNil(encodedObject?[HardwareLocation.RoomKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.UsernameKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.RealNameKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.EmailAddressKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.PositionKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.PhoneNumberKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.DepartementKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.BuildingKey]) + XCTAssertNotNil(encodedObject?[ComputerLocation.RoomKey]) } } diff --git a/JAMFKit/Tests/Models/Hardware/HardwarePurchasingTests.swift b/JamfKit/Tests/Models/Computer/ComputerPurchasingTests.swift similarity index 56% rename from JAMFKit/Tests/Models/Hardware/HardwarePurchasingTests.swift rename to JamfKit/Tests/Models/Computer/ComputerPurchasingTests.swift index 595461c..472d72c 100644 --- a/JAMFKit/Tests/Models/Hardware/HardwarePurchasingTests.swift +++ b/JamfKit/Tests/Models/Computer/ComputerPurchasingTests.swift @@ -1,5 +1,5 @@ // -// HardwarePurchasingTests.swift +// ComputerPurchasingTests.swift // JAMFKit // // Copyright © 2018 JAMFKit. All rights reserved. @@ -9,7 +9,7 @@ import XCTest @testable import JAMFKit -class HardwarePurchasingTests: XCTestCase { +class ComputerPurchasingTests: XCTestCase { // MARK: - Constants @@ -26,13 +26,13 @@ class HardwarePurchasingTests: XCTestCase { // MARK: - Tests func testShouldInitializeFromJSON() { - let payload = self.payload(for: "hardware_purchasing")! + let payload = self.payload(for: "computer_purchasing")! let defaultPoDate = PreciseDate(json: payload, node: "po_date") let defaultWarrantyExpires = PreciseDate(json: payload, node: "warranty_expires") let defaultLeaseExpires = PreciseDate(json: payload, node: "lease_expires") - let actualValue = HardwarePurchasing(json: payload) + let actualValue = ComputerPurchasing(json: payload) XCTAssertNotNil(actualValue) XCTAssertEqual(actualValue?.isPurchased, defaultIsPurchased) @@ -55,31 +55,46 @@ class HardwarePurchasingTests: XCTestCase { XCTAssertEqual(actualValue?.lifeExpectancy, defaultLifeExpectancy) } + func testShouldInitializeFromEmptyJSON() { + let actualValue = ComputerPurchasing(json: [String: Any]()) + + XCTAssertNotNil(actualValue) + XCTAssertEqual(actualValue?.isPurchased, false) + XCTAssertEqual(actualValue?.isLeased, false) + XCTAssertEqual(actualValue?.poNumber, "") + XCTAssertEqual(actualValue?.vendor, "") + XCTAssertEqual(actualValue?.appleCareIdentifier, "") + XCTAssertEqual(actualValue?.purchasePrice, "") + XCTAssertEqual(actualValue?.purchasingAccount, "") + XCTAssertEqual(actualValue?.purchasingContact, "") + XCTAssertEqual(actualValue?.lifeExpectancy, 0) + } + func testShouldEncodeToJSON() { - let payload = self.payload(for: "hardware_purchasing")! + let payload = self.payload(for: "computer_purchasing")! - let actualValue = HardwarePurchasing(json: payload) + let actualValue = ComputerPurchasing(json: payload) let encodedObject = actualValue?.toJSON() XCTAssertNotNil(encodedObject) XCTAssertEqual(encodedObject?.count, 18) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.IsPurchasedKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.IsLeasedKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.PoNumberKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.VendorKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.AppleCareIdentifierKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.PurchasePriceKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.PurchasingAccountKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.PurchasingContactKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.PoDateKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.PoDateKey + "_epoch"]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.PoDateKey + "_utc"]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.WarrantyExpiresKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.WarrantyExpiresKey + "_epoch"]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.WarrantyExpiresKey + "_utc"]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.LeaseExpiresKey]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.LeaseExpiresKey + "_epoch"]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.LeaseExpiresKey + "_utc"]) - XCTAssertNotNil(encodedObject?[HardwarePurchasing.LifeExpectancyKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.IsPurchasedKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.IsLeasedKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.PoNumberKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.VendorKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.AppleCareIdentifierKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.PurchasePriceKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.PurchasingAccountKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.PurchasingContactKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.PoDateKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.PoDateKey + "_epoch"]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.PoDateKey + "_utc"]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.WarrantyExpiresKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.WarrantyExpiresKey + "_epoch"]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.WarrantyExpiresKey + "_utc"]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.LeaseExpiresKey]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.LeaseExpiresKey + "_epoch"]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.LeaseExpiresKey + "_utc"]) + XCTAssertNotNil(encodedObject?[ComputerPurchasing.LifeExpectancyKey]) } } diff --git a/JAMFKit/Tests/Models/Hardware/HardwareRemoteManagementTests.swift b/JamfKit/Tests/Models/Computer/ComputerRemoteManagementTests.swift similarity index 63% rename from JAMFKit/Tests/Models/Hardware/HardwareRemoteManagementTests.swift rename to JamfKit/Tests/Models/Computer/ComputerRemoteManagementTests.swift index d7eb386..3574606 100644 --- a/JAMFKit/Tests/Models/Hardware/HardwareRemoteManagementTests.swift +++ b/JamfKit/Tests/Models/Computer/ComputerRemoteManagementTests.swift @@ -1,5 +1,5 @@ // -// HardwareRemoteManagementTests.swift +// ComputerRemoteManagementTests.swift // JAMFKit // // Copyright © 2017 JAMFKit. All rights reserved. @@ -9,7 +9,7 @@ import XCTest @testable import JAMFKit -class HardwareRemoteManagementTests: XCTestCase { +class ComputerRemoteManagementTests: XCTestCase { // MARK: - Constants @@ -19,9 +19,9 @@ class HardwareRemoteManagementTests: XCTestCase { // MARK: - Tests func testShouldInitializeFromJSON() { - let payload = self.payload(for: "hardware_remote_management")! + let payload = self.payload(for: "computer_remote_management")! - let actualValue = HardwareRemoteManagement(json: payload) + let actualValue = ComputerRemoteManagement(json: payload) XCTAssertNotNil(actualValue) XCTAssertEqual(actualValue?.isManaged, defaultManaged) @@ -29,7 +29,7 @@ class HardwareRemoteManagementTests: XCTestCase { } func testShouldInitializeFromEmptyJSON() { - let actualValue = HardwareRemoteManagement(json: [String: Any]()) + let actualValue = ComputerRemoteManagement(json: [String: Any]()) XCTAssertNotNil(actualValue) XCTAssertEqual(actualValue?.isManaged, false) @@ -37,14 +37,14 @@ class HardwareRemoteManagementTests: XCTestCase { } func testShouldEncodeToJSON() { - let payload = self.payload(for: "hardware_remote_management")! + let payload = self.payload(for: "computer_remote_management")! - let actualValue = HardwareRemoteManagement(json: payload) + let actualValue = ComputerRemoteManagement(json: payload) let encodedObject = actualValue?.toJSON() XCTAssertNotNil(encodedObject) XCTAssertEqual(encodedObject?.count, 2) - XCTAssertNotNil(encodedObject?[HardwareRemoteManagement.ManagedKey]) - XCTAssertNotNil(encodedObject?[HardwareRemoteManagement.ManagementUsernameKey]) + XCTAssertNotNil(encodedObject?[ComputerRemoteManagement.ManagedKey]) + XCTAssertNotNil(encodedObject?[ComputerRemoteManagement.ManagementUsernameKey]) } } diff --git a/JAMFKit/Tests/Models/ComputerTests.swift b/JamfKit/Tests/Models/Computer/ComputerTests.swift similarity index 93% rename from JAMFKit/Tests/Models/ComputerTests.swift rename to JamfKit/Tests/Models/Computer/ComputerTests.swift index 700ac2c..e8a7c8e 100644 --- a/JAMFKit/Tests/Models/ComputerTests.swift +++ b/JamfKit/Tests/Models/Computer/ComputerTests.swift @@ -31,8 +31,8 @@ class ComputerTests: XCTestCase { XCTAssertNotNil(actualValue) XCTAssertEqual(actualValue?.description, "[Computer]") XCTAssertNil(actualValue?.general) - XCTAssertNotNil(actualValue?.location) - XCTAssertNotNil(actualValue?.purchasing) + XCTAssertNil(actualValue?.location) + XCTAssertNil(actualValue?.purchasing) } func testShouldEncodeToJSON() { diff --git a/JamfKit/Tests/Models/MobileDevice/MobileDeviceGeneralTests.swift b/JamfKit/Tests/Models/MobileDevice/MobileDeviceGeneralTests.swift new file mode 100644 index 0000000..f79246c --- /dev/null +++ b/JamfKit/Tests/Models/MobileDevice/MobileDeviceGeneralTests.swift @@ -0,0 +1,289 @@ +// +// MobileDeviceGeneralTests.swift +// JAMFKit +// +// Copyright © 2018 JAMFKit. All rights reserved. +// + +import XCTest + +@testable import JAMFKit + +class MobileDeviceGeneralTests: XCTestCase { + + // MARK: - Constants + + let defaultIdentifier: UInt = 12345 + let defaultName = "Mobile Device" + let defaultDisplayName = "Mobile Device" + let defaultDeviceName = "mobile_device" + let defaultAssetTag = "asset_tag" + let defaultCapacity: UInt = 1024 + let defaultCapacityMb: UInt = 1024 + let defaultAvailable: UInt = 1024 + let defaultAvailableMb: UInt = 1024 + let defaultPercentageUsed: UInt = 5 + let defaultOsType = "iOS" + let defaultOsVersion = "10.3.2" + let defaultOsBuild = "14F89" + let defaultSerialNumber = "C02Q7KHTGFWF" + let defaultUdid = "270aae10800b6e61a2ee2bbc285eb967050b5984" + let defaultPhoneNumber = "123-555-6789" + let defaultIpAddress = "192.0.0.1" + let defaultWifiMacAddress = "E0:AC:CB:97:36:G4" + let defaultBluetoothMacAddress = "E0:AC:CB:97:36:G6" + let defaultModemFirmware = "2.61.00" + let defaultModel = "iPhone 6S" + let defaultModelIdentifier = "iPhone8,1" + let defaultModelNumber = "MKRY2LL" + let defaultModelDisplay = "iPhone 6S" + let defaultDeviceOwnershipLevel = "Institutional" + let defaultIsManaged = true + let defaultIsSupervised = true + let defaultExchangeActiveSyncDeviceIdentifier = "TUCLLFJHPL779ACL9DCJQFN39F" + let defaultShared = "shared" + let defaultTethered = "tethered" + let defaultBatteryLevel: UInt = 95 + let defaultIsBluetoothCapable = true + let defaultIsDeviceLocatorServiceEnabled = true + let defaultIsDoNotDisturbEnabled = true + let defaultIsCloudBackupEnabled = true + let defaultIsLocationServicesEnabled = true + let defaultIsITunesStoreAccountActive = true + + // MARK: - Tests + + func testShouldInitializeFromJSON() { + let payload = self.payload(for: "mobile_device_general_valid")! + + let defaultLastInventoryUpdate = PreciseDate(json: payload, node: "last_inventory_update") + let defaultInitialEntryDate = PreciseDate(json: payload, node: "initial_entry_date") + let defaultLastEnrollment = PreciseDate(json: payload, node: "last_enrollment") + let defaultLastCloudBackupDate = PreciseDate(json: payload, node: "last_cloud_backup_date") + let defaultLastBackupTime = PreciseDate(json: payload, node: "last_backup_time") + + let actualValue = MobileDeviceGeneral(json: payload) + + XCTAssertNotNil(actualValue) + XCTAssertEqual(actualValue?.identifier, defaultIdentifier) + XCTAssertEqual(actualValue?.name, defaultName) + XCTAssertEqual(actualValue?.deviceName, defaultDeviceName) + XCTAssertEqual(actualValue?.assetTag, defaultAssetTag) + XCTAssertEqual(actualValue?.lastInventoryUpdate?.date, defaultLastInventoryUpdate?.date) + XCTAssertEqual(actualValue?.lastInventoryUpdate?.epoch, defaultLastInventoryUpdate?.epoch) + XCTAssertEqual(actualValue?.lastInventoryUpdate?.dateUTC, defaultLastInventoryUpdate?.dateUTC) + XCTAssertEqual(actualValue?.capacity, defaultCapacity) + XCTAssertEqual(actualValue?.capacityMb, defaultCapacityMb) + XCTAssertEqual(actualValue?.available, defaultAvailable) + XCTAssertEqual(actualValue?.availableMb, defaultAvailableMb) + XCTAssertEqual(actualValue?.percentageUsed, defaultPercentageUsed) + XCTAssertEqual(actualValue?.osType, defaultOsType) + XCTAssertEqual(actualValue?.osVersion, defaultOsVersion) + XCTAssertEqual(actualValue?.osBuild, defaultOsBuild) + XCTAssertEqual(actualValue?.serialNumber, defaultSerialNumber) + XCTAssertEqual(actualValue?.udid, defaultUdid) + XCTAssertNil(actualValue?.initialEntryDate?.date) + XCTAssertEqual(actualValue?.initialEntryDate?.epoch, defaultInitialEntryDate?.epoch) + XCTAssertEqual(actualValue?.initialEntryDate?.dateUTC, defaultInitialEntryDate?.dateUTC) + XCTAssertEqual(actualValue?.phoneNumber, defaultPhoneNumber) + XCTAssertEqual(actualValue?.ipAddress, defaultIpAddress) + XCTAssertEqual(actualValue?.wifiMacAddress, defaultWifiMacAddress) + XCTAssertEqual(actualValue?.bluetoothMacAddress, defaultBluetoothMacAddress) + XCTAssertEqual(actualValue?.modemFirmware, defaultModemFirmware) + XCTAssertEqual(actualValue?.model, defaultModel) + XCTAssertEqual(actualValue?.modelIdentifier, defaultModelIdentifier) + XCTAssertEqual(actualValue?.modelNumber, defaultModelNumber) + XCTAssertEqual(actualValue?.modelDisplay, defaultModelDisplay) + XCTAssertEqual(actualValue?.deviceOwnershipLevel, defaultDeviceOwnershipLevel) + XCTAssertNil(actualValue?.lastEnrollment?.date) + XCTAssertEqual(actualValue?.lastEnrollment?.epoch, defaultLastEnrollment?.epoch) + XCTAssertEqual(actualValue?.lastEnrollment?.dateUTC, defaultLastEnrollment?.dateUTC) + XCTAssertEqual(actualValue?.isManaged, defaultIsManaged) + XCTAssertEqual(actualValue?.isSupervised, defaultIsSupervised) + XCTAssertEqual(actualValue?.exchangeActiveSyncDeviceIdentifier, defaultExchangeActiveSyncDeviceIdentifier) + XCTAssertEqual(actualValue?.shared, defaultShared) + XCTAssertEqual(actualValue?.tethered, defaultTethered) + XCTAssertEqual(actualValue?.batteryLevel, defaultBatteryLevel) + XCTAssertEqual(actualValue?.isBluetoothCapable, defaultIsBluetoothCapable) + XCTAssertEqual(actualValue?.isDeviceLocatorServiceEnabled, defaultIsDeviceLocatorServiceEnabled) + XCTAssertEqual(actualValue?.isDoNotDisturbEnabled, defaultIsDoNotDisturbEnabled) + XCTAssertEqual(actualValue?.isCloudBackupEnabled, defaultIsCloudBackupEnabled) + XCTAssertNil(actualValue?.lastCloudBackupDate?.date) + XCTAssertEqual(actualValue?.lastCloudBackupDate?.epoch, defaultLastCloudBackupDate?.epoch) + XCTAssertEqual(actualValue?.lastCloudBackupDate?.dateUTC, defaultLastCloudBackupDate?.dateUTC) + XCTAssertEqual(actualValue?.isLocationServicesEnabled, defaultIsLocationServicesEnabled) + XCTAssertEqual(actualValue?.isITunesStoreAccountActive, defaultIsITunesStoreAccountActive) + XCTAssertNil(actualValue?.lastBackupTime?.date) + XCTAssertEqual(actualValue?.lastBackupTime?.epoch, defaultLastBackupTime?.epoch) + XCTAssertEqual(actualValue?.lastBackupTime?.dateUTC, defaultLastBackupTime?.dateUTC) + + } + + func testShouldInitializeFromIncompleteJSON() { + let payload = self.payload(for: "mobile_device_general_incomplete")! + + let defaultLastInventoryUpdate = PreciseDate(json: payload, node: "last_inventory_update") + let defaultInitialEntryDate = PreciseDate(json: payload, node: "initial_entry_date") + let defaultLastEnrollment = PreciseDate(json: payload, node: "last_enrollment") + let defaultLastCloudBackupDate = PreciseDate(json: payload, node: "last_cloud_backup_date") + let defaultLastBackupTime = PreciseDate(json: payload, node: "last_backup_time") + + let actualValue = MobileDeviceGeneral(json: payload) + + XCTAssertNotNil(actualValue) + XCTAssertEqual(actualValue?.identifier, defaultIdentifier) + XCTAssertEqual(actualValue?.name, defaultName) + XCTAssertEqual(actualValue?.deviceName, "") + XCTAssertEqual(actualValue?.assetTag, "") + XCTAssertEqual(actualValue?.lastInventoryUpdate?.date, defaultLastInventoryUpdate?.date) + XCTAssertEqual(actualValue?.lastInventoryUpdate?.epoch, defaultLastInventoryUpdate?.epoch) + XCTAssertEqual(actualValue?.lastInventoryUpdate?.dateUTC, defaultLastInventoryUpdate?.dateUTC) + XCTAssertEqual(actualValue?.capacity, 0) + XCTAssertEqual(actualValue?.capacityMb, 0) + XCTAssertEqual(actualValue?.available, 0) + XCTAssertEqual(actualValue?.availableMb, 0) + XCTAssertEqual(actualValue?.percentageUsed, 0) + XCTAssertEqual(actualValue?.osType, "") + XCTAssertEqual(actualValue?.osVersion, "") + XCTAssertEqual(actualValue?.osBuild, "") + XCTAssertEqual(actualValue?.serialNumber, "") + XCTAssertEqual(actualValue?.udid, "") + XCTAssertNil(actualValue?.initialEntryDate?.date) + XCTAssertEqual(actualValue?.initialEntryDate?.epoch, defaultInitialEntryDate?.epoch) + XCTAssertEqual(actualValue?.initialEntryDate?.dateUTC, defaultInitialEntryDate?.dateUTC) + XCTAssertEqual(actualValue?.phoneNumber, "") + XCTAssertEqual(actualValue?.ipAddress, "") + XCTAssertEqual(actualValue?.wifiMacAddress, "") + XCTAssertEqual(actualValue?.bluetoothMacAddress, "") + XCTAssertEqual(actualValue?.modemFirmware, "") + XCTAssertEqual(actualValue?.model, "") + XCTAssertEqual(actualValue?.modelIdentifier, "") + XCTAssertEqual(actualValue?.modelNumber, "") + XCTAssertEqual(actualValue?.modelDisplay, "") + XCTAssertEqual(actualValue?.deviceOwnershipLevel, "") + XCTAssertNil(actualValue?.lastEnrollment?.date) + XCTAssertEqual(actualValue?.lastEnrollment?.epoch, defaultLastEnrollment?.epoch) + XCTAssertEqual(actualValue?.lastEnrollment?.dateUTC, defaultLastEnrollment?.dateUTC) + XCTAssertEqual(actualValue?.isManaged, false) + XCTAssertEqual(actualValue?.isSupervised, false) + XCTAssertEqual(actualValue?.exchangeActiveSyncDeviceIdentifier, "") + XCTAssertEqual(actualValue?.shared, "") + XCTAssertEqual(actualValue?.tethered, "") + XCTAssertEqual(actualValue?.batteryLevel, 0) + XCTAssertEqual(actualValue?.isBluetoothCapable, false) + XCTAssertEqual(actualValue?.isDeviceLocatorServiceEnabled, false) + XCTAssertEqual(actualValue?.isDoNotDisturbEnabled, false) + XCTAssertEqual(actualValue?.isCloudBackupEnabled, false) + XCTAssertNil(actualValue?.lastCloudBackupDate?.date) + XCTAssertEqual(actualValue?.lastCloudBackupDate?.epoch, defaultLastCloudBackupDate?.epoch) + XCTAssertEqual(actualValue?.lastCloudBackupDate?.dateUTC, defaultLastCloudBackupDate?.dateUTC) + XCTAssertEqual(actualValue?.isLocationServicesEnabled, false) + XCTAssertEqual(actualValue?.isITunesStoreAccountActive, false) + XCTAssertNil(actualValue?.lastBackupTime?.date) + XCTAssertEqual(actualValue?.lastBackupTime?.epoch, defaultLastBackupTime?.epoch) + XCTAssertEqual(actualValue?.lastBackupTime?.dateUTC, defaultLastBackupTime?.dateUTC) + } + + func testShouldNotInitializeFromInvalidJSON() { + let payload = self.payload(for: "mobile_device_general_invalid")! + + let site = MobileDeviceGeneral(json: payload) + + XCTAssertNil(site) + } + + func testShouldEncodeToJSON() { + let payload = self.payload(for: "mobile_device_general_valid")! + + let actualValue = MobileDeviceGeneral(json: payload) + let encodedObject = actualValue?.toJSON() + + XCTAssertNotNil(encodedObject) + XCTAssertEqual(encodedObject?.count, 48) + + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.IdentifierKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.NameKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.DeviceNameKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.AssetTagNameKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastInventoryUpdateKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastInventoryUpdateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastInventoryUpdateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.CapacityKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.CapacityMbKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.AvailableKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.AvailableMbKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.PercentageUsedKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.OSTypeKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.OSVersionKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.OSBuildKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.SerialNumberKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.UDIDKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.InitialEntryDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.InitialEntryDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.PhoneNumberKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.IPAddressKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.WifiMacAddressKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.BluetoothMacAddressKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ModemFirmwareKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ModelKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ModelIdentifierKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ModelNumberKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ModelDisplayKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.DeviceOwnershipLevelKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastEnrollmentKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastEnrollmentKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ManagedKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.SupervisedKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ExchangeActiveSyncDeviceIdentifierKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.SharedKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.TetheredKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.BatteryLevelKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.BluetoothCapableKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.DeviceLocatorServiceEnabledKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.DoNotDisturbEnabledKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.CloudBackupEnabledKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastCloudBackupDateKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastCloudBackupDateKey + PreciseDate.UTCKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LocationServicesEnabledKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ITunesStoreAccountIsActiveKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastBackupTimeKey + PreciseDate.EpochKey]) + XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastBackupTimeKey + PreciseDate.UTCKey]) + } + +// func testIncompleteShouldEncodeToJSON() { +// let payload = self.payload(for: "mobile_device_general_incomplete")! +// +// let actualValue = MobileDeviceGeneral(json: payload) +// let encodedObject = actualValue?.toJSON() +// +// XCTAssertNotNil(encodedObject) +// XCTAssertEqual(encodedObject?.count, 26) +// +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.IdentifierKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.NameKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.MacAddressKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.AlternativeMacAddressKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.IpAddressKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastReportedIPAddressKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.SerialNumberKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.UDIDKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.JAMFVersionKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.PlatformKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.MdmCapableKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ReportDateKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ReportDateKey + PreciseDate.EpochKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ReportDateKey + PreciseDate.UTCKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastContactTimeKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastContactTimeKey + PreciseDate.EpochKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastContactTimeKey + PreciseDate.UTCKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.InitialEntryDateKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.InitialEntryDateKey + PreciseDate.EpochKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.InitialEntryDateKey + PreciseDate.UTCKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastCloudBackupDateKey + PreciseDate.EpochKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.LastCloudBackupDateKey + PreciseDate.UTCKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.DistributionPointKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.SusKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.NetbootServerKey]) +// XCTAssertNotNil(encodedObject?[MobileDeviceGeneral.ItunesStoreAccountIsActiveKey]) +// } +} diff --git a/JamfKit/Tests/Models/MobileDevice/MobileDeviceTests.swift b/JamfKit/Tests/Models/MobileDevice/MobileDeviceTests.swift new file mode 100644 index 0000000..96e7c91 --- /dev/null +++ b/JamfKit/Tests/Models/MobileDevice/MobileDeviceTests.swift @@ -0,0 +1,44 @@ +// +// MobileDeviceTests.swift +// JAMFKit +// +// Copyright © 2018 JAMFKit. All rights reserved. +// + +import XCTest + +@testable import JAMFKit + +class MobileDeviceTests: XCTestCase { + + // MARK: - Tests + + func testShouldInitializeFromJSON() { + let payload = self.payload(for: "mobile_device")! + + let actualValue = MobileDevice(json: payload) + + XCTAssertNotNil(actualValue) + XCTAssertEqual(actualValue?.description, "[MobileDevice][12345. Mobile Device]") + XCTAssertNotNil(actualValue?.general) + } + + func testShouldInitializeFromEmptyJSON() { + let actualValue = MobileDevice(json: [String: Any]()) + + XCTAssertNotNil(actualValue) + XCTAssertEqual(actualValue?.description, "[MobileDevice]") + XCTAssertNil(actualValue?.general) + } + + func testShouldEncodeToJSON() { + let payload = self.payload(for: "mobile_device")! + + let actualValue = MobileDevice(json: payload) + let encodedObject = actualValue?.toJSON() + + XCTAssertNotNil(encodedObject) + XCTAssertEqual(encodedObject?.count, 1) + XCTAssertNotNil(encodedObject?[MobileDevice.GeneralKey]) + } +} diff --git a/JamfKit/Tests/Resources/Mocks.bundle/computer_general_incomplete.json b/JamfKit/Tests/Resources/Mocks.bundle/computer_general_incomplete.json new file mode 100644 index 0000000..52ade5c --- /dev/null +++ b/JamfKit/Tests/Resources/Mocks.bundle/computer_general_incomplete.json @@ -0,0 +1,28 @@ +{ + "id": 12345, + "name": "computer", + "mac_address": "E0:AC:CB:97:36:G4", + "alt_mac_address": "E0:AC:CB:97:36:G4", + "ip_address": "10.1.1.1", + "last_reported_ip": "192.0.0.1", + "serial_number": "C02Q7KHTGFWF", + "udid": "55900BDC-347C-58B1-D249-F32244B11D30", + "jamf_version": "9.99.0-t1494340586", + "platform": "Mac", + "mdm_capable": true, + "report_date": "2017-07-07T18:37:04.000Z", + "report_date_epoch": 1499470624555, + "report_date_utc": "2017-07-07T18:37:04.555-0500", + "last_contact_time": "2017-07-07T18:37:04.000Z", + "last_contact_time_epoch": 1499470624555, + "last_contact_time_utc": "2017-07-07T18:37:04.555-0500", + "initial_entry_date": "2017-07-07T18:37:04.000Z", + "initial_entry_date_epoch": 1499470624555, + "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", + "last_cloud_backup_date_epoch": 1499470624555, + "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", + "distribution_point": "string", + "sus": "string", + "netboot_server": "string", + "itunes_store_account_is_active": true +} diff --git a/JamfKit/Tests/Resources/Mocks.bundle/computer_general_invalid.json b/JamfKit/Tests/Resources/Mocks.bundle/computer_general_invalid.json new file mode 100644 index 0000000..b0ef880 --- /dev/null +++ b/JamfKit/Tests/Resources/Mocks.bundle/computer_general_invalid.json @@ -0,0 +1,43 @@ +{ + "id": 12345, + "mac_address": "E0:AC:CB:97:36:G4", + "alt_mac_address": "E0:AC:CB:97:36:G4", + "ip_address": "10.1.1.1", + "last_reported_ip": "192.0.0.1", + "serial_number": "C02Q7KHTGFWF", + "udid": "55900BDC-347C-58B1-D249-F32244B11D30", + "jamf_version": "9.99.0-t1494340586", + "platform": "Mac", + "barcode_1": "string", + "barcode_2": "string", + "asset_tag": "string", + "remote_management": { + "managed": true, + "management_username": "casperadmin" + }, + "mdm_capable": true, + "mdm_capable_users": { + "mdm_capable_user": "string" + }, + "report_date": "2017-07-07T18:37:04.000Z", + "report_date_epoch": 1499470624555, + "report_date_utc": "2017-07-07T18:37:04.555-0500", + "last_contact_time": "2017-07-07T18:37:04.000Z", + "last_contact_time_epoch": 1499470624555, + "last_contact_time_utc": "2017-07-07T18:37:04.555-0500", + "initial_entry_date": "2017-07-07T18:37:04.000Z", + "initial_entry_date_epoch": 1499470624555, + "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", + "last_cloud_backup_date_epoch": 1499470624555, + "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", + "last_enrolled_date_epoch": 1499470624555, + "last_enrolled_date_utc": "2017-07-07T18:37:04.555-0500", + "distribution_point": "string", + "sus": "string", + "netboot_server": "string", + "site": { + "id": 0, + "name": "None" + }, + "itunes_store_account_is_active": true +} diff --git a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_malformed.json b/JamfKit/Tests/Resources/Mocks.bundle/computer_general_valid.json similarity index 98% rename from JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_malformed.json rename to JamfKit/Tests/Resources/Mocks.bundle/computer_general_valid.json index 233c9d2..c28f0ba 100644 --- a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_general_malformed.json +++ b/JamfKit/Tests/Resources/Mocks.bundle/computer_general_valid.json @@ -1,6 +1,6 @@ { "id": 12345, - "name": "hardware", + "name": "computer", "mac_address": "E0:AC:CB:97:36:G4", "alt_mac_address": "E0:AC:CB:97:36:G4", "ip_address": "10.1.1.1", diff --git a/JamfKit/Tests/Resources/Mocks.bundle/hardware_location.json b/JamfKit/Tests/Resources/Mocks.bundle/computer_location.json similarity index 100% rename from JamfKit/Tests/Resources/Mocks.bundle/hardware_location.json rename to JamfKit/Tests/Resources/Mocks.bundle/computer_location.json diff --git a/JamfKit/Tests/Resources/Mocks.bundle/hardware_purchasing.json b/JamfKit/Tests/Resources/Mocks.bundle/computer_purchasing.json similarity index 100% rename from JamfKit/Tests/Resources/Mocks.bundle/hardware_purchasing.json rename to JamfKit/Tests/Resources/Mocks.bundle/computer_purchasing.json diff --git a/JAMFKit/Tests/Resources/Mocks.bundle/hardware_remote_management.json b/JamfKit/Tests/Resources/Mocks.bundle/computer_remote_management.json similarity index 100% rename from JAMFKit/Tests/Resources/Mocks.bundle/hardware_remote_management.json rename to JamfKit/Tests/Resources/Mocks.bundle/computer_remote_management.json diff --git a/JamfKit/Tests/Resources/Mocks.bundle/mobile_device.json b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device.json new file mode 100644 index 0000000..70cfbe1 --- /dev/null +++ b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device.json @@ -0,0 +1,52 @@ +{ + "general": { + "id": 12345, + "display_name": "Mobile Device", + "device_name": "mobile_device", + "name": "Mobile Device", + "asset_tag": "asset_tag", + "last_inventory_update": "2017-07-07T18:37:04.000Z", + "last_inventory_update_epoch": 1499470624555, + "last_inventory_update_utc": "2017-07-07T18:37:04.555-0500", + "capacity": 12159, + "capacity_mb": 12159, + "available": 11487, + "available_mb": 11487, + "percentage_used": 5, + "os_type": "iOS", + "os_version": "10.3.2", + "os_build": "14F89", + "serial_number": "C02Q7KHTGFWF", + "udid": "270aae10800b6e61a2ee2bbc285eb967050b5984", + "initial_entry_date_epoch": 1499470624555, + "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", + "phone_number": "123-555-6789", + "ip_address": "192.0.0.1", + "wifi_mac_address": "E0:AC:CB:97:36:G4", + "bluetooth_mac_address": "E0:AC:CB:97:36:G6", + "modem_firmware": "2.61.00", + "model": "iPhone 6S", + "model_identifier": "iPhone8,1", + "model_number": "MKRY2LL", + "model_display": "iPhone 6S", + "device_ownership_level": "Institutional", + "last_enrollment_epoch": 1499470624555, + "last_enrollment_utc": "2017-07-07T18:37:04.555-0500", + "managed": true, + "supervised": true, + "exchange_activesync_device_identifier": "TUCLLFJHPL779ACL9DCJQFN39F", + "shared": "string", + "tethered": "string", + "battery_level": 95, + "ble_capable": true, + "device_locator_service_enabled": true, + "do_not_disturb_enabled": true, + "cloud_backup_enabled": true, + "last_cloud_backup_date_epoch": 1499470624555, + "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", + "location_services_enabled": true, + "itunes_store_account_is_active": true, + "last_backup_time_epoch": 1499470624555, + "last_backup_time_utc": "2017-07-07T18:37:04.555-0500" + } +} diff --git a/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_incomplete.json b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_incomplete.json new file mode 100644 index 0000000..3ea14df --- /dev/null +++ b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_incomplete.json @@ -0,0 +1,15 @@ +{ + "id": 12345, + "name": "Mobile Device", + "last_inventory_update": "2017-07-07T18:37:04.000Z", + "last_inventory_update_epoch": 1499470624555, + "last_inventory_update_utc": "2017-07-07T18:37:04.555-0500", + "initial_entry_date_epoch": 1499470624555, + "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", + "last_enrollment_epoch": 1499470624555, + "last_enrollment_utc": "2017-07-07T18:37:04.555-0500", + "last_cloud_backup_date_epoch": 1499470624555, + "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", + "last_backup_time_epoch": 1499470624555, + "last_backup_time_utc": "2017-07-07T18:37:04.555-0500" +} diff --git a/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_invalid.json b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_invalid.json new file mode 100644 index 0000000..70ea5b0 --- /dev/null +++ b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_invalid.json @@ -0,0 +1,49 @@ +{ + "id": 12345, + "display_name": "Mobile Device", + "device_name": "mobile_device", + "asset_tag": "asset_tag", + "last_inventory_update": "2017-07-07T18:37:04.000Z", + "last_inventory_update_epoch": 1499470624555, + "last_inventory_update_utc": "2017-07-07T18:37:04.555-0500", + "capacity": 1024, + "capacity_mb": 1024, + "available": 1024, + "available_mb": 1024, + "percentage_used": 5, + "os_type": "iOS", + "os_version": "10.3.2", + "os_build": "14F89", + "serial_number": "C02Q7KHTGFWF", + "udid": "270aae10800b6e61a2ee2bbc285eb967050b5984", + "initial_entry_date_epoch": 1499470624555, + "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", + "phone_number": "123-555-6789", + "ip_address": "192.0.0.1", + "wifi_mac_address": "E0:AC:CB:97:36:G4", + "bluetooth_mac_address": "E0:AC:CB:97:36:G6", + "modem_firmware": "2.61.00", + "model": "iPhone 6S", + "model_identifier": "iPhone8,1", + "model_number": "MKRY2LL", + "model_display": "iPhone 6S", + "device_ownership_level": "Institutional", + "last_enrollment_epoch": 1499470624555, + "last_enrollment_utc": "2017-07-07T18:37:04.555-0500", + "managed": true, + "supervised": true, + "exchange_activesync_device_identifier": "TUCLLFJHPL779ACL9DCJQFN39F", + "shared": "shared", + "tethered": "tethered", + "battery_level": 95, + "ble_capable": true, + "device_locator_service_enabled": true, + "do_not_disturb_enabled": true, + "cloud_backup_enabled": true, + "last_cloud_backup_date_epoch": 1499470624555, + "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", + "location_services_enabled": true, + "itunes_store_account_is_active": true, + "last_backup_time_epoch": 1499470624555, + "last_backup_time_utc": "2017-07-07T18:37:04.555-0500" +} diff --git a/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_valid.json b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_valid.json new file mode 100644 index 0000000..9d5574a --- /dev/null +++ b/JamfKit/Tests/Resources/Mocks.bundle/mobile_device_general_valid.json @@ -0,0 +1,50 @@ +{ + "id": 12345, + "display_name": "Mobile Device", + "device_name": "mobile_device", + "name": "Mobile Device", + "asset_tag": "asset_tag", + "last_inventory_update": "2017-07-07T18:37:04.000Z", + "last_inventory_update_epoch": 1499470624555, + "last_inventory_update_utc": "2017-07-07T18:37:04.555-0500", + "capacity": 1024, + "capacity_mb": 1024, + "available": 1024, + "available_mb": 1024, + "percentage_used": 5, + "os_type": "iOS", + "os_version": "10.3.2", + "os_build": "14F89", + "serial_number": "C02Q7KHTGFWF", + "udid": "270aae10800b6e61a2ee2bbc285eb967050b5984", + "initial_entry_date_epoch": 1499470624555, + "initial_entry_date_utc": "2017-07-07T18:37:04.555-0500", + "phone_number": "123-555-6789", + "ip_address": "192.0.0.1", + "wifi_mac_address": "E0:AC:CB:97:36:G4", + "bluetooth_mac_address": "E0:AC:CB:97:36:G6", + "modem_firmware": "2.61.00", + "model": "iPhone 6S", + "model_identifier": "iPhone8,1", + "model_number": "MKRY2LL", + "model_display": "iPhone 6S", + "device_ownership_level": "Institutional", + "last_enrollment_epoch": 1499470624555, + "last_enrollment_utc": "2017-07-07T18:37:04.555-0500", + "managed": true, + "supervised": true, + "exchange_activesync_device_identifier": "TUCLLFJHPL779ACL9DCJQFN39F", + "shared": "shared", + "tethered": "tethered", + "battery_level": 95, + "ble_capable": true, + "device_locator_service_enabled": true, + "do_not_disturb_enabled": true, + "cloud_backup_enabled": true, + "last_cloud_backup_date_epoch": 1499470624555, + "last_cloud_backup_date_utc": "2017-07-07T18:37:04.555-0500", + "location_services_enabled": true, + "itunes_store_account_is_active": true, + "last_backup_time_epoch": 1499470624555, + "last_backup_time_utc": "2017-07-07T18:37:04.555-0500" +} diff --git a/README.md b/README.md index c05c3b1..349ec3b 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Then run the following command: #### Identifiable #### -Represents all objects that can be received from / sent to the JAMF host. Its exposes two criticals elements: +Represents all objects that can be received from / sent to the Jamf host. Its exposes two criticals elements: - An failable initializer that takes a JSON payload and return the instantiated `Identifiable` object - A function to return the JSON payload that represents the instance of the `Identifiable` object @@ -95,7 +95,7 @@ Represents all objects that can be received from / sent to the JAMF host. Its ex #### BaseObject #### -Represents the common denominator between all the JAMF objects which must contains at least an `identifier` and a `name` properties. +Represents the common denominator between all the JSS objects which must contains at least an `identifier` and a `name` properties. #### Building #### @@ -103,12 +103,16 @@ Represents a physical building. #### Computer #### -Represents a JAMF computer, contains general / location / purchasing information. +Represents a Jamf managed computer, contains the general / location / purchasing information about the hardware. #### Department #### Represents a physical department. +#### Mobile device #### + +Represents a Jamf managed mobile device, contains the general information about the device. + #### Netboot server #### Represents a physical netboot server, contains information about the server and it's configuration. @@ -135,7 +139,7 @@ Represents a physical SMTP server, contains information about the server and it' #### User #### -Represents a JAMF user and contains the identification properties that are required to contact the actual user and identify the hardware assigned to him. +Represents a Jamf user and contains the identification properties that are required to contact the actual user and identify the hardware devices assigned to him / her. ## Usage ##