diff --git a/Libraries/Sources/APIService/Extensions/Int+Ports.swift b/Libraries/Sources/APIService/Extensions/Int+Ports.swift new file mode 100644 index 0000000..73ad179 --- /dev/null +++ b/Libraries/Sources/APIService/Extensions/Int+Ports.swift @@ -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 + } +} diff --git a/Libraries/Sources/APIService/Extensions/String+Hosts.swift b/Libraries/Sources/APIService/Extensions/String+Hosts.swift index 5daa9c4..b6c6f48 100644 --- a/Libraries/Sources/APIService/Extensions/String+Hosts.swift +++ b/Libraries/Sources/APIService/Extensions/String+Hosts.swift @@ -8,6 +8,6 @@ extension String { enum Hosts { - static let `default` = "163.172.147.216:8080" + static let `default` = "163.172.147.216" } } diff --git a/Libraries/Sources/APIService/Protocols/Endpoint.swift b/Libraries/Sources/APIService/Protocols/Endpoint.swift index bac6dfa..71cd132 100644 --- a/Libraries/Sources/APIService/Protocols/Endpoint.swift +++ b/Libraries/Sources/APIService/Protocols/Endpoint.swift @@ -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() diff --git a/Libraries/Tests/APIServiceTests/Cases/Endpoints/CreateFolderEndpoint+InitTests.swift b/Libraries/Tests/APIServiceTests/Cases/Endpoints/CreateFolderEndpoint+InitTests.swift index 212a0b3..e1a0c99 100644 --- a/Libraries/Tests/APIServiceTests/Cases/Endpoints/CreateFolderEndpoint+InitTests.swift +++ b/Libraries/Tests/APIServiceTests/Cases/Endpoints/CreateFolderEndpoint+InitTests.swift @@ -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) diff --git a/Libraries/Tests/APIServiceTests/Cases/Endpoints/DeleteItemEndpoint+InitTests.swift b/Libraries/Tests/APIServiceTests/Cases/Endpoints/DeleteItemEndpoint+InitTests.swift index c5be642..abd63f7 100644 --- a/Libraries/Tests/APIServiceTests/Cases/Endpoints/DeleteItemEndpoint+InitTests.swift +++ b/Libraries/Tests/APIServiceTests/Cases/Endpoints/DeleteItemEndpoint+InitTests.swift @@ -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) diff --git a/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetDataEndpoint+InitTests.swift b/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetDataEndpoint+InitTests.swift index f158e3d..158dbe5 100644 --- a/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetDataEndpoint+InitTests.swift +++ b/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetDataEndpoint+InitTests.swift @@ -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) diff --git a/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetItemsEndpoint+InitTests.swift b/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetItemsEndpoint+InitTests.swift index ebf18bf..956d23c 100644 --- a/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetItemsEndpoint+InitTests.swift +++ b/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetItemsEndpoint+InitTests.swift @@ -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) diff --git a/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetMeEndpoint+InitTests.swift b/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetMeEndpoint+InitTests.swift index 151e552..235ed6c 100644 --- a/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetMeEndpoint+InitTests.swift +++ b/Libraries/Tests/APIServiceTests/Cases/Endpoints/GetMeEndpoint+InitTests.swift @@ -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) diff --git a/Libraries/Tests/APIServiceTests/Cases/Endpoints/UploadFileEndpoint+InitTests.swift b/Libraries/Tests/APIServiceTests/Cases/Endpoints/UploadFileEndpoint+InitTests.swift index d91c854..6a7edc8 100644 --- a/Libraries/Tests/APIServiceTests/Cases/Endpoints/UploadFileEndpoint+InitTests.swift +++ b/Libraries/Tests/APIServiceTests/Cases/Endpoints/UploadFileEndpoint+InitTests.swift @@ -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)