DocC documentation support (#4)
This PR contains the work done to: * Documented all the `private`, `internal`, and `public` interfaces on the existing codebase; * Set the DocC documentation catalog in the project; * Written the main `Library` article for the DocC documentation catalog; * Added the documentation tasks in the `Makefile` file. Reviewed-on: #4 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #4.
This commit is contained in:
@@ -14,7 +14,13 @@ import Foundation
|
||||
|
||||
extension DateFormatter {
|
||||
|
||||
static var isoDateTime: DateFormatter {
|
||||
// MARK: Properties
|
||||
|
||||
/// An ISO timestamp formatter.
|
||||
///
|
||||
/// This formatter implements the `yyyy-MM-dd'T'HH:mm:ss.SSSSSS` custom date format.
|
||||
/// Within the context of this library, this formatter is solely used to decode a date formatted as a timestamp that is returned by the ``AmiiboService/getLastUpdated()`` function.
|
||||
static var isoTimestamp: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
|
||||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS"
|
||||
|
||||
@@ -12,15 +12,44 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol APIClient {
|
||||
/// A protocol that defines API clients containing all available endpoints to interact with.
|
||||
protocol APIClient {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func getAmiibos(by filter: AmiiboFilter) async throws -> [Amiibo]
|
||||
func getAmiiboSeries(by filter: AmiiboSeriesFilter) async throws -> [AmiiboSeries]
|
||||
func getAmiiboTypes(by filter: AmiiboTypeFilter) async throws -> [AmiiboType]
|
||||
func getGameCharacters(by filter: GameCharacterFilter) async throws -> [GameCharacter]
|
||||
func getGameSeries(by filter: GameSeriesFilter) async throws -> [GameSeries]
|
||||
func getLastUpdated() async throws -> Date
|
||||
/// Gets a list of amiibo items based on a given filter.
|
||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||
/// - Returns: A list of filtered amiibo items.
|
||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||
func getAmiibos(by filter: AmiiboFilter) async throws(AmiiboServiceError) -> [Amiibo]
|
||||
|
||||
/// Gets a list of amiibo series based on a given filter.
|
||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||
/// - Returns: A list of filtered amiibo series.
|
||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||
func getAmiiboSeries(by filter: AmiiboSeriesFilter) async throws(AmiiboServiceError) -> [AmiiboSeries]
|
||||
|
||||
/// Gets a list of amiibo types based on a given filter.
|
||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||
/// - Returns: A list of filtered amiibo types.
|
||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||
func getAmiiboTypes(by filter: AmiiboTypeFilter) async throws(AmiiboServiceError) -> [AmiiboType]
|
||||
|
||||
/// Gets a list of game characters based on a given filter.
|
||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||
/// - Returns: A list of filtered game characters.
|
||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||
func getGameCharacters(by filter: GameCharacterFilter) async throws(AmiiboServiceError) -> [GameCharacter]
|
||||
|
||||
/// Gets a list of game series based on a given filter.
|
||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||
/// - Returns: A list of filtered game series.
|
||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||
func getGameSeries(by filter: GameSeriesFilter) async throws(AmiiboServiceError) -> [GameSeries]
|
||||
|
||||
/// Gets the date when the data was last updated.
|
||||
/// - Returns: A last updated date.
|
||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||
func getLastUpdated() async throws(AmiiboServiceError) -> Date
|
||||
|
||||
}
|
||||
|
||||
@@ -10,17 +10,28 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===
|
||||
|
||||
/// A protocol that defines filters that might contain `key` and/or `name` values.
|
||||
protocol KeyNameFilter {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A key to use for filtering, if any.
|
||||
var key: String? { get }
|
||||
|
||||
/// A name to use for filtering, if any.
|
||||
var name: String? { get }
|
||||
|
||||
// MARK: Initialisers
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this filter without key or name values.
|
||||
init()
|
||||
|
||||
/// Initializes this filter with a key value.
|
||||
/// - Parameter key: A key to use for filtering.
|
||||
init(key: String)
|
||||
|
||||
/// Initializes this filter with a name value.
|
||||
/// - Parameter name: A name to use for filtering.
|
||||
init(name: String)
|
||||
|
||||
}
|
||||
|
||||
@@ -10,15 +10,21 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===
|
||||
|
||||
/// A protocol that defines decodable models containing the `key` and `name` properties.
|
||||
protocol KeyNameModel: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A key.
|
||||
var key: String { get }
|
||||
|
||||
/// A name.
|
||||
var name: String { get }
|
||||
|
||||
// MARK: Initialisers
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.Tuple)
|
||||
|
||||
}
|
||||
|
||||
+12
-3
@@ -13,10 +13,19 @@
|
||||
import Foundation
|
||||
import OpenAPIRuntime
|
||||
|
||||
struct ISODateTranscoder: DateTranscoder {
|
||||
|
||||
/// A type that allows the decoding and encoding of ISO timestamp dates, defined by the `yyyy-MM-dd'T'HH:mm:ss.SSSSSS` custom date format.
|
||||
struct ISOTimestampTranscoder {
|
||||
|
||||
// MARK: Properties
|
||||
private let dateFormatter: DateFormatter = .isoDateTime
|
||||
|
||||
/// A formatter to use to decode and encode ISO timestamps dates.
|
||||
private let dateFormatter: DateFormatter = .isoTimestamp
|
||||
|
||||
}
|
||||
|
||||
// MARK: - DateTranscoder
|
||||
|
||||
extension ISOTimestampTranscoder: DateTranscoder {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
Reference in New Issue
Block a user