[Feature] All endpoints #2

Merged
javier merged 11 commits from feature/endpoints into main 2023-04-18 20:03:13 +00:00
12 changed files with 128 additions and 19 deletions

View File

@ -4,6 +4,12 @@ import PackageDescription
let package = Package( let package = Package(
name: "AmiiboService", name: "AmiiboService",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13),
.watchOS(.v8)
],
products: [ products: [
.library( .library(
name: "AmiiboService", name: "AmiiboService",
@ -12,11 +18,15 @@ let package = Package(
] ]
), ),
], ],
dependencies: [], dependencies: [
.package(url: "https://github.com/rock-n-code/swift-libs.git", from: "0.1.0")
],
targets: [ targets: [
.target( .target(
name: "AmiiboService", name: "AmiiboService",
dependencies: [], dependencies: [
.product(name: "SwiftLibs", package: "swift-libs")
],
path: "Sources" path: "Sources"
), ),
.testTarget( .testTarget(

View File

@ -1,6 +0,0 @@
public struct AmiiboService {
public private(set) var text = "Hello, World!"
public init() {
}
}

View File

@ -0,0 +1,16 @@
import Communications
import Foundation
struct GetAmiiboEndpoint: Endpoint {
// MARK: Properties
let scheme: String = .Scheme.https
let host: String = .Host.amiiboApi
let port: Int?
let path: String = .Path.type
let method: HTTPRequestMethod = .get
let headers: [String : String] = [:]
let body: Data?
}

View File

@ -0,0 +1,16 @@
import Communications
import Foundation
struct GetCharacterEndpoint: Endpoint {
// MARK: Properties
let scheme: String = .Scheme.https
let host: String = .Host.amiiboApi
let port: Int?
let path: String = .Path.character
let method: HTTPRequestMethod = .get
let headers: [String : String] = [:]
let body: Data?
}

View File

@ -0,0 +1,16 @@
import Communications
import Foundation
struct GetGameSeriesEndpoint: Endpoint {
// MARK: Properties
let scheme: String = .Scheme.https
let host: String = .Host.amiiboApi
let port: Int?
let path: String = .Path.gameSeries
let method: HTTPRequestMethod = .get
let headers: [String : String] = [:]
let body: Data?
}

View File

@ -0,0 +1,16 @@
import Communications
import Foundation
struct GetLastUpdatedEndpoint: Endpoint {
// MARK: Properties
let scheme: String = .Scheme.https
let host: String = .Host.amiiboApi
let port: Int?
let path: String = .Path.lastUpdated
let method: HTTPRequestMethod = .get
let headers: [String : String] = [:]
let body: Data?
}

View File

@ -0,0 +1,16 @@
import Communications
import Foundation
struct GetSeriesEndpoint: Endpoint {
// MARK: Properties
let scheme: String = .Scheme.https
let host: String = .Host.amiiboApi
let port: Int?
let path: String = .Path.series
let method: HTTPRequestMethod = .get
let headers: [String : String] = [:]
let body: Data?
}

View File

@ -0,0 +1,16 @@
import Communications
import Foundation
struct GetTypeEndpoint: Endpoint {
// MARK: Properties
let scheme: String = .Scheme.https
let host: String = .Host.amiiboApi
let port: Int?
let path: String = .Path.type
let method: HTTPRequestMethod = .get
let headers: [String : String] = [:]
let body: Data?
}

View File

@ -0,0 +1,5 @@
extension String {
enum Host {
static let amiiboApi = "www.amiiboapi.com"
}
}

View File

@ -0,0 +1,10 @@
extension String {
enum Path {
static let amiibo = "/api/amiibo/"
static let type = "/api/type"
static let gameSeries = "/api/gameseries"
static let series = "/api/amiiboseries"
static let character = "/api/character"
static let lastUpdated = "/api/lastupdated"
}
}

View File

@ -0,0 +1,5 @@
extension String {
enum Scheme {
static let https = "https"
}
}

View File

@ -1,11 +0,0 @@
import XCTest
@testable import AmiiboService
final class AmiiboServiceTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
XCTAssertEqual(AmiiboService().text, "Hello, World!")
}
}