Skip to content

Commit 55ab4bd

Browse files
committed
Removes unnecessary E: Encodable generic type
1 parent 5edcd93 commit 55ab4bd

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

Sources/Networking/Calls/NetworkingClient+Data.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public extension NetworkingClient {
1818
request(.post, route, params: params).publisher()
1919
}
2020

21-
func post<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Data, Error> {
21+
func post(_ route: String, body: Encodable) -> AnyPublisher<Data, Error> {
2222
request(.post, route, encodableBody: body).publisher()
2323
}
2424

@@ -30,7 +30,7 @@ public extension NetworkingClient {
3030
request(.patch, route, params: params).publisher()
3131
}
3232

33-
func patch<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Data, Error> {
33+
func patch(_ route: String, body: Encodable) -> AnyPublisher<Data, Error> {
3434
request(.patch, route, encodableBody: body).publisher()
3535
}
3636

@@ -49,7 +49,7 @@ public extension NetworkingClient {
4949
try await request(.post, route, params: params).execute()
5050
}
5151

52-
func post<E: Encodable>(_ route: String, body: E) async throws -> Data {
52+
func post(_ route: String, body: Encodable) async throws -> Data {
5353
try await request(.post, route, encodableBody: body).execute()
5454
}
5555

Sources/Networking/Calls/NetworkingClient+Decodable.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public extension NetworkingClient {
3939
.eraseToAnyPublisher()
4040
}
4141

42-
func post<E: Encodable, T: Decodable>(_ route: String,
43-
body: E,
42+
func post<T: Decodable>(_ route: String,
43+
body: Encodable,
4444
keypath: String? = nil
4545
) -> AnyPublisher<T, Error> {
4646
return post(route, body: body)
@@ -90,8 +90,8 @@ public extension NetworkingClient {
9090
}
9191

9292

93-
func patch<E: Encodable, T: Decodable>(_ route: String,
94-
body: E,
93+
func patch<T: Decodable>(_ route: String,
94+
body: Encodable,
9595
keypath: String? = nil
9696
) -> AnyPublisher<T, Error> {
9797
return patch(route, body: body)
@@ -158,8 +158,8 @@ public extension NetworkingClient {
158158
return try self.toModel(json, keypath: keypath)
159159
}
160160

161-
func post<E: Encodable, T: Decodable>(_ route: String,
162-
body: E,
161+
func post<T: Decodable>(_ route: String,
162+
body: Encodable,
163163
keypath: String? = nil
164164
) async throws -> T {
165165
let json: Any = try await post(route, body: body)
@@ -204,8 +204,8 @@ public extension NetworkingClient {
204204
return try self.toModel(json, keypath: keypath)
205205
}
206206

207-
func patch<E: Encodable, T: Decodable>(_ route: String,
208-
body: E,
207+
func patch<T: Decodable>(_ route: String,
208+
body: Encodable,
209209
keypath: String? = nil
210210
) async throws -> T {
211211
let json: Any = try await patch(route, body: body)

Sources/Networking/Calls/NetworkingClient+JSON.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public extension NetworkingClient {
1818
post(route, params: params).toJSON()
1919
}
2020

21-
func post<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Any, Error> {
21+
func post(_ route: String, body: Encodable) -> AnyPublisher<Any, Error> {
2222
post(route, body: body).toJSON()
2323
}
2424

@@ -30,7 +30,7 @@ public extension NetworkingClient {
3030
patch(route, params: params).toJSON()
3131
}
3232

33-
func patch<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Any, Error> {
33+
func patch(_ route: String, body: Encodable) -> AnyPublisher<Any, Error> {
3434
patch(route, body: body).toJSON()
3535
}
3636

@@ -53,7 +53,7 @@ public extension NetworkingClient {
5353
return try JSONSerialization.jsonObject(with: data, options: [])
5454
}
5555

56-
func post<E: Encodable>(_ route: String, body: E) async throws -> Any {
56+
func post(_ route: String, body: Encodable) async throws -> Any {
5757
let req = request(.post, route, encodableBody: body)
5858
let data = try await req.execute()
5959
return try JSONSerialization.jsonObject(with: data, options: [])
@@ -71,7 +71,7 @@ public extension NetworkingClient {
7171
return try JSONSerialization.jsonObject(with: data, options: [])
7272
}
7373

74-
func patch<E: Encodable>(_ route: String, body: E) async throws -> Any {
74+
func patch(_ route: String, body: Encodable) async throws -> Any {
7575
let req = request(.patch, route, encodableBody: body)
7676
let data = try await req.execute()
7777
return try JSONSerialization.jsonObject(with: data, options: [])

Sources/Networking/Calls/NetworkingClient+Requests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ public extension NetworkingClient {
5959
return req
6060
}
6161

62-
internal func request<E: Encodable>(_ httpMethod: HTTPMethod,
62+
internal func request(_ httpMethod: HTTPMethod,
6363
_ route: String,
6464
params: Params = Params(),
65-
encodableBody: E? = nil
65+
encodableBody: Encodable? = nil
6666
) -> NetworkingRequest {
6767
let req = NetworkingRequest()
6868
req.httpMethod = httpMethod

Sources/Networking/Calls/NetworkingClient+Void.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public extension NetworkingClient {
2222
.eraseToAnyPublisher()
2323
}
2424

25-
func post<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Void, Error> {
25+
func post(_ route: String, body: Encodable) -> AnyPublisher<Void, Error> {
2626
post(route, body: body)
2727
.map { (data: Data) -> Void in () }
2828
.eraseToAnyPublisher()
@@ -40,7 +40,7 @@ public extension NetworkingClient {
4040
.eraseToAnyPublisher()
4141
}
4242

43-
func patch<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Void, Error> {
43+
func patch(_ route: String, body: Encodable) -> AnyPublisher<Void, Error> {
4444
patch(route, body: body)
4545
.map { (data: Data) -> Void in () }
4646
.eraseToAnyPublisher()
@@ -65,7 +65,7 @@ public extension NetworkingClient {
6565
_ = try await req.execute()
6666
}
6767

68-
func post<E: Encodable>(_ route: String, body: E) async throws {
68+
func post(_ route: String, body: Encodable) async throws {
6969
let req = request(.post, route, encodableBody: body)
7070
_ = try await req.execute()
7171
}

Sources/Networking/NetworkingService.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public extension NetworkingService {
2626
network.post(route, params: params)
2727
}
2828

29-
func post<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Data, Error> {
29+
func post(_ route: String, body: Encodable) -> AnyPublisher<Data, Error> {
3030
network.post(route, body: body)
3131
}
3232

@@ -38,7 +38,7 @@ public extension NetworkingService {
3838
network.patch(route, params: params)
3939
}
4040

41-
func patch<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Data, Error> {
41+
func patch(_ route: String, body: Encodable) -> AnyPublisher<Data, Error> {
4242
network.patch(route, body: body)
4343
}
4444

@@ -56,7 +56,7 @@ public extension NetworkingService {
5656
network.post(route, params: params)
5757
}
5858

59-
func post<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Void, Error> {
59+
func post(_ route: String, body: Encodable) -> AnyPublisher<Void, Error> {
6060
network.post(route, body: body)
6161
}
6262

@@ -82,7 +82,7 @@ public extension NetworkingService {
8282
network.post(route, params: params)
8383
}
8484

85-
func post<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Any, Error> {
85+
func post(_ route: String, body: Encodable) -> AnyPublisher<Any, Error> {
8686
network.post(route, body: body)
8787
}
8888

@@ -242,7 +242,7 @@ public extension NetworkingService {
242242
try await network.post(route, params: params)
243243
}
244244

245-
func post<E: Encodable>(_ route: String, body: E) async throws -> Data {
245+
func post(_ route: String, body: Encodable) async throws -> Data {
246246
try await network.post(route, body: body)
247247
}
248248

@@ -268,7 +268,7 @@ public extension NetworkingService {
268268
return try await network.post(route, params: params)
269269
}
270270

271-
func post<E: Encodable>(_ route: String, body: E) async throws {
271+
func post(_ route: String, body: Encodable) async throws {
272272
return try await network.post(route, body: body)
273273
}
274274

@@ -294,7 +294,7 @@ public extension NetworkingService {
294294
try await network.post(route, params: params)
295295
}
296296

297-
func post<E: Encodable>(_ route: String, body: E) async throws -> Any {
297+
func post(_ route: String, body: Encodable) async throws -> Any {
298298
try await network.post(route, body: body)
299299
}
300300

@@ -324,7 +324,7 @@ public extension NetworkingService {
324324
try await network.post(route, params: params, keypath: keypath)
325325
}
326326

327-
func post<E: Encodable, T: Decodable>(_ route: String, body: E) async throws -> T {
327+
func post<T: Decodable>(_ route: String, body: Encodable) async throws -> T {
328328
try await network.post(route, body: body)
329329
}
330330

@@ -340,7 +340,7 @@ public extension NetworkingService {
340340
try await network.patch(route, params: params, keypath: keypath)
341341
}
342342

343-
func patch<E: Encodable, T: Decodable>(_ route: String, body: E) async throws -> T {
343+
func patch<T: Decodable>(_ route: String, body: Encodable) async throws -> T {
344344
try await network.patch(route, body: body)
345345
}
346346

0 commit comments

Comments
 (0)