Skip to content

Commit 3e1d25c

Browse files
committed
Improve Objective-C compatibility
Removed implicit “internal” access levels.
1 parent b162874 commit 3e1d25c

18 files changed

+123
-36
lines changed

.github/ISSUE_TEMPLATE.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# {Issue} OR {New feature} #
2-
31
:warning:
42

53
New issue checklist:
@@ -13,12 +11,12 @@ New issue checklist:
1311

1412
:warning:
1513

16-
*Please change the section title with the right issue type.*
17-
18-
## Short description ##
14+
# Short description #
1915

2016
*Please fill this section with a short description of your issue / new feature.*
2117

18+
-----
19+
2220
**If the ticket is about an issue, use the following sections to give more details about the issue you're facing.**
2321

2422
### Expected outcome ###
@@ -27,7 +25,9 @@ New issue checklist:
2725

2826
### Actual outcome ###
2927

30-
*Please fill this section with a description of what is actually happening. Please add as much information as you can (how easy it is to reproduce, steps, etc.).*
28+
*Please fill the following section with a description of what is actually happening. Please add as much information as you can (how easy it is to reproduce, steps, etc.).*
29+
30+
-----
3131

3232
**If the ticket is about a new feature, use the following sections to give more details about the changes you ask for / want to implement.**
3333

JamfKit/Sources/Constants.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
77
//
88

9-
internal struct Constants {
9+
struct Constants {
1010

1111
static let domain = "com.github.ethenyl.JamfKit"
1212
}

JamfKit/Sources/Extensions/StringExtension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
77
//
88

9-
internal extension String {
9+
extension String {
1010

1111
// MARK: - Functions
1212

JamfKit/Sources/Models/BaseObject.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class BaseObject: NSObject, Requestable, Identifiable {
7676
* - Parameter singleNodeKey: The string key used to identify a single element within the main node.
7777
*
7878
*/
79-
internal static func parseElements<Element: Requestable>(from json: [String: Any], nodeKey: String, singleNodeKey: String) -> [Element] {
79+
static func parseElements<Element: Requestable>(from json: [String: Any], nodeKey: String, singleNodeKey: String) -> [Element] {
8080
var elements = [Element]()
8181

8282
guard let elementsNode = json[nodeKey] as? [[String: [String: Any]]] else {

JamfKit/Sources/Models/Building.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public final class Building: BaseObject, Endpoint {
1515
public static let Endpoint: String = "buildings"
1616
}
1717

18+
// MARK: - Creatable
19+
20+
extension Building: Creatable {
21+
22+
public func create() -> URLRequest? {
23+
return self.createRequest()
24+
}
25+
}
26+
1827
// MARK: - Protocols
1928

20-
extension Building: Creatable, Readable, Updatable, Deletable { }
29+
extension Building: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/ComputerGroup/ComputerGroup.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ public final class ComputerGroup: HardwareGroup, Endpoint {
5151
}
5252
}
5353

54+
// MARK: - Creatable
55+
56+
extension ComputerGroup: Creatable {
57+
58+
public func create() -> URLRequest? {
59+
return self.createRequest()
60+
}
61+
}
62+
5463
// MARK: - Protocols
5564

56-
extension ComputerGroup: Creatable, Readable, Updatable, Deletable { }
65+
extension ComputerGroup: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/Department.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public final class Department: BaseObject, Endpoint {
1515
public static let Endpoint: String = "departments"
1616
}
1717

18+
// MARK: - Creatable
19+
20+
extension Department: Creatable {
21+
22+
public func create() -> URLRequest? {
23+
return self.createRequest()
24+
}
25+
}
26+
1827
// MARK: - Protocols
1928

20-
extension Department: Creatable, Readable, Updatable, Deletable { }
29+
extension Department: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/DirectoryBinding.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ public final class DirectoryBinding: BaseObject, Endpoint {
7373
}
7474
}
7575

76+
// MARK: - Creatable
77+
78+
extension DirectoryBinding: Creatable {
79+
80+
public func create() -> URLRequest? {
81+
return self.createRequest()
82+
}
83+
}
84+
7685
// MARK: - Protocols
7786

78-
extension DirectoryBinding: Creatable, Readable, Updatable, Deletable { }
87+
extension DirectoryBinding: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/HardwareGroup/HardwareGroup.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class HardwareGroup: BaseObject {
3636
super.init(json: json)
3737
}
3838

39-
internal override init?(identifier: UInt, name: String) {
39+
override init?(identifier: UInt, name: String) {
4040
super.init(identifier: identifier, name: name)
4141
}
4242

JamfKit/Sources/Models/MobileDeviceGroup/MobileDeviceGroup.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ public final class MobileDeviceGroup: HardwareGroup, Endpoint {
5151
}
5252
}
5353

54+
// MARK: - Creatable
55+
56+
extension MobileDeviceGroup: Creatable {
57+
58+
public func create() -> URLRequest? {
59+
return self.createRequest()
60+
}
61+
}
62+
5463
// MARK: - Protocols
5564

56-
extension MobileDeviceGroup: Creatable, Readable, Updatable, Deletable { }
65+
extension MobileDeviceGroup: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/NetbootServer.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ public final class NetbootServer: BaseObject, Endpoint {
113113
}
114114
}
115115

116+
// MARK: - Creatable
117+
118+
extension NetbootServer: Creatable {
119+
120+
public func create() -> URLRequest? {
121+
return self.createRequest()
122+
}
123+
}
124+
116125
// MARK: - Protocols
117126

118-
extension NetbootServer: Creatable, Readable, Updatable, Deletable { }
127+
extension NetbootServer: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/Printer.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ public final class Printer: BaseObject, Endpoint {
119119
}
120120
}
121121

122+
// MARK: - Creatable
123+
124+
extension Printer: Creatable {
125+
126+
public func create() -> URLRequest? {
127+
return self.createRequest()
128+
}
129+
}
130+
122131
// MARK: - Protocols
123132

124-
extension Printer: Creatable, Readable, Updatable, Deletable { }
133+
extension Printer: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/Script.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ public final class Script: BaseObject, Endpoint {
9999
}
100100
}
101101

102+
// MARK: - Creatable
103+
104+
extension Script: Creatable {
105+
106+
public func create() -> URLRequest? {
107+
return self.createRequest()
108+
}
109+
}
110+
102111
// MARK: - Protocols
103112

104-
extension Script: Creatable, Readable, Updatable, Deletable { }
113+
extension Script: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/Site.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public final class Site: BaseObject, Endpoint {
1515
public static let Endpoint: String = "sites"
1616
}
1717

18+
// MARK: - Creatable
19+
20+
extension Site: Creatable {
21+
22+
public func create() -> URLRequest? {
23+
return self.createRequest()
24+
}
25+
}
26+
1827
// MARK: - Protocols
1928

20-
extension Site: Creatable, Readable, Updatable, Deletable { }
29+
extension Site: Readable, Updatable, Deletable { }

JamfKit/Sources/Models/User.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ public final class User: BaseObject, Endpoint {
110110

111111
// MARK: - Creatable
112112

113-
extension User: Creatable { }
113+
extension User: Creatable {
114+
115+
public func create() -> URLRequest? {
116+
return self.createRequest()
117+
}
118+
}
114119

115120
// MARK: - Protocols
116121

JamfKit/Sources/Protocols/Requests/Creatable.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
/// Represents an object that can be created with an URLRequest
10+
@objc(JMFKCreatable)
1011
public protocol Creatable {
1112

1213
// MARK: - Functions
@@ -21,7 +22,7 @@ public extension Creatable where Self: Endpoint & Identifiable & Requestable {
2122

2223
// MARK: - Functions
2324

24-
func create() -> URLRequest? {
25+
func createRequest() -> URLRequest? {
2526
return SessionManager.instance.createRequest(for: self, key: BaseObject.CodingKeys.identifier.rawValue, value: String(identifier))
2627
}
2728
}

JamfKit/Sources/Session/Requests/SessionManagerRequests.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
77
//
88

9-
internal enum HttpHeader: String {
9+
enum HttpHeader: String {
1010
case accept = "Accept"
1111
case authorization = "Authorization"
1212
case contentType = "Content-Type"
1313
}
1414

15-
internal enum HeaderContentType: String {
15+
enum HeaderContentType: String {
1616
case json = "application/json"
1717
}
1818

@@ -21,7 +21,7 @@ extension SessionManager {
2121
// MARK: - Functions
2222

2323
/// Returns a Base64 encoded username & password pair to be used for Basic HTTP authentication
24-
internal static func computeAuthorizationHeader(from username: String, password: String) -> String {
24+
static func computeAuthorizationHeader(from username: String, password: String) -> String {
2525
guard
2626
!username.isEmpty,
2727
!password.isEmpty,
@@ -34,15 +34,15 @@ extension SessionManager {
3434
}
3535

3636
/// Returns an authentified URLRequst matching the supplied configuration
37-
internal func authentifiedRequest(for url: URL, authorizationHeader: String, method: HttpMethod) -> URLRequest {
37+
func authentifiedRequest(for url: URL, authorizationHeader: String, method: HttpMethod) -> URLRequest {
3838
var request = URLRequest(url: url)
3939
request.httpMethod = method.rawValue
4040
request.setValue(authorizationHeader, forHTTPHeaderField: HttpHeader.authorization.rawValue)
4141

4242
return request
4343
}
4444

45-
internal func baseRequest(endpoint: String, key: String, value: String, method: HttpMethod) -> URLRequest? {
45+
func baseRequest(endpoint: String, key: String, value: String, method: HttpMethod) -> URLRequest? {
4646
guard let url = host?.appendingPathComponent("\(endpoint)/\(key.asCleanedKey())/\(value)") else {
4747
return nil
4848
}
@@ -56,7 +56,7 @@ extension SessionManager {
5656
extension SessionManager {
5757

5858
/// Returns a `CREATE` URLRequest for the supplied URL
59-
internal func createRequest(for object: Endpoint & Requestable, key: String, value: String) -> URLRequest? {
59+
func createRequest(for object: Endpoint & Requestable, key: String, value: String) -> URLRequest? {
6060
guard
6161
var request = baseRequest(endpoint: object.endpoint, key: key, value: value, method: .post),
6262
let data = try? JSONSerialization.data(withJSONObject: object.toJSON(), options: .prettyPrinted) else {
@@ -75,7 +75,7 @@ extension SessionManager {
7575
extension SessionManager {
7676

7777
/// Returns a `READ` URLRequest for the supplied JSS endpoint
78-
internal func readAllRequest(for endpoint: String) -> URLRequest? {
78+
func readAllRequest(for endpoint: String) -> URLRequest? {
7979
guard let url = host?.appendingPathComponent("\(endpoint)") else {
8080
return nil
8181
}
@@ -87,7 +87,7 @@ extension SessionManager {
8787
}
8888

8989
/// Returns a `READ` URLRequest for the supplied endpoint type & identifier
90-
internal func readRequest(for endpoint: Endpoint.Type, key: String, value: String) -> URLRequest? {
90+
func readRequest(for endpoint: Endpoint.Type, key: String, value: String) -> URLRequest? {
9191
guard var request = baseRequest(endpoint: endpoint.Endpoint, key: key, value: value, method: .get) else {
9292
return nil
9393
}
@@ -98,7 +98,7 @@ extension SessionManager {
9898
}
9999

100100
/// Returns a `READ` URLRequest for the supplied JSS object
101-
internal func readRequest(for object: Endpoint) -> URLRequest? {
101+
func readRequest(for object: Endpoint) -> URLRequest? {
102102
guard let url = host?.appendingPathComponent("\(object.endpoint)") else {
103103
return nil
104104
}
@@ -110,7 +110,7 @@ extension SessionManager {
110110
}
111111

112112
/// Returns a `READ` URLRequest for the supplied JSS object
113-
internal func readRequest(for object: Endpoint, key: String, value: String) -> URLRequest? {
113+
func readRequest(for object: Endpoint, key: String, value: String) -> URLRequest? {
114114
guard var request = baseRequest(endpoint: object.endpoint, key: key, value: value, method: .get) else {
115115
return nil
116116
}
@@ -126,7 +126,7 @@ extension SessionManager {
126126
extension SessionManager {
127127

128128
/// Returns an `UPDATE` URLRequest for the supplied JSS object
129-
internal func updateRequest(for object: Endpoint & Requestable) -> URLRequest? {
129+
func updateRequest(for object: Endpoint & Requestable) -> URLRequest? {
130130
guard
131131
let url = host?.appendingPathComponent("\(object.endpoint)"),
132132
let data = try? JSONSerialization.data(withJSONObject: object.toJSON(), options: .prettyPrinted) else {
@@ -141,7 +141,7 @@ extension SessionManager {
141141
}
142142

143143
/// Returns an `UPDATE` URLRequest for the supplied JSS object
144-
internal func updateRequest(for object: Endpoint & Requestable, key: String, value: String) -> URLRequest? {
144+
func updateRequest(for object: Endpoint & Requestable, key: String, value: String) -> URLRequest? {
145145
guard
146146
var request = self.baseRequest(endpoint: object.endpoint, key: key, value: value, method: .put),
147147
let data = try? JSONSerialization.data(withJSONObject: object.toJSON(), options: .prettyPrinted) else {
@@ -160,12 +160,12 @@ extension SessionManager {
160160
extension SessionManager {
161161

162162
/// Returns a `DELETE` URLRequest for the supplied endpoint type & identifier
163-
internal func deleteRequest(for endpoint: Endpoint.Type, key: String, value: String) -> URLRequest? {
163+
func deleteRequest(for endpoint: Endpoint.Type, key: String, value: String) -> URLRequest? {
164164
return baseRequest(endpoint: endpoint.Endpoint, key: key, value: value, method: .delete)
165165
}
166166

167167
/// Returns a `DELETE` URLRequest for the supplied URL
168-
internal func deleteRequest(for object: Endpoint, key: String, value: String) -> URLRequest? {
168+
func deleteRequest(for object: Endpoint, key: String, value: String) -> URLRequest? {
169169
return baseRequest(endpoint: object.endpoint, key: key, value: value, method: .delete)
170170
}
171171
}

JamfKit/Sources/Session/SessionManagerError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class SessionManagerError: NSError {
2929

3030
// MARK: - Initialization
3131

32-
convenience internal init(code: SessionManagerErrorCode) {
32+
convenience init(code: SessionManagerErrorCode) {
3333
self.init(domain: Constants.domain, code: code.rawValue)
3434
}
3535
}

0 commit comments

Comments
 (0)