Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] allow to override default json decoder on APIManager #71

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/Networking/Core/APIManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ import Foundation
```
*/
open class APIManager: APIManaging, Retryable {
// MARK: Public variables
/// Default JSONDecoder implementation
public var defaultDecoder: JSONDecoder {
JSONDecoder()
}

// MARK: Private variables
private let requestAdapters: [RequestAdapting]
private let responseProcessors: [ResponseProcessing]
private let errorProcessors: [ErrorProcessing]
private let responseProvider: ResponseProviding
private let sessionId: String

internal var retryCounter = Counter()

public init(
Expand Down
13 changes: 0 additions & 13 deletions Sources/Networking/Core/APIManaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public protocol APIManaging {
// MARK: - Provide request with default json decoder, retry configuration

public extension APIManaging {
/// Default JSONDecoder implementation.
var defaultDecoder: JSONDecoder {
JSONDecoder.default
}

/// Simplifies request using a default ``RetryConfiguration``.
/// - Parameter endpoint: API endpoint requestable definition.
/// - Returns: ``Response``.
Expand Down Expand Up @@ -88,11 +83,3 @@ public extension APIManaging {
return try decoder.decode(DecodableResponse.self, from: response.data)
}
}


// MARK: - JSONDecoder static extension

private extension JSONDecoder {
/// A static `JSONDecoder` instance used by default implementation of `APIManaging`
static let `default` = JSONDecoder()
}
Loading