Implemented the GetLocationsEndpoint endpoint.

This commit is contained in:
Javier Cicchelli 2023-04-10 13:43:26 +02:00
parent e1e5a9a36d
commit 128d11a3cf
5 changed files with 77 additions and 17 deletions

View File

@ -0,0 +1,20 @@
//
// GetLocationsEndpoint.swift
// Locations
//
// Created by Javier Cicchelli on 10/04/2023.
// Copyright © 2023 Röck+Cöde. All rights reserved.
//
import APICore
import Foundation
struct GetLocationsEndpoint: Endpoint {
let scheme: String = .Scheme.https
let host: String = .Hosts.default
let port: Int? = nil
let path: String = .Paths.getLocations
let method: HTTPRequestMethod = .get
let headers: [String: String] = [:]
let body: Data? = nil
}

View File

@ -0,0 +1,21 @@
//
// String+Constants.swift
// Locations
//
// Created by Javier Cicchelli on 10/04/2023.
// Copyright © 2023 Röck+Cöde. All rights reserved.
//
extension String {
enum Scheme {
static let https = "https"
}
enum Hosts {
static let `default` = "raw.githubusercontent.com"
}
enum Paths {
static let getLocations = "/abnamrocoesd/assignment-ios/main/locations.json"
}
}

View File

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

View File

@ -0,0 +1,36 @@
//
// GetLocationsEndpointTests.swift
// LocationsTests
//
// Created by Javier Cicchelli on 10/04/2023.
// Copyright © 2023 Röck+Cöde. All rights reserved.
//
import XCTest
@testable import Locations
final class GetLocationsEndpointTests: XCTestCase {
// MARK: Properties
private var endpoint: GetLocationsEndpoint!
// MARK: Tests
func test_init() {
// GIVEN
// WHEN
endpoint = GetLocationsEndpoint()
// THEN
XCTAssertNotNil(endpoint)
XCTAssertEqual(endpoint.scheme, .Scheme.https)
XCTAssertEqual(endpoint.host, .Hosts.default)
XCTAssertNil(endpoint.port)
XCTAssertEqual(endpoint.path, .Paths.getLocations)
XCTAssertTrue(endpoint.headers.isEmpty)
XCTAssertNil(endpoint.body)
}
}

View File

@ -1,11 +0,0 @@
import XCTest
@testable import Libraries
final class LibrariesTests: 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(Libraries().text, "Hello, World!")
}
}