One downside of using repositories is that need to implement all the method required that the protocol required.
You could return a error when you call a method that is not allowed/ you dont use.
Something like :
class CarRemoteRepository: Repository {
private let adapter = NetworkAdapter<CarService>(provider: MoyaProvider<CarService>())
func getAll(completion: @escaping (ResultList<[Car]>) -> Void) {
adapter.requestList(target: CarService.list, completion: completion)
}
func get(identifier: Int, completion: @escaping (Result<Car>) -> Void) {
completion(Result.error(NetworkErrors.errorMethodNotAllowed))
}
func create(a: Car, completion: @escaping (ResultVoid) -> Void) {
adapter.requestVoid(target: CarService.save(car: a), completion: completion)
}
func update(a: Car, completion: @escaping (ResultVoid) -> Void) {
adapter.requestVoid(target: CarService.edit(car: a), completion: completion)
}
func delete(a: Car, completion: @escaping (ResultVoid) -> Void) {
completion(ResultVoid.error(NetworkErrors.errorMethodNotAllowed))
}
}