This PR contains the work done to addres the issue #8, related to setting up a EUPL 1.2 license for this project. To provide further details about the work done: - [x] defined the LICENSE text; - [x] defined the CONTRIBUTORS text; - [x] added a header file to source code available in this project. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: #12
81 lines
2.5 KiB
Swift
81 lines
2.5 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the AmiiboService open source project
|
|
//
|
|
// Copyright (c) 2023 Röck+Cöde VoF. and the AmiiboService project authors
|
|
// Licensed under the EUPL 1.2 or later.
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of AmiiboService project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// This filter provides all the possible parameters (and combinations) available at the remote API applies when filtering amiibos series (``AmiiboSeriesFilter``), amiibo types (``AmiiboTypeFilter``), characters (``CharacterFilter``), or game series (``GameSeriesFilter``).
|
|
public struct KeyNameFilter {
|
|
|
|
// MARK: Properties
|
|
|
|
private let key: String?
|
|
private let name: String?
|
|
|
|
// MARK: Initialisers
|
|
|
|
/// Initialises this filter.
|
|
/// - Parameters:
|
|
/// - key: A `key` value to match against.
|
|
/// - name: A `name` value to match against.
|
|
public init(
|
|
key: String? = nil,
|
|
name: String? = nil
|
|
) {
|
|
self.key = key
|
|
self.name = name
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Type aliases
|
|
|
|
/// This filter provides all the possible parameters (and combinations) available at the remote API applies when filtering amiibos series.
|
|
public typealias AmiiboSeriesFilter = KeyNameFilter
|
|
|
|
/// This filter provides all the possible parameters (and combinations) available at the remote API applies when filtering amiibo types.
|
|
public typealias AmiiboTypeFilter = KeyNameFilter
|
|
|
|
/// This filter provides all the possible parameters (and combinations) available at the remote API applies when filtering characters.
|
|
public typealias CharacterFilter = KeyNameFilter
|
|
|
|
/// This filter provides all the possible parameters (and combinations) available at the remote API applies when filtering game series.
|
|
public typealias GameSeriesFilter = KeyNameFilter
|
|
|
|
// MARK: - Filter
|
|
|
|
extension KeyNameFilter: Filter {
|
|
|
|
// MARK: Functions
|
|
|
|
func makeParameters() -> [String : String?] {
|
|
var parameters: [String : String?] = [:]
|
|
|
|
if let key {
|
|
parameters[.Key.key] = key
|
|
}
|
|
|
|
if let name {
|
|
parameters[.Key.name] = name
|
|
}
|
|
|
|
return parameters
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - String+Key
|
|
|
|
private extension String {
|
|
enum Key {
|
|
static let key = "key"
|
|
static let name = "name"
|
|
}
|
|
}
|