[Feature] All endpoints (#2)
This PR contains the work done in implementing the endpoints needed for the remote calls: `GetAmiiboEndpoint`, `GetTypeEndpoint`, `GetGameSeriesEndpoint`, `GetSeriesEndpoint`, `GetSeriesEndpoint` and `GetLastUpdatedEndpoint` endpoints definitions. Furthermore, I added the the **SwiftLibs** package as a dependency and also, I defined constants for `String+Scheme`, `String+Host` and the `String+Path` extensions. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: #2
This commit is contained in:
parent
29f766ebdb
commit
e12fce9ddc
@ -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(
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
public struct AmiiboService {
|
|
||||||
public private(set) var text = "Hello, World!"
|
|
||||||
|
|
||||||
public init() {
|
|
||||||
}
|
|
||||||
}
|
|
16
Sources/Endpoints/GetAmiiboEndpoint.swift
Normal file
16
Sources/Endpoints/GetAmiiboEndpoint.swift
Normal 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?
|
||||||
|
|
||||||
|
}
|
16
Sources/Endpoints/GetCharacterEndpoint.swift
Normal file
16
Sources/Endpoints/GetCharacterEndpoint.swift
Normal 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?
|
||||||
|
|
||||||
|
}
|
16
Sources/Endpoints/GetGameSeriesEndpoint.swift
Normal file
16
Sources/Endpoints/GetGameSeriesEndpoint.swift
Normal 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?
|
||||||
|
|
||||||
|
}
|
16
Sources/Endpoints/GetLastUpdatedEndpoint.swift
Normal file
16
Sources/Endpoints/GetLastUpdatedEndpoint.swift
Normal 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?
|
||||||
|
|
||||||
|
}
|
16
Sources/Endpoints/GetSeriesEndpoint.swift
Normal file
16
Sources/Endpoints/GetSeriesEndpoint.swift
Normal 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?
|
||||||
|
|
||||||
|
}
|
16
Sources/Endpoints/GetTypeEndpoint.swift
Normal file
16
Sources/Endpoints/GetTypeEndpoint.swift
Normal 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?
|
||||||
|
|
||||||
|
}
|
5
Sources/Extensions/String+Host.swift
Normal file
5
Sources/Extensions/String+Host.swift
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
extension String {
|
||||||
|
enum Host {
|
||||||
|
static let amiiboApi = "www.amiiboapi.com"
|
||||||
|
}
|
||||||
|
}
|
10
Sources/Extensions/String+Path.swift
Normal file
10
Sources/Extensions/String+Path.swift
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
5
Sources/Extensions/String+Scheme.swift
Normal file
5
Sources/Extensions/String+Scheme.swift
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
extension String {
|
||||||
|
enum Scheme {
|
||||||
|
static let https = "https"
|
||||||
|
}
|
||||||
|
}
|
@ -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!")
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user