From 7beb36068b32a34c90444bc636b9b5b2a73d63e1 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 17 Mar 2024 16:10:13 +0100 Subject: [PATCH] Defined the Service protocol in the Feed library. --- .../Feed/Kit/Sources/Protocols/Service.swift | 21 ++++++++++++++ .../Structs/ServiceConfiguration.swift | 29 +++++++++++++++++++ .../Sources/Extensions/String+Constants.swift | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Libraries/Feed/Kit/Sources/Protocols/Service.swift create mode 100644 Libraries/Feed/Kit/Sources/Structs/ServiceConfiguration.swift diff --git a/Libraries/Feed/Kit/Sources/Protocols/Service.swift b/Libraries/Feed/Kit/Sources/Protocols/Service.swift new file mode 100644 index 0000000..d602442 --- /dev/null +++ b/Libraries/Feed/Kit/Sources/Protocols/Service.swift @@ -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 + +} diff --git a/Libraries/Feed/Kit/Sources/Structs/ServiceConfiguration.swift b/Libraries/Feed/Kit/Sources/Structs/ServiceConfiguration.swift new file mode 100644 index 0000000..32df28f --- /dev/null +++ b/Libraries/Feed/Kit/Sources/Structs/ServiceConfiguration.swift @@ -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 + } + +} diff --git a/Libraries/Foundation/Kit/Sources/Extensions/String+Constants.swift b/Libraries/Foundation/Kit/Sources/Extensions/String+Constants.swift index ab80392..f6d84ec 100644 --- a/Libraries/Foundation/Kit/Sources/Extensions/String+Constants.swift +++ b/Libraries/Foundation/Kit/Sources/Extensions/String+Constants.swift @@ -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.