[Library] iTunes library (#5)

This PR contains the work done to implement the `iTunesService` service that fetches the reviews from the **Apple App Store**.

Reviewed-on: rock-n-code/app-reviews#5
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #5.
This commit is contained in:
2024-03-17 22:48:27 +00:00
committed by javier
parent 4359f53a19
commit 7c016b50d6
18 changed files with 850 additions and 3 deletions
@@ -0,0 +1,43 @@
//
// iTunesService.swift
// ReviewsiTunes
//
// Created by Javier Cicchelli on 17/03/2024.
// Copyright © 2024 Röck+Cöde VoF. All rights reserved.
//
import Foundation
import ReviewsFeedKit
public actor iTunesService: Service {
// MARK: Constants
public let configuration: ServiceConfiguration
public let decoder: JSONDecoder
public let session: URLSession
// MARK: Properties
private lazy var getReviewsEndpoint: GetReviewsAPIEndpoint = {
.init(
host: configuration.host,
decoder: decoder,
session: session
)
}()
// MARK: Initialisers
public init(configuration: ServiceConfiguration) {
self.configuration = configuration
self.decoder = configuration.decoder
self.session = .init(configuration: configuration.session)
}
// MARK: Functions
@discardableResult public func getReviews(
_ input: GetReviewsInput
) async throws -> GetReviewsOutput {
try await getReviewsEndpoint(input)
}
}