-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cc1102
commit c5ee3bc
Showing
18 changed files
with
118 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
Tests/TMDbIntegrationTests/Utility/TMDbSessionHelper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// File.swift | ||
// TMDb | ||
// | ||
// Created by Adam Young on 16/09/2024. | ||
// | ||
|
||
import Foundation | ||
import TMDb | ||
|
||
actor TMDbSessionHelper { | ||
|
||
static let shared = TMDbSessionHelper() | ||
|
||
private let credentialHelper: CredentialHelper | ||
|
||
private var sessionCache: CacheEntry? | ||
|
||
private init(credentialHelper: CredentialHelper = .shared) { | ||
self.credentialHelper = credentialHelper | ||
} | ||
|
||
// func session() async throws -> Session { | ||
// if let sessionCache { | ||
// switch sessionCache { | ||
// case .ready(let session): | ||
// return session | ||
// | ||
// case .inProgress(let task): | ||
// return try await task.value | ||
// } | ||
// } | ||
// | ||
// let apiKey = CredentialHelper.shared.tmdbAPIKey | ||
// let tmdbClient = TMDbClient(apiKey: apiKey) | ||
// let credential = credentialHelper.tmdbCredential | ||
// | ||
// let task = Task { | ||
// try await tmdbClient.authentication.createSession(withCredential: credential) | ||
// } | ||
// | ||
// sessionCache = .inProgress(task) | ||
// | ||
// do { | ||
// let session = try await task.value | ||
// sessionCache = .ready(session) | ||
// return session | ||
// } catch { | ||
// sessionCache = nil | ||
// throw error | ||
// } | ||
// } | ||
|
||
func createSession() async throws -> Session { | ||
let apiKey = CredentialHelper.shared.tmdbAPIKey | ||
let tmdbClient = TMDbClient(apiKey: apiKey) | ||
let credential = credentialHelper.tmdbCredential | ||
|
||
return try await tmdbClient.authentication.createSession(withCredential: credential) | ||
|
||
} | ||
|
||
func delete(session: Session) async throws { | ||
let apiKey = CredentialHelper.shared.tmdbAPIKey | ||
let tmdbClient = TMDbClient(apiKey: apiKey) | ||
|
||
try await tmdbClient.authentication.deleteSession(session) | ||
} | ||
|
||
} | ||
|
||
extension TMDbSessionHelper { | ||
|
||
private enum CacheEntry { | ||
case inProgress(Task<Session, Error>) | ||
case ready(Session) | ||
} | ||
|
||
} |
78 changes: 0 additions & 78 deletions
78
Tests/TMDbIntegrationTests/Utility/XCTestCase+ConfigureTMDb.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters