44 lines
1.0 KiB
Swift
44 lines
1.0 KiB
Swift
|
//
|
||
|
// 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)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|