Added the "port" property to the Endpoint protocol.
This commit is contained in:
parent
acce70b6bc
commit
47a8db48ff
13
Libraries/Sources/APIService/Extensions/Int+Ports.swift
Normal file
13
Libraries/Sources/APIService/Extensions/Int+Ports.swift
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// Int+Ports.swift
|
||||
// APIService
|
||||
//
|
||||
// Created by Javier Cicchelli on 04/12/2022.
|
||||
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
extension Int {
|
||||
enum Ports {
|
||||
static let `default` = 8080
|
||||
}
|
||||
}
|
@ -8,6 +8,6 @@
|
||||
|
||||
extension String {
|
||||
enum Hosts {
|
||||
static let `default` = "163.172.147.216:8080"
|
||||
static let `default` = "163.172.147.216"
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import Foundation
|
||||
protocol Endpoint {
|
||||
var scheme: String { get }
|
||||
var host: String { get }
|
||||
var port: Int { get }
|
||||
var path: String { get }
|
||||
var method: RequestMethod { get }
|
||||
var credentials: BasicCredentials { get }
|
||||
@ -23,6 +24,7 @@ protocol Endpoint {
|
||||
extension Endpoint {
|
||||
var scheme: String { .Schemes.http }
|
||||
var host: String { .Hosts.default }
|
||||
var port: Int { .Ports.default }
|
||||
var authorizationHeader: [String: String] {
|
||||
let makeAuthHeader = MakeAuthorizationHeaderUseCase()
|
||||
|
||||
|
@ -41,6 +41,7 @@ final class CreateFolderEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)")
|
||||
XCTAssertEqual(endpoint.method, .post)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
@ -67,6 +68,7 @@ final class CreateFolderEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)")
|
||||
XCTAssertEqual(endpoint.method, .post)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
|
@ -38,6 +38,7 @@ final class DeleteItemEndpoint_InitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)")
|
||||
XCTAssertEqual(endpoint.method, .delete)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
@ -62,6 +63,7 @@ final class DeleteItemEndpoint_InitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)")
|
||||
XCTAssertEqual(endpoint.method, .delete)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
|
@ -38,6 +38,7 @@ final class GetDataEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)/data")
|
||||
XCTAssertEqual(endpoint.method, .get)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
@ -62,6 +63,7 @@ final class GetDataEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)/data")
|
||||
XCTAssertEqual(endpoint.method, .get)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
|
@ -38,6 +38,7 @@ final class GetItemsEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/" + itemId)
|
||||
XCTAssertEqual(endpoint.method, .get)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
@ -62,6 +63,7 @@ final class GetItemsEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/" + itemId)
|
||||
XCTAssertEqual(endpoint.method, .get)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
|
@ -31,6 +31,7 @@ final class GetMeEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/me")
|
||||
XCTAssertEqual(endpoint.method, .get)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
@ -51,6 +52,7 @@ final class GetMeEndpointInitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/me")
|
||||
XCTAssertEqual(endpoint.method, .get)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
|
@ -44,6 +44,7 @@ final class UploadFileEndpoint_InitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)")
|
||||
XCTAssertEqual(endpoint.method, .post)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
@ -75,6 +76,7 @@ final class UploadFileEndpoint_InitTests: XCTestCase {
|
||||
// THEN
|
||||
XCTAssertEqual(endpoint.scheme, .Schemes.http)
|
||||
XCTAssertEqual(endpoint.host, .Hosts.default)
|
||||
XCTAssertEqual(endpoint.port, .Ports.default)
|
||||
XCTAssertEqual(endpoint.path, "/items/\(itemId)")
|
||||
XCTAssertEqual(endpoint.method, .post)
|
||||
XCTAssertEqual(endpoint.credentials.username, username)
|
||||
|
Loading…
x
Reference in New Issue
Block a user