Defined the Service protocol in the Feed library.

This commit is contained in:
Javier Cicchelli 2024-03-17 16:10:13 +01:00
parent f97025fdb8
commit 7beb36068b
3 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,21 @@
//
// Service.swift
// ReviewsFeedKit
//
// Created by Javier Cicchelli on 17/03/2024.
// Copyright © 2024 Röck+Cöde VoF. All rights reserved.
//
import Foundation
public protocol Service {
// MARK: Properties
var configuration: ServiceConfiguration { get }
var decoder: JSONDecoder { get }
var session: URLSession { get }
// MARK: Functions
func getReviews(_ input: GetReviewsInput) async throws -> GetReviewsOutput
}

View File

@ -0,0 +1,29 @@
//
// ServiceConfiguration.swift
// ReviewsiTunesKit
//
// Created by Javier Cicchelli on 17/03/2024.
// Copyright © 2024 Röck+Cöde VoF. All rights reserved.
//
import Foundation
public struct ServiceConfiguration {
// MARK: Constants
public let decoder: JSONDecoder
public let host: URL
public let session: URLSessionConfiguration
// MARK: Initialisers
public init(
host: URL,
session: URLSessionConfiguration = .ephemeral,
decoder: JSONDecoder? = nil
) {
self.decoder = decoder ?? .init()
self.host = host
self.session = session
}
}

View File

@ -1,6 +1,6 @@
//
// String+Constants.swift
// ReviewsFoundation
// ReviewsFoundationKit
//
// Created by Javier Cicchelli on 16/03/2024.
// Copyright © 2024 Röck+Cöde VoF. All rights reserved.