Skip to content

Commit

Permalink
Removes unnecessary E: Encodable generic type
Browse files Browse the repository at this point in the history
  • Loading branch information
s4cha committed Nov 14, 2023
1 parent 5edcd93 commit 55ab4bd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Sources/Networking/Calls/NetworkingClient+Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public extension NetworkingClient {
request(.post, route, params: params).publisher()
}

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

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

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

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

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

Expand Down
16 changes: 8 additions & 8 deletions Sources/Networking/Calls/NetworkingClient+Decodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public extension NetworkingClient {
.eraseToAnyPublisher()
}

func post<E: Encodable, T: Decodable>(_ route: String,
body: E,
func post<T: Decodable>(_ route: String,
body: Encodable,
keypath: String? = nil
) -> AnyPublisher<T, Error> {
return post(route, body: body)
Expand Down Expand Up @@ -90,8 +90,8 @@ public extension NetworkingClient {
}


func patch<E: Encodable, T: Decodable>(_ route: String,
body: E,
func patch<T: Decodable>(_ route: String,
body: Encodable,
keypath: String? = nil
) -> AnyPublisher<T, Error> {
return patch(route, body: body)
Expand Down Expand Up @@ -158,8 +158,8 @@ public extension NetworkingClient {
return try self.toModel(json, keypath: keypath)
}

func post<E: Encodable, T: Decodable>(_ route: String,
body: E,
func post<T: Decodable>(_ route: String,
body: Encodable,
keypath: String? = nil
) async throws -> T {
let json: Any = try await post(route, body: body)
Expand Down Expand Up @@ -204,8 +204,8 @@ public extension NetworkingClient {
return try self.toModel(json, keypath: keypath)
}

func patch<E: Encodable, T: Decodable>(_ route: String,
body: E,
func patch<T: Decodable>(_ route: String,
body: Encodable,
keypath: String? = nil
) async throws -> T {
let json: Any = try await patch(route, body: body)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Networking/Calls/NetworkingClient+JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public extension NetworkingClient {
post(route, params: params).toJSON()
}

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

Expand All @@ -30,7 +30,7 @@ public extension NetworkingClient {
patch(route, params: params).toJSON()
}

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

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

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

func patch<E: Encodable>(_ route: String, body: E) async throws -> Any {
func patch(_ route: String, body: Encodable) async throws -> Any {
let req = request(.patch, route, encodableBody: body)
let data = try await req.execute()
return try JSONSerialization.jsonObject(with: data, options: [])
Expand Down
4 changes: 2 additions & 2 deletions Sources/Networking/Calls/NetworkingClient+Requests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public extension NetworkingClient {
return req
}

internal func request<E: Encodable>(_ httpMethod: HTTPMethod,
internal func request(_ httpMethod: HTTPMethod,
_ route: String,
params: Params = Params(),
encodableBody: E? = nil
encodableBody: Encodable? = nil
) -> NetworkingRequest {
let req = NetworkingRequest()
req.httpMethod = httpMethod
Expand Down
6 changes: 3 additions & 3 deletions Sources/Networking/Calls/NetworkingClient+Void.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public extension NetworkingClient {
.eraseToAnyPublisher()
}

func post<E: Encodable>(_ route: String, body: E) -> AnyPublisher<Void, Error> {
func post(_ route: String, body: Encodable) -> AnyPublisher<Void, Error> {
post(route, body: body)
.map { (data: Data) -> Void in () }
.eraseToAnyPublisher()
Expand All @@ -40,7 +40,7 @@ public extension NetworkingClient {
.eraseToAnyPublisher()
}

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

func post<E: Encodable>(_ route: String, body: E) async throws {
func post(_ route: String, body: Encodable) async throws {
let req = request(.post, route, encodableBody: body)
_ = try await req.execute()
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/Networking/NetworkingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public extension NetworkingService {
network.post(route, params: params)
}

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

Expand All @@ -38,7 +38,7 @@ public extension NetworkingService {
network.patch(route, params: params)
}

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

Expand All @@ -56,7 +56,7 @@ public extension NetworkingService {
network.post(route, params: params)
}

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

Expand All @@ -82,7 +82,7 @@ public extension NetworkingService {
network.post(route, params: params)
}

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

Expand Down Expand Up @@ -242,7 +242,7 @@ public extension NetworkingService {
try await network.post(route, params: params)
}

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

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

func post<E: Encodable>(_ route: String, body: E) async throws {
func post(_ route: String, body: Encodable) async throws {
return try await network.post(route, body: body)
}

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

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

Expand Down Expand Up @@ -324,7 +324,7 @@ public extension NetworkingService {
try await network.post(route, params: params, keypath: keypath)
}

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

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

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

Expand Down

0 comments on commit 55ab4bd

Please sign in to comment.