Skip to content

Commit

Permalink
Repository refactor (no need to split for educational purposes)
Browse files Browse the repository at this point in the history
Header files comment now shows the TechTalk title
  • Loading branch information
fitomad committed Jul 7, 2023
1 parent 2649db7 commit 6b94f51
Show file tree
Hide file tree
Showing 49 changed files with 252 additions and 369 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Environment.swift
// Premiere
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 3/1/23.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PremiereApp.swift
// Premiere
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 3/1/23.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Int+Runtime.swift
// Premiere
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 10/3/23.
//
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// AmazonFavoriteTrainingRepository.swift
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 15/3/23.
//

import Foundation
import Resty

final class AmazonFavoriteTrainingRepository: AmazonFavoriteTrainingBaseRepository, FavoriteTrainingRepository {
func post(mediaID: Int, forUser userID: String) async throws {
try await super.process(mediaID: mediaID, forUser: userID, httpMethod: .post)
}

func delete(mediaID: Int, forUser userID: String) async throws {
try await super.process(mediaID: mediaID, forUser: userID, httpMethod: .delete)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SQSActivity.swift
// Premiere
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 13/3/23.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SQSActivityQueue.swift
// Premiere
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 12/3/23.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Trackable.swift
// Premiere
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 13/3/23.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// TMDBPopularDocumentaryListRepository.swift
// GlobantPlus
//
// Created by Adolfo Vera Blasco on 16/3/23.
//

import Foundation
import MovieDB

final class TMDBDashboardRepository: DashboardRepository {
let apiClient: MovieDB

init() {
self.apiClient = MovieDB(token: ApplicationEnvironment.shared.apiToken)
}

func fetchPopularDocumentaries() async throws -> [TrendingItem] {
let apiDocumentaries = try await apiClient.discoverDocumentaries(sortedBy: .popularity)

let trendingDocumentaries = apiDocumentaries.map({ apiDocumentary in
var trendingDocumentary = TrendingItem(titled: apiDocumentary.title, ofType: .tv, withIdentifier: apiDocumentary.id)

trendingDocumentary.backdropPath = apiClient.makeBackdropUriFrom(path: apiDocumentary.backdropPath, ofSize: .regular)
trendingDocumentary.posterPath = apiClient.makePosterUriFrom(path: apiDocumentary.posterPath, ofSize: .regular)

trendingDocumentary.popularity = apiDocumentary.popularity
trendingDocumentary.voteCount = apiDocumentary.voteCount
trendingDocumentary.voteAverage = apiDocumentary.voteAverage
trendingDocumentary.overview = apiDocumentary.overview

return trendingDocumentary
})

return trendingDocumentaries
}

func fetchTrendingMovies() async throws -> [TrendingItem] {
let apiMovies = try await apiClient.trendingMovies()

let trendingMovies = apiMovies.map({ apiMovie in
var trendingMovie = TrendingItem(titled: apiMovie.title, ofType: .movie, withIdentifier: apiMovie.id)

trendingMovie.backdropPath = apiClient.makeBackdropUriFrom(path: apiMovie.backdropPath, ofSize: .regular)
trendingMovie.posterPath = apiClient.makePosterUriFrom(path: apiMovie.posterPath, ofSize: .regular)

trendingMovie.popularity = apiMovie.popularity
trendingMovie.voteCount = apiMovie.voteCount
trendingMovie.voteAverage = apiMovie.voteAverage

trendingMovie.isAdultContent = apiMovie.isAdultContent
trendingMovie.overview = apiMovie.overview

return trendingMovie
})

return trendingMovies
}

func fetchTrendingShows() async throws -> [TrendingItem] {
async let apiShows = apiClient.trendingShows()
async let tvGenres = apiClient.genres(for: .tv)

let trendingShows = try await apiShows.map({ apiShow in
var trendingShow = TrendingItem(titled: apiShow.title, ofType: .tv, withIdentifier: apiShow.id)

trendingShow.backdropPath = apiClient.makeBackdropUriFrom(path: apiShow.backdropPath, ofSize: .regular)
trendingShow.posterPath = apiClient.makePosterUriFrom(path: apiShow.posterPath, ofSize: .regular)

trendingShow.popularity = apiShow.popularity
trendingShow.voteCount = apiShow.voteCount
trendingShow.voteAverage = apiShow.voteAverage

trendingShow.isAdultContent = apiShow.isAdultContent
trendingShow.overview = apiShow.overview

return trendingShow
})

return trendingShows
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6b94f51

Please sign in to comment.