From 4a18b1853ab0674024f9a6e28a2d3c5d79e79f06 Mon Sep 17 00:00:00 2001 From: Rudrank Riyam Date: Mon, 30 May 2022 23:41:09 +0530 Subject: [PATCH] Add MusadoraLabs endpoint --- Package.swift | 26 ++-- .../Albums/AlbumCatalogEndpoint.swift | 78 +++++++++++ .../Albums/AlbumEndpointURLs.swift | 41 ++++++ .../Albums/AlbumLibraryEndpoint.swift | 78 +++++++++++ .../Apple Music Endpoint/AlbumsEndpoint.swift | 39 ------ .../AppleMusicEndpoint.swift | 48 +++---- .../ArtistsEndpoint.swift | 48 +++---- .../Apple Music Endpoint/Endpoint.swift | 15 +++ .../Apple Music Endpoint/LibraryPath.swift | 36 +++--- .../MusicVideosEndpoint.swift | 60 ++++----- .../PlaylistsEndpoint.swift | 48 +++---- .../Apple Music Endpoint/SongsEndpoint.swift | 58 +++++---- .../Apple Music Endpoint/Storefront.swift | 56 ++++---- Sources/MusadoraLabsKit/Categories.swift | 102 +++++++++++++++ Sources/MusadoraLabsKit/MusadoraLabsKit.swift | 32 ++--- ...usicAddResourcesRequestEndpointTests.swift | 30 ++--- Tests/MusadoraKitTests/MusadoraKitTests.swift | 9 +- .../MusicHistoryRequestEndpointTests.swift | 122 +++++++++--------- ...icRecommendationRequestEndpointTests.swift | 49 ++++--- .../AlbumsEndpointTests.swift | 76 +++++------ .../ArtistsEndpointTests.swift | 64 ++++----- .../MusadoraLabsKitTests.swift | 40 +++--- .../MusicVideosEndpointTests.swift | 76 +++++------ .../PlaylistsEndpointTests.swift | 64 ++++----- .../SongsEndpointTests.swift | 76 +++++------ .../XCTAssertEqualEndpoint.swift | 6 +- 26 files changed, 833 insertions(+), 544 deletions(-) create mode 100644 Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumCatalogEndpoint.swift create mode 100644 Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumEndpointURLs.swift create mode 100644 Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumLibraryEndpoint.swift delete mode 100644 Sources/MusadoraLabsKit/Apple Music Endpoint/AlbumsEndpoint.swift create mode 100644 Sources/MusadoraLabsKit/Apple Music Endpoint/Endpoint.swift create mode 100644 Sources/MusadoraLabsKit/Categories.swift diff --git a/Package.swift b/Package.swift index 4fa6b773e..6e0a4423b 100644 --- a/Package.swift +++ b/Package.swift @@ -4,17 +4,17 @@ import PackageDescription let package = Package( - name: "MusadoraKit", - platforms: [.iOS(.v15), .macOS(.v12), .watchOS(.v8), .tvOS(.v15)], - products: [ - .library(name: "MusadoraKit", type: .static, targets: ["MusadoraKit"]), - .library(name: "MusadoraLabsKit", type: .static, targets: ["MusadoraLabsKit"]), - ], - dependencies: [], - targets: [ - .target(name: "MusadoraKit", dependencies: []), - .testTarget(name: "MusadoraKitTests", dependencies: ["MusadoraKit"]), - .target(name: "MusadoraLabsKit", dependencies: []), - .testTarget(name: "MusadoraLabsKitTests", dependencies: ["MusadoraLabsKit"]), - ] + name: "MusadoraKit", + platforms: [.iOS(.v15), .macOS(.v12), .watchOS(.v8), .tvOS(.v15)], + products: [ + .library(name: "MusadoraKit", type: .static, targets: ["MusadoraKit"]), + .library(name: "MusadoraLabsKit", type: .static, targets: ["MusadoraLabsKit"]), + ], + dependencies: [], + targets: [ + .target(name: "MusadoraKit", dependencies: []), + .testTarget(name: "MusadoraKitTests", dependencies: ["MusadoraKit"]), + .target(name: "MusadoraLabsKit", dependencies: []), + .testTarget(name: "MusadoraLabsKitTests", dependencies: ["MusadoraLabsKit"]), + ] ) diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumCatalogEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumCatalogEndpoint.swift new file mode 100644 index 000000000..c78a611d5 --- /dev/null +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumCatalogEndpoint.swift @@ -0,0 +1,78 @@ +// +// AlbumCatalogEndpoint.swift +// AlbumCatalogEndpoint +// +// Created by Rudrank Riyam on 19/04/22. +// + +import Foundation + +// MARK: - Requesting Catalog Albums + +public enum AlbumCatalogEndpoint { + case id(id: String) + case ids(ids: [String]) + case upcs(upcs: [String]) +} + +// MARK: - Endpoint + +extension AlbumCatalogEndpoint: Endpoint { + public var name: String { + switch self { + case .id: + return "Get a Catalog Album" + case .ids: + return "Get Multiple Catalog Albums" + case .upcs: + return "Get Multiple Catalog Albums by UPC" + } + } + + public var description: String { + switch self { + case .id: + return "Fetch an album by using its identifier." + case .ids: + return "Fetch one or more albums by using their identifiers." + case .upcs: + return "Fetch one or more albums by using their UPC values." + } + } + + var previewURL: String { + switch self { + case .id: + return "https://api.music.apple.com/v1/catalog/{storefront}/albums/{id}" + case .ids: + return "https://api.music.apple.com/v1/catalog/{storefront}/albums?ids={ids}" + case .upcs: + return "https://api.music.apple.com/v1/catalog/{storefront}/albums?filter[upc]={upcs}" + } + } + + var url: URL { + get async throws { + switch self { + case let .id(id): + return try await MusadoraLabsKit.catalogAlbum(id: id) + case let .ids(ids): + return try await MusadoraLabsKit.catalogAlbums(ids: ids) + case let .upcs(upcs): + return try await MusadoraLabsKit.catalogAlbums(upcs: upcs) + } + } + } +} + +// MARK: - Identifiable + +extension AlbumCatalogEndpoint: Hashable, Identifiable { + public var id: Self { self } +} + +// MARK: - CaseIterable + +extension AlbumCatalogEndpoint: CaseIterable { + public static var allCases: [AlbumCatalogEndpoint] = [.id(id: ""), .ids(ids: []), .upcs(upcs: [])] +} diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumEndpointURLs.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumEndpointURLs.swift new file mode 100644 index 000000000..8d62ee0a4 --- /dev/null +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumEndpointURLs.swift @@ -0,0 +1,41 @@ +// +// AlbumsEndpoint.swift +// AlbumsEndpoint +// +// Created by Rudrank Riyam on 18/04/22. +// + +import Foundation + +public extension MusadoraLabsKit { + // MARK: - Catalog Albums + + static func catalogAlbum(id: String, storeFront: String? = nil) async throws -> URL { + try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.albums.id(id), storeFront: storeFront).url + } + + static func catalogAlbums(ids: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .albums, storeFront: storeFront, queryItems: [query]).url + } + + static func catalogAlbums(upcs: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "filter[upc]", value: upcs.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .albums, storeFront: storeFront, queryItems: [query]).url + } + + // MARK: - Library Albums + + static func libraryAlbum(id: String) async throws -> URL { + try await MusadoraLabsKit(library: .library, path: MusicItemPath.albums.id(id)).url + } + + static func libraryAlbums(ids: [String]) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .library, path: .albums, queryItems: [query]).url + } + + static func libraryAlbums() async throws -> URL { + try await MusadoraLabsKit(library: .library, path: .albums).url + } +} diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumLibraryEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumLibraryEndpoint.swift new file mode 100644 index 000000000..040541e17 --- /dev/null +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/Albums/AlbumLibraryEndpoint.swift @@ -0,0 +1,78 @@ +// +// AlbumLibraryEndpoint.swift +// AlbumLibraryEndpoint +// +// Created by Rudrank Riyam on 20/04/22. +// + +import Foundation + +// MARK: - Requesting User Library Albums + +enum AlbumLibraryEndpoint { + case all + case id(id: String) + case ids(ids: [String]) +} + +// MARK: - Endpoint + +extension AlbumLibraryEndpoint: Endpoint { + var name: String { + switch self { + case .all: + return "Get All Library Albums" + case .id: + return "Get a Library Album" + case .ids: + return "Get Multiple Library Albums" + } + } + + var description: String { + switch self { + case .all: + return "Fetch all the library albums in alphabetical order." + case .id: + return "Fetch a library album by using its identifier." + case .ids: + return "Fetch one or more library albums by using their identifiers." + } + } + + var previewURL: String { + switch self { + case .all: + return "https://api.music.apple.com/v1/me/library/albums/{id}" + case .id: + return "https://api.music.apple.com/v1/me/library/albums?ids={ids}" + case .ids: + return "https://api.music.apple.com/v1/me/library/albums" + } + } + + var url: URL { + get async throws { + switch self { + case .all: + return try await MusadoraLabsKit.libraryAlbums() + case let .id(id): + return try await MusadoraLabsKit.libraryAlbum(id: id) + case let .ids(ids): + return try await MusadoraLabsKit.libraryAlbums(ids: ids) + } + } + } +} + +// MARK: - Identifiable + +extension AlbumLibraryEndpoint: Hashable, Identifiable { + public var id: Self { self } +} + +// MARK: - CaseIterable + +// extension AlbumLibraryEndpoint: CaseIterable { +// static public var allCases: [AlbumCatalogEndpoint] = [.all, .id(id: ""), .ids(ids: [])] +// } diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/AlbumsEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/AlbumsEndpoint.swift deleted file mode 100644 index f1de4e814..000000000 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/AlbumsEndpoint.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// AlbumsEndpoint.swift -// AlbumsEndpoint -// -// Created by Rudrank Riyam on 18/04/22. -// - -import Foundation - -public extension MusadoraLabsKit { - // MARK: - Catalog Albums - static func catalogAlbum(id: String, storeFront: String? = nil) async throws -> URL { - try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.albums.id(id), storeFront: storeFront).url - } - - static func catalogAlbums(ids: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .albums, storeFront: storeFront, queryItems: [query]).url - } - - static func catalogAlbums(upcs: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "filter[upc]", value: upcs.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .albums, storeFront: storeFront, queryItems: [query]).url - } - - // MARK: - Library Albums - static func libraryAlbum(id: String) async throws -> URL { - try await MusadoraLabsKit(library: .library, path: MusicItemPath.albums.id(id)).url - } - - static func libraryAlbums(ids: [String]) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .library, path: .albums, queryItems: [query]).url - } - - static func libraryAlbums() async throws -> URL { - try await MusadoraLabsKit(library: .library, path: .albums).url - } -} diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/AppleMusicEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/AppleMusicEndpoint.swift index 1e5c7bdcf..2b0b8a563 100644 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/AppleMusicEndpoint.swift +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/AppleMusicEndpoint.swift @@ -9,32 +9,32 @@ import Foundation import MusicKit extension MusadoraLabsKit { - var url: URL { - get async throws { - var components = URLComponents() - components.scheme = "https" - components.host = "api.music.apple.com" - components.path = library.path + var url: URL { + get async throws { + var components = URLComponents() + components.scheme = "https" + components.host = "api.music.apple.com" + components.path = library.path - if let queryItems = queryItems { - components.queryItems = queryItems - } + if let queryItems = queryItems { + components.queryItems = queryItems + } - switch library { - case .catalog: - if let storeFront = storeFront { - components.path += storeFront + "/" + path - } else { - let storeFront = try await MusicDataRequest.currentCountryCode - components.path += storeFront + "/" + path - } - case .user, .library: components.path += path - } - - guard let url = components.url else { - preconditionFailure("Invalid URL components: \(components)") - } - return url + switch library { + case .catalog: + if let storeFront = storeFront { + components.path += storeFront + "/" + path + } else { + let storeFront = try await MusicDataRequest.currentCountryCode + components.path += storeFront + "/" + path } + case .user, .library: components.path += path + } + + guard let url = components.url else { + preconditionFailure("Invalid URL components: \(components)") + } + return url } + } } diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/ArtistsEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/ArtistsEndpoint.swift index cdbd54667..c8d0ca645 100644 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/ArtistsEndpoint.swift +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/ArtistsEndpoint.swift @@ -8,27 +8,29 @@ import Foundation extension MusadoraLabsKit { - // MARK: - Catalog Artists - static func catalogArtist(id: String, storeFront: String? = nil) async throws -> URL { - try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.artists.id(id), storeFront: storeFront).url - } - - static func catalogArtists(ids: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .artists, storeFront: storeFront, queryItems: [query]).url - } - - // MARK: - Library Artists - static func libraryArtist(id: String) async throws -> URL { - try await MusadoraLabsKit(library: .library, path: MusicItemPath.artists.id(id)).url - } - - static func libraryArtists(ids: [String]) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .library, path: .artists, queryItems: [query]).url - } - - static func libraryArtists() async throws -> URL { - try await MusadoraLabsKit(library: .library, path: .artists).url - } + // MARK: - Catalog Artists + + static func catalogArtist(id: String, storeFront: String? = nil) async throws -> URL { + try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.artists.id(id), storeFront: storeFront).url + } + + static func catalogArtists(ids: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .artists, storeFront: storeFront, queryItems: [query]).url + } + + // MARK: - Library Artists + + static func libraryArtist(id: String) async throws -> URL { + try await MusadoraLabsKit(library: .library, path: MusicItemPath.artists.id(id)).url + } + + static func libraryArtists(ids: [String]) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .library, path: .artists, queryItems: [query]).url + } + + static func libraryArtists() async throws -> URL { + try await MusadoraLabsKit(library: .library, path: .artists).url + } } diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/Endpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/Endpoint.swift new file mode 100644 index 000000000..f9c9593ee --- /dev/null +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/Endpoint.swift @@ -0,0 +1,15 @@ +// +// Endpoint.swift +// Endpoint +// +// Created by Rudrank Riyam on 19/04/22. +// + +import Foundation + +protocol Endpoint { + var name: String { get } + var description: String { get } + var previewURL: String { get } + var url: URL { get async throws } +} diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/LibraryPath.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/LibraryPath.swift index 0d85735b0..55331adef 100644 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/LibraryPath.swift +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/LibraryPath.swift @@ -8,27 +8,27 @@ import Foundation public enum LibraryPath { - case catalog - case user - case library - - var path: String { - switch self { - case .catalog: return "/v1/catalog/" - case .user: return "/v1/me/" - case .library: return "/v1/me/library/" - } + case catalog + case user + case library + + var path: String { + switch self { + case .catalog: return "/v1/catalog/" + case .user: return "/v1/me/" + case .library: return "/v1/me/library/" } + } } public enum MusicItemPath: String { - case albums - case songs - case artists - case playlists - case musicVideos = "music-videos" + case albums + case songs + case artists + case playlists + case musicVideos = "music-videos" - func id(_ id: String) -> String { - self.rawValue + "/" + id - } + func id(_ id: String) -> String { + rawValue + "/" + id + } } diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/MusicVideosEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/MusicVideosEndpoint.swift index c45c4db57..6f799baac 100644 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/MusicVideosEndpoint.swift +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/MusicVideosEndpoint.swift @@ -1,6 +1,6 @@ // // MusicVideosEndpoint.swift -// +// // // Created by Rudrank Riyam on 19/04/22. // @@ -8,32 +8,34 @@ import Foundation extension MusadoraLabsKit { - // MARK: - Catalog Music Videos - static func catalogMusicVideo(id: String, storeFront: String? = nil) async throws -> URL { - try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.musicVideos.id(id), storeFront: storeFront).url - } - - static func catalogMusicVideos(ids: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .musicVideos, storeFront: storeFront, queryItems: [query]).url - } - - static func catalogMusicVideos(isrcs: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "filter[isrc]", value: isrcs.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .musicVideos, storeFront: storeFront, queryItems: [query]).url - } - - // MARK: - Library Music Videos - static func libraryMusicVideo(id: String) async throws -> URL { - try await MusadoraLabsKit(library: .library, path: MusicItemPath.musicVideos.id(id)).url - } - - static func libraryMusicVideos(ids: [String]) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .library, path: .musicVideos, queryItems: [query]).url - } - - static func libraryMusicVideos() async throws -> URL { - try await MusadoraLabsKit(library: .library, path: .musicVideos).url - } + // MARK: - Catalog Music Videos + + static func catalogMusicVideo(id: String, storeFront: String? = nil) async throws -> URL { + try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.musicVideos.id(id), storeFront: storeFront).url + } + + static func catalogMusicVideos(ids: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .musicVideos, storeFront: storeFront, queryItems: [query]).url + } + + static func catalogMusicVideos(isrcs: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "filter[isrc]", value: isrcs.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .musicVideos, storeFront: storeFront, queryItems: [query]).url + } + + // MARK: - Library Music Videos + + static func libraryMusicVideo(id: String) async throws -> URL { + try await MusadoraLabsKit(library: .library, path: MusicItemPath.musicVideos.id(id)).url + } + + static func libraryMusicVideos(ids: [String]) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .library, path: .musicVideos, queryItems: [query]).url + } + + static func libraryMusicVideos() async throws -> URL { + try await MusadoraLabsKit(library: .library, path: .musicVideos).url + } } diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/PlaylistsEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/PlaylistsEndpoint.swift index 89d1c3c3f..11c6b0d08 100644 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/PlaylistsEndpoint.swift +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/PlaylistsEndpoint.swift @@ -8,27 +8,29 @@ import Foundation extension MusadoraLabsKit { - // MARK: - Catalog Playlists - static func catalogPlaylist(id: String, storeFront: String? = nil) async throws -> URL { - try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.playlists.id(id), storeFront: storeFront).url - } - - static func catalogPlaylists(ids: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .playlists, storeFront: storeFront, queryItems: [query]).url - } - - // MARK: - Library Playlists - static func libraryPlaylist(id: String) async throws -> URL { - try await MusadoraLabsKit(library: .library, path: MusicItemPath.playlists.id(id)).url - } - - static func libraryPlaylists(ids: [String]) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .library, path: .playlists, queryItems: [query]).url - } - - static func libraryPlaylists() async throws -> URL { - try await MusadoraLabsKit(library: .library, path: .playlists).url - } + // MARK: - Catalog Playlists + + static func catalogPlaylist(id: String, storeFront: String? = nil) async throws -> URL { + try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.playlists.id(id), storeFront: storeFront).url + } + + static func catalogPlaylists(ids: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .playlists, storeFront: storeFront, queryItems: [query]).url + } + + // MARK: - Library Playlists + + static func libraryPlaylist(id: String) async throws -> URL { + try await MusadoraLabsKit(library: .library, path: MusicItemPath.playlists.id(id)).url + } + + static func libraryPlaylists(ids: [String]) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .library, path: .playlists, queryItems: [query]).url + } + + static func libraryPlaylists() async throws -> URL { + try await MusadoraLabsKit(library: .library, path: .playlists).url + } } diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/SongsEndpoint.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/SongsEndpoint.swift index aaec26370..6e699519f 100644 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/SongsEndpoint.swift +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/SongsEndpoint.swift @@ -8,32 +8,34 @@ import Foundation extension MusadoraLabsKit { - // MARK: - Catalog Songs - static func catalogSong(id: String, storeFront: String? = nil) async throws -> URL { - try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.songs.id(id), storeFront: storeFront).url - } - - static func catalogSongs(ids: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .songs, storeFront: storeFront, queryItems: [query]).url - } - - static func catalogSongs(isrcs: [String], storeFront: String? = nil) async throws -> URL { - let query = URLQueryItem(name: "filter[isrc]", value: isrcs.joined(separator: ",")) - return try await MusadoraLabsKit(library: .catalog, path: .songs, storeFront: storeFront, queryItems: [query]).url - } - - // MARK: - Library Songs - static func librarySong(id: String) async throws -> URL { - try await MusadoraLabsKit(library: .library, path: MusicItemPath.songs.id(id)).url - } - - static func librarySongs(ids: [String]) async throws -> URL { - let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) - return try await MusadoraLabsKit(library: .library, path: .songs, queryItems: [query]).url - } - - static func librarySongs() async throws -> URL { - try await MusadoraLabsKit(library: .library, path: .songs).url - } + // MARK: - Catalog Songs + + static func catalogSong(id: String, storeFront: String? = nil) async throws -> URL { + try await MusadoraLabsKit(library: .catalog, path: MusicItemPath.songs.id(id), storeFront: storeFront).url + } + + static func catalogSongs(ids: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .songs, storeFront: storeFront, queryItems: [query]).url + } + + static func catalogSongs(isrcs: [String], storeFront: String? = nil) async throws -> URL { + let query = URLQueryItem(name: "filter[isrc]", value: isrcs.joined(separator: ",")) + return try await MusadoraLabsKit(library: .catalog, path: .songs, storeFront: storeFront, queryItems: [query]).url + } + + // MARK: - Library Songs + + static func librarySong(id: String) async throws -> URL { + try await MusadoraLabsKit(library: .library, path: MusicItemPath.songs.id(id)).url + } + + static func librarySongs(ids: [String]) async throws -> URL { + let query = URLQueryItem(name: "ids", value: ids.joined(separator: ",")) + return try await MusadoraLabsKit(library: .library, path: .songs, queryItems: [query]).url + } + + static func librarySongs() async throws -> URL { + try await MusadoraLabsKit(library: .library, path: .songs).url + } } diff --git a/Sources/MusadoraLabsKit/Apple Music Endpoint/Storefront.swift b/Sources/MusadoraLabsKit/Apple Music Endpoint/Storefront.swift index e97adec87..c9e6223b5 100644 --- a/Sources/MusadoraLabsKit/Apple Music Endpoint/Storefront.swift +++ b/Sources/MusadoraLabsKit/Apple Music Endpoint/Storefront.swift @@ -1,6 +1,6 @@ // // File.swift -// +// // // Created by Rudrank Riyam on 19/04/22. // @@ -9,38 +9,38 @@ import Foundation import MusicKit public struct Storefronts: Codable { - let data: [Storefront] + let data: [Storefront] - public struct Storefront: Codable { - public let id: String - public let type: `Type` - public let attributes: Attributes + public struct Storefront: Codable { + public let id: String + public let type: `Type` + public let attributes: Attributes - public struct Attributes: Codable { - public let explicitContentPolicy: ExplicitContentPolicy - public let name: String - public let supportedLanguageTags: [String] - public let defaultLanguageTag: String - } + public struct Attributes: Codable { + public let explicitContentPolicy: ExplicitContentPolicy + public let name: String + public let supportedLanguageTags: [String] + public let defaultLanguageTag: String + } - public enum ExplicitContentPolicy: String, Codable { - case allowed = "allowed" - case optIn = "opt-in" - case prohibited = "prohibited" - } + public enum ExplicitContentPolicy: String, Codable { + case allowed + case optIn = "opt-in" + case prohibited + } - public enum `Type`: String, Codable { - case storefronts = "storefronts" - } + public enum `Type`: String, Codable { + case storefronts } + } } -extension MusadoraLabsKit { - public static func storefronts() async throws -> [Storefronts.Storefront] { - let url = URL(string: "https://api.music.apple.com/v1/storefronts")! - let request = MusicDataRequest(urlRequest: .init(url: url)) - let response = try await request.response() - let storefronts = try JSONDecoder().decode(Storefronts.self, from: response.data) - return storefronts.data - } +public extension MusadoraLabsKit { + static func storefronts() async throws -> [Storefronts.Storefront] { + let url = URL(string: "https://api.music.apple.com/v1/storefronts")! + let request = MusicDataRequest(urlRequest: .init(url: url)) + let response = try await request.response() + let storefronts = try JSONDecoder().decode(Storefronts.self, from: response.data) + return storefronts.data + } } diff --git a/Sources/MusadoraLabsKit/Categories.swift b/Sources/MusadoraLabsKit/Categories.swift new file mode 100644 index 000000000..8596b3064 --- /dev/null +++ b/Sources/MusadoraLabsKit/Categories.swift @@ -0,0 +1,102 @@ +// +// Categories.swift +// Categories +// +// Created by Rudrank Riyam on 19/04/22. +// + +import Foundation + +public enum Categories: String { + case albums + case artists + case songs + case musicVideos + + case playlists + case stations + + case search + + case ratings + case genres + case charts + + case recommendations + case history + + case recordLabels + case curators + + public var sectionName: [String] { + [ + "Albums, Artists, Songs, and Videos", + "Playlists and Stations", + "Search", + "Ratings, Genres, and Charts", + "Activities, Curators, and Record Labels", + "Recommendations and History", + "Fetching Multiple Resource Types", + ] + } + + public var name: String { + switch self { + case .albums: return "Albums" + case .artists: return "Artists" + case .songs: return "Songs" + case .musicVideos: return "Music Videos" + case .playlists: return "Playlists" + case .stations: return "Apple Music Stations" + case .search: return "Search" + case .ratings: return "Ratings" + case .genres: return "Music Genres" + case .charts: return "Charts" + case .recordLabels: return "Record Labels" + case .curators: return "Curators" + case .recommendations: return "Recommendations" + case .history: return "History" + } + } + + public var description: String { + switch self { + case .albums: + return "Get an album’s name, artist, list of tracks, artwork, release date, and recording information, and add new albums to the user’s library." + case .artists: + return "Get information about an artist, including the content they created and references to them in playlists and radio stations." + case .songs: + return "Get information about a particular song, including the artist who created it and the album on which it appeared." + case .musicVideos: + return "Get information about a music video, including the artist who created it and the associated album, and add new videos to the user’s library." + case .playlists: + return "Get the contents of playlists, add new playlists to the user's library, and add tracks to an existing playlist." + case .stations: + return "Get information about streaming content offered by Apple Music." + case .search: + return "Search for albums, songs, artists, and other information in the user’s personal library or the Apple Music Catalog." + case .ratings: + return "Get and set ratings for albums, songs, playlists, music videos, and stations." + case .genres: + return "Get information about the genres of the user’s music or items in the Apple Music Catalog." + case .charts: + return "Get chart information that shows the popularity of albums, songs, and music videos." + case .recommendations: + return "Get music recommendations based on the user’s library and purchase history." + case .history: + return "Get historical information about the songs and stations the user played recently." + case .recordLabels: + return "Get information on record labels in the Apple Music Catalog." + case .curators: + return "Get information about the person who curated a playlist or station." + } + } +} + +extension Categories: Identifiable { + public var id: String { + rawValue + } +} + +extension Categories: CaseIterable {} diff --git a/Sources/MusadoraLabsKit/MusadoraLabsKit.swift b/Sources/MusadoraLabsKit/MusadoraLabsKit.swift index 0e42d68c0..66fbd920f 100644 --- a/Sources/MusadoraLabsKit/MusadoraLabsKit.swift +++ b/Sources/MusadoraLabsKit/MusadoraLabsKit.swift @@ -8,22 +8,22 @@ import Foundation public struct MusadoraLabsKit { - var library: LibraryPath - var path: String - var queryItems: [URLQueryItem]? - var storeFront: String? + var library: LibraryPath + var path: String + var queryItems: [URLQueryItem]? + var storeFront: String? - init(library: LibraryPath, path: String, storeFront: String? = nil, queryItems: [URLQueryItem]? = nil) { - self.library = library - self.path = path - self.queryItems = queryItems - self.storeFront = storeFront - } + init(library: LibraryPath, path: String, storeFront: String? = nil, queryItems: [URLQueryItem]? = nil) { + self.library = library + self.path = path + self.queryItems = queryItems + self.storeFront = storeFront + } - init(library: LibraryPath, path: MusicItemPath, storeFront: String? = nil, queryItems: [URLQueryItem]? = nil) { - self.library = library - self.path = path.rawValue - self.queryItems = queryItems - self.storeFront = storeFront - } + init(library: LibraryPath, path: MusicItemPath, storeFront: String? = nil, queryItems: [URLQueryItem]? = nil) { + self.library = library + self.path = path.rawValue + self.queryItems = queryItems + self.storeFront = storeFront + } } diff --git a/Tests/MusadoraKitTests/Add Resources/MusicAddResourcesRequestEndpointTests.swift b/Tests/MusadoraKitTests/Add Resources/MusicAddResourcesRequestEndpointTests.swift index d5bf6ad4a..88f6a96ee 100644 --- a/Tests/MusadoraKitTests/Add Resources/MusicAddResourcesRequestEndpointTests.swift +++ b/Tests/MusadoraKitTests/Add Resources/MusicAddResourcesRequestEndpointTests.swift @@ -5,27 +5,27 @@ // Created by Rudrank Riyam on 18/05/22. // -import XCTest @testable import MusadoraKit import MusicKit +import XCTest class MusicAddResourcesRequestEndpointTests: XCTestCase { - func testAddAlbumsToLibraryEndpointURL() throws { - let albums: [MusicItemID] = ["1577502911", "1577502912"] - - let request = MusicAddResourcesRequest(types: [.albums: albums]) - let url = try request.addResourcesEndpointURL + func testAddAlbumsToLibraryEndpointURL() throws { + let albums: [MusicItemID] = ["1577502911", "1577502912"] + + let request = MusicAddResourcesRequest(types: [.albums: albums]) + let url = try request.addResourcesEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/library?ids[albums]=1577502911,1577502912") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/library?ids[albums]=1577502911,1577502912") + } - func testAddResourcesToLibraryEndpointURL() throws { - let albums: [MusicItemID] = ["1577502911"] - let songs: [MusicItemID] = ["1545146511"] + func testAddResourcesToLibraryEndpointURL() throws { + let albums: [MusicItemID] = ["1577502911"] + let songs: [MusicItemID] = ["1545146511"] - let request = MusicAddResourcesRequest(types: [.albums: albums, .songs: songs]) - let url = try request.addResourcesEndpointURL + let request = MusicAddResourcesRequest(types: [.albums: albums, .songs: songs]) + let url = try request.addResourcesEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/library?ids[albums]=1577502911&ids[songs]=1545146511") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/library?ids[albums]=1577502911&ids[songs]=1545146511") + } } diff --git a/Tests/MusadoraKitTests/MusadoraKitTests.swift b/Tests/MusadoraKitTests/MusadoraKitTests.swift index ed98291f6..21213eaa4 100644 --- a/Tests/MusadoraKitTests/MusadoraKitTests.swift +++ b/Tests/MusadoraKitTests/MusadoraKitTests.swift @@ -5,13 +5,12 @@ // Created by Rudrank Riyam on 19/04/22. // -import XCTest @testable import MusadoraKit +import XCTest -final class MusadoraKitTests: XCTestCase { -} +final class MusadoraKitTests: XCTestCase {} public func XCTAssertEqualEndpoint(_ endpoint: URL, _ url: String) { - let url = URL(string: url)! - XCTAssertEqual(endpoint, url) + let url = URL(string: url)! + XCTAssertEqual(endpoint, url) } diff --git a/Tests/MusadoraKitTests/MusicHistoryRequestEndpointTests.swift b/Tests/MusadoraKitTests/MusicHistoryRequestEndpointTests.swift index 63132baea..502a7500c 100644 --- a/Tests/MusadoraKitTests/MusicHistoryRequestEndpointTests.swift +++ b/Tests/MusadoraKitTests/MusicHistoryRequestEndpointTests.swift @@ -5,92 +5,92 @@ // Created by Rudrank Riyam on 27/04/22. // -import XCTest @testable import MusadoraKit +import XCTest class MusicHistoryRequestEndpointTests: XCTestCase { - func testHeavyRoationEndpointURL() throws { - let request = MusicHistoryRequest(for: .heavyRotation) - let url = try request.historyEndpointURL + func testHeavyRoationEndpointURL() throws { + let request = MusicHistoryRequest(for: .heavyRotation) + let url = try request.historyEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/history/heavy-rotation") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/history/heavy-rotation") + } - func testHeavyRoationEndpointURLWithOverLimit() throws { - let limit = 11 - var request = MusicHistoryRequest(for: .heavyRotation) - request.limit = limit + func testHeavyRoationEndpointURLWithOverLimit() throws { + let limit = 11 + var request = MusicHistoryRequest(for: .heavyRotation) + request.limit = limit - XCTAssertThrowsError(try request.historyEndpointURL) { error in - XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) - } + XCTAssertThrowsError(try request.historyEndpointURL) { error in + XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) } + } - func testRecentlyAddedEndpointURL() throws { - let request = MusicHistoryRequest(for: .recentlyAdded) - let url = try request.historyEndpointURL + func testRecentlyAddedEndpointURL() throws { + let request = MusicHistoryRequest(for: .recentlyAdded) + let url = try request.historyEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/library/recently-added") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/library/recently-added") + } - func testRecentlyAddedEndpointURLWithOverLimit() throws { - let limit = 26 - var request = MusicHistoryRequest(for: .recentlyAdded) - request.limit = limit + func testRecentlyAddedEndpointURLWithOverLimit() throws { + let limit = 26 + var request = MusicHistoryRequest(for: .recentlyAdded) + request.limit = limit - XCTAssertThrowsError(try request.historyEndpointURL) { error in - XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) - } + XCTAssertThrowsError(try request.historyEndpointURL) { error in + XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) } + } - func testRecentlyPlayedEndpointURL() throws { - let request = MusicHistoryRequest(for: .recentlyPlayed) - let url = try request.historyEndpointURL + func testRecentlyPlayedEndpointURL() throws { + let request = MusicHistoryRequest(for: .recentlyPlayed) + let url = try request.historyEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recent/played") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recent/played") + } - func testRecentlyPlayedEndpointURLWithOverLimit() throws { - let limit = 11 - var request = MusicHistoryRequest(for: .recentlyPlayed) - request.limit = limit + func testRecentlyPlayedEndpointURLWithOverLimit() throws { + let limit = 11 + var request = MusicHistoryRequest(for: .recentlyPlayed) + request.limit = limit - XCTAssertThrowsError(try request.historyEndpointURL) { error in - XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) - } + XCTAssertThrowsError(try request.historyEndpointURL) { error in + XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) } + } - func testRecentlyPlayedTracksEndpointURL() throws { - let request = MusicHistoryRequest(for: .recentlyPlayedTracks) - let url = try request.historyEndpointURL + func testRecentlyPlayedTracksEndpointURL() throws { + let request = MusicHistoryRequest(for: .recentlyPlayedTracks) + let url = try request.historyEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recent/played/tracks") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recent/played/tracks") + } - func testRecentlyPlayedTracksEndpointURLWithOverLimit() throws { - let limit = 31 - var request = MusicHistoryRequest(for: .recentlyPlayedTracks) - request.limit = limit + func testRecentlyPlayedTracksEndpointURLWithOverLimit() throws { + let limit = 31 + var request = MusicHistoryRequest(for: .recentlyPlayedTracks) + request.limit = limit - XCTAssertThrowsError(try request.historyEndpointURL) { error in - XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) - } + XCTAssertThrowsError(try request.historyEndpointURL) { error in + XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) } + } - func testRecentlyPlayedStationsEndpointURL() throws { - let request = MusicHistoryRequest(for: .recentlyPlayedStations) - let url = try request.historyEndpointURL + func testRecentlyPlayedStationsEndpointURL() throws { + let request = MusicHistoryRequest(for: .recentlyPlayedStations) + let url = try request.historyEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recent/radio-stations") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recent/radio-stations") + } - func testRecentlyPlayedStationsEndpointURLWithOverLimit() throws { - let limit = 11 - var request = MusicHistoryRequest(for: .recentlyPlayedStations) - request.limit = limit + func testRecentlyPlayedStationsEndpointURLWithOverLimit() throws { + let limit = 11 + var request = MusicHistoryRequest(for: .recentlyPlayedStations) + request.limit = limit - XCTAssertThrowsError(try request.historyEndpointURL) { error in - XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) - } + XCTAssertThrowsError(try request.historyEndpointURL) { error in + XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.historyOverLimit(limit: request.maximumLimit, overLimit: limit)) } + } } diff --git a/Tests/MusadoraKitTests/Recommendation/MusicRecommendationRequestEndpointTests.swift b/Tests/MusadoraKitTests/Recommendation/MusicRecommendationRequestEndpointTests.swift index 35d712fa9..9bc0dfa16 100644 --- a/Tests/MusadoraKitTests/Recommendation/MusicRecommendationRequestEndpointTests.swift +++ b/Tests/MusadoraKitTests/Recommendation/MusicRecommendationRequestEndpointTests.swift @@ -5,40 +5,39 @@ // Created by Rudrank Riyam on 27/04/22. // -import XCTest @testable import MusadoraKit +import XCTest class MusicRecommendationRequestEndpointTests: XCTestCase { - func testDefaultRecommendationEndpointURL() throws { - let request = MusicRecommendationRequest() - let url = try request.recommendationEndpointURL + func testDefaultRecommendationEndpointURL() throws { + let request = MusicRecommendationRequest() + let url = try request.recommendationEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recommendations") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recommendations") + } - func testDefaultRecommendationWithLimitEndpointURL() throws { - var request = MusicRecommendationRequest() - request.limit = 5 - let url = try request.recommendationEndpointURL + func testDefaultRecommendationWithLimitEndpointURL() throws { + var request = MusicRecommendationRequest() + request.limit = 5 + let url = try request.recommendationEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recommendations?limit=5") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recommendations?limit=5") + } - func testRecommendationByIDEndpointURL() throws { - let request = MusicRecommendationRequest(equalTo: "6-27s5hU6azhJY") - let url = try request.recommendationEndpointURL + func testRecommendationByIDEndpointURL() throws { + let request = MusicRecommendationRequest(equalTo: "6-27s5hU6azhJY") + let url = try request.recommendationEndpointURL - XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recommendations?ids=6-27s5hU6azhJY") - } + XCTAssertEqualEndpoint(url, "https://api.music.apple.com/v1/me/recommendations?ids=6-27s5hU6azhJY") + } - func testDefaultRecommendationEndpointURLWithOverLimit() throws { - let limit = 31 - var request = MusicRecommendationRequest() - request.limit = limit + func testDefaultRecommendationEndpointURLWithOverLimit() throws { + let limit = 31 + var request = MusicRecommendationRequest() + request.limit = limit - XCTAssertThrowsError(try request.recommendationEndpointURL) { error in - XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.recommendationOverLimit(for: limit)) - } + XCTAssertThrowsError(try request.recommendationEndpointURL) { error in + XCTAssertEqual(error as! MusadoraKitError, MusadoraKitError.recommendationOverLimit(for: limit)) } + } } - diff --git a/Tests/MusadoraLabsKitTests/AlbumsEndpointTests.swift b/Tests/MusadoraLabsKitTests/AlbumsEndpointTests.swift index 81f172fa9..086b3ce85 100644 --- a/Tests/MusadoraLabsKitTests/AlbumsEndpointTests.swift +++ b/Tests/MusadoraLabsKitTests/AlbumsEndpointTests.swift @@ -5,44 +5,46 @@ // Created by Rudrank Riyam on 18/04/22. // -import XCTest @testable import MusadoraLabsKit +import XCTest final class AlbumsEndpointTests: XCTestCase { - // MARK: - Catalog Albums Tests - func testFetchACatalogAlbumByIDEndpoint() async throws { - let id = "1564530719" - let endpoint = try await MusadoraLabsKit.catalogAlbum(id: id, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/albums/1564530719") - } - - func testFetchMultipleCatalogAlbumsByIDsEndpoint() async throws { - let ids = ["1564530719", "1568819304"] - let endpoint = try await MusadoraLabsKit.catalogAlbums(ids: ids, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/albums?ids=1564530719,1568819304") - } - - func testFetchMultipleCatalogAlbumsByUPCEndpoint() async throws { - let upcs = ["5056167160984"] - let endpoint = try await MusadoraLabsKit.catalogAlbums(upcs: upcs, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/albums?filter[upc]=5056167160984") - } - - // MARK: - Library Albums Tests - func testFetchALibraryAlbumByIDEndpoint() async throws { - let id = "l.qrRWYhq" - let endpoint = try await MusadoraLabsKit.libraryAlbum(id: id) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/albums/l.qrRWYhq") - } - - func testFetchMultipleLibraryAlbumsByIDsEndpoint() async throws { - let ids = ["l.qrRWYhq"] - let endpoint = try await MusadoraLabsKit.libraryAlbums(ids: ids) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/albums?ids=l.qrRWYhq") - } - - func testFetchAllLibraryAlbumsEndpoint() async throws { - let endpoint = try await MusadoraLabsKit.libraryAlbums() - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/albums") - } + // MARK: - Catalog Albums Tests + + func testFetchACatalogAlbumByIDEndpoint() async throws { + let id = "1564530719" + let endpoint = try await MusadoraLabsKit.catalogAlbum(id: id, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/albums/1564530719") + } + + func testFetchMultipleCatalogAlbumsByIDsEndpoint() async throws { + let ids = ["1564530719", "1568819304"] + let endpoint = try await MusadoraLabsKit.catalogAlbums(ids: ids, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/albums?ids=1564530719,1568819304") + } + + func testFetchMultipleCatalogAlbumsByUPCEndpoint() async throws { + let upcs = ["5056167160984"] + let endpoint = try await MusadoraLabsKit.catalogAlbums(upcs: upcs, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/albums?filter[upc]=5056167160984") + } + + // MARK: - Library Albums Tests + + func testFetchALibraryAlbumByIDEndpoint() async throws { + let id = "l.qrRWYhq" + let endpoint = try await MusadoraLabsKit.libraryAlbum(id: id) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/albums/l.qrRWYhq") + } + + func testFetchMultipleLibraryAlbumsByIDsEndpoint() async throws { + let ids = ["l.qrRWYhq"] + let endpoint = try await MusadoraLabsKit.libraryAlbums(ids: ids) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/albums?ids=l.qrRWYhq") + } + + func testFetchAllLibraryAlbumsEndpoint() async throws { + let endpoint = try await MusadoraLabsKit.libraryAlbums() + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/albums") + } } diff --git a/Tests/MusadoraLabsKitTests/ArtistsEndpointTests.swift b/Tests/MusadoraLabsKitTests/ArtistsEndpointTests.swift index c38d848a0..7c6e27e23 100644 --- a/Tests/MusadoraLabsKitTests/ArtistsEndpointTests.swift +++ b/Tests/MusadoraLabsKitTests/ArtistsEndpointTests.swift @@ -5,38 +5,40 @@ // Created by Rudrank Riyam on 19/04/22. // -import XCTest @testable import MusadoraLabsKit +import XCTest class ArtistsEndpointTests: XCTestCase { - // MARK: - Catalog Artists Tests - func testFetchACatalogArtistsByIDEndpoint() async throws { - let id = "1264549322" - let endpoint = try await MusadoraLabsKit.catalogArtist(id: id, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/artists/1264549322") - } - - func testFetchMultipleCatalogArtistsByIDsEndpoint() async throws { - let ids = ["1065981054", "1264549322"] - let endpoint = try await MusadoraLabsKit.catalogArtists(ids: ids, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/artists?ids=1065981054,1264549322") - } - - // MARK: - Library Artists Tests - func testFetchALibraryArtistByIDEndpoint() async throws { - let id = "r.V2zewCs" - let endpoint = try await MusadoraLabsKit.libraryArtist(id: id) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/artists/r.V2zewCs") - } - - func testFetchMultipleLibraryArtistsByIDsEndpoint() async throws { - let ids = ["r.V2zewCs"] - let endpoint = try await MusadoraLabsKit.libraryArtists(ids: ids) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/artists?ids=r.V2zewCs") - } - - func testFetchAllLibraryArtistsEndpoint() async throws { - let endpoint = try await MusadoraLabsKit.libraryArtists() - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/artists") - } + // MARK: - Catalog Artists Tests + + func testFetchACatalogArtistsByIDEndpoint() async throws { + let id = "1264549322" + let endpoint = try await MusadoraLabsKit.catalogArtist(id: id, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/artists/1264549322") + } + + func testFetchMultipleCatalogArtistsByIDsEndpoint() async throws { + let ids = ["1065981054", "1264549322"] + let endpoint = try await MusadoraLabsKit.catalogArtists(ids: ids, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/artists?ids=1065981054,1264549322") + } + + // MARK: - Library Artists Tests + + func testFetchALibraryArtistByIDEndpoint() async throws { + let id = "r.V2zewCs" + let endpoint = try await MusadoraLabsKit.libraryArtist(id: id) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/artists/r.V2zewCs") + } + + func testFetchMultipleLibraryArtistsByIDsEndpoint() async throws { + let ids = ["r.V2zewCs"] + let endpoint = try await MusadoraLabsKit.libraryArtists(ids: ids) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/artists?ids=r.V2zewCs") + } + + func testFetchAllLibraryArtistsEndpoint() async throws { + let endpoint = try await MusadoraLabsKit.libraryArtists() + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/artists") + } } diff --git a/Tests/MusadoraLabsKitTests/MusadoraLabsKitTests.swift b/Tests/MusadoraLabsKitTests/MusadoraLabsKitTests.swift index c71ac24c5..8a5f1f12e 100644 --- a/Tests/MusadoraLabsKitTests/MusadoraLabsKitTests.swift +++ b/Tests/MusadoraLabsKitTests/MusadoraLabsKitTests.swift @@ -5,32 +5,30 @@ // Created by Rudrank Riyam on 27/04/22. // -import XCTest @testable import MusadoraLabsKit +import XCTest class MusadoraLabsKitTests: XCTestCase { + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } - func testExample() throws { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - // Any test you write for XCTest can be annotated as throws and async. - // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. - // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + func testPerformanceExample() throws { + // This is an example of a performance test case. + measure { + // Put the code you want to measure the time of here. } - - func testPerformanceExample() throws { - // This is an example of a performance test case. - self.measure { - // Put the code you want to measure the time of here. - } - } - + } } diff --git a/Tests/MusadoraLabsKitTests/MusicVideosEndpointTests.swift b/Tests/MusadoraLabsKitTests/MusicVideosEndpointTests.swift index 23468c635..d8999e4ec 100644 --- a/Tests/MusadoraLabsKitTests/MusicVideosEndpointTests.swift +++ b/Tests/MusadoraLabsKitTests/MusicVideosEndpointTests.swift @@ -5,44 +5,46 @@ // Created by Rudrank Riyam on 19/04/22. // -import XCTest @testable import MusadoraLabsKit +import XCTest class MusicVideosEndpointTests: XCTestCase { - // MARK: - Catalog Music Videos Tests - func testFetchACatalogMusicVideosByIDEndpoint() async throws { - let id = "1560735548" - let endpoint = try await MusadoraLabsKit.catalogMusicVideo(id: id, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/music-videos/1560735548") - } - - func testFetchMultipleCatalogMusicVideosByIDsEndpoint() async throws { - let ids = ["1560735548", "1572278914"] - let endpoint = try await MusadoraLabsKit.catalogMusicVideos(ids: ids, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/music-videos?ids=1560735548,1572278914") - } - - func testFetchMultipleCatalogMusicVideosByISRCEndpoint() async throws { - let isrcs = ["USUM72105936"] - let endpoint = try await MusadoraLabsKit.catalogMusicVideos(isrcs: isrcs, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/music-videos?filter[isrc]=USUM72105936") - } - - // MARK: - Library Music Videos Tests - func testFetchALibraryMusicVideoByIDEndpoint() async throws { - let id = "i.gelNOzPuL41Lxo" - let endpoint = try await MusadoraLabsKit.libraryMusicVideo(id: id) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/music-videos/i.gelNOzPuL41Lxo") - } - - func testFetchMultipleLibraryMusicVideosByIDsEndpoint() async throws { - let ids = ["i.gelNOzPuL41Lxo"] - let endpoint = try await MusadoraLabsKit.libraryMusicVideos(ids: ids) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/music-videos?ids=i.gelNOzPuL41Lxo") - } - - func testFetchAllLibraryArtistsEndpoint() async throws { - let endpoint = try await MusadoraLabsKit.libraryMusicVideos() - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/music-videos") - } + // MARK: - Catalog Music Videos Tests + + func testFetchACatalogMusicVideosByIDEndpoint() async throws { + let id = "1560735548" + let endpoint = try await MusadoraLabsKit.catalogMusicVideo(id: id, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/music-videos/1560735548") + } + + func testFetchMultipleCatalogMusicVideosByIDsEndpoint() async throws { + let ids = ["1560735548", "1572278914"] + let endpoint = try await MusadoraLabsKit.catalogMusicVideos(ids: ids, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/music-videos?ids=1560735548,1572278914") + } + + func testFetchMultipleCatalogMusicVideosByISRCEndpoint() async throws { + let isrcs = ["USUM72105936"] + let endpoint = try await MusadoraLabsKit.catalogMusicVideos(isrcs: isrcs, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/music-videos?filter[isrc]=USUM72105936") + } + + // MARK: - Library Music Videos Tests + + func testFetchALibraryMusicVideoByIDEndpoint() async throws { + let id = "i.gelNOzPuL41Lxo" + let endpoint = try await MusadoraLabsKit.libraryMusicVideo(id: id) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/music-videos/i.gelNOzPuL41Lxo") + } + + func testFetchMultipleLibraryMusicVideosByIDsEndpoint() async throws { + let ids = ["i.gelNOzPuL41Lxo"] + let endpoint = try await MusadoraLabsKit.libraryMusicVideos(ids: ids) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/music-videos?ids=i.gelNOzPuL41Lxo") + } + + func testFetchAllLibraryArtistsEndpoint() async throws { + let endpoint = try await MusadoraLabsKit.libraryMusicVideos() + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/music-videos") + } } diff --git a/Tests/MusadoraLabsKitTests/PlaylistsEndpointTests.swift b/Tests/MusadoraLabsKitTests/PlaylistsEndpointTests.swift index 58be8a9fb..35bb0ae02 100644 --- a/Tests/MusadoraLabsKitTests/PlaylistsEndpointTests.swift +++ b/Tests/MusadoraLabsKitTests/PlaylistsEndpointTests.swift @@ -7,38 +7,40 @@ import Foundation -import XCTest @testable import MusadoraLabsKit +import XCTest class PlaylistsEndpointTests: XCTestCase { - // MARK: - Catalog Playlists Tests - func testFetchACatalogPlaylistsByIDEndpoint() async throws { - let id = "pl.f4d106fed2bd41149aaacabb233eb5eb" - let endpoint = try await MusadoraLabsKit.catalogPlaylist(id: id, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/playlists/pl.f4d106fed2bd41149aaacabb233eb5eb") - } - - func testFetchMultipleCatalogPlaylistsByIDsEndpoint() async throws { - let ids = ["pl.f4d106fed2bd41149aaacabb233eb5eb"] - let endpoint = try await MusadoraLabsKit.catalogPlaylists(ids: ids, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/playlists?ids=pl.f4d106fed2bd41149aaacabb233eb5eb") - } - - // MARK: - Library Playlists Tests - func testFetchALibraryPlaylistByIDEndpoint() async throws { - let id = "p.ldvAAZ3C3Qmop9" - let endpoint = try await MusadoraLabsKit.libraryPlaylist(id: id) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/playlists/p.ldvAAZ3C3Qmop9") - } - - func testFetchMultipleLibraryPlaylistsByIDsEndpoint() async throws { - let ids = ["p.ldvAAZ3C3Qmop9"] - let endpoint = try await MusadoraLabsKit.libraryPlaylists(ids: ids) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/playlists?ids=p.ldvAAZ3C3Qmop9") - } - - func testFetchAllLibraryPlaylistsEndpoint() async throws { - let endpoint = try await MusadoraLabsKit.libraryPlaylists() - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/playlists") - } + // MARK: - Catalog Playlists Tests + + func testFetchACatalogPlaylistsByIDEndpoint() async throws { + let id = "pl.f4d106fed2bd41149aaacabb233eb5eb" + let endpoint = try await MusadoraLabsKit.catalogPlaylist(id: id, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/playlists/pl.f4d106fed2bd41149aaacabb233eb5eb") + } + + func testFetchMultipleCatalogPlaylistsByIDsEndpoint() async throws { + let ids = ["pl.f4d106fed2bd41149aaacabb233eb5eb"] + let endpoint = try await MusadoraLabsKit.catalogPlaylists(ids: ids, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/playlists?ids=pl.f4d106fed2bd41149aaacabb233eb5eb") + } + + // MARK: - Library Playlists Tests + + func testFetchALibraryPlaylistByIDEndpoint() async throws { + let id = "p.ldvAAZ3C3Qmop9" + let endpoint = try await MusadoraLabsKit.libraryPlaylist(id: id) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/playlists/p.ldvAAZ3C3Qmop9") + } + + func testFetchMultipleLibraryPlaylistsByIDsEndpoint() async throws { + let ids = ["p.ldvAAZ3C3Qmop9"] + let endpoint = try await MusadoraLabsKit.libraryPlaylists(ids: ids) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/playlists?ids=p.ldvAAZ3C3Qmop9") + } + + func testFetchAllLibraryPlaylistsEndpoint() async throws { + let endpoint = try await MusadoraLabsKit.libraryPlaylists() + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/playlists") + } } diff --git a/Tests/MusadoraLabsKitTests/SongsEndpointTests.swift b/Tests/MusadoraLabsKitTests/SongsEndpointTests.swift index 36773494f..45a877b91 100644 --- a/Tests/MusadoraLabsKitTests/SongsEndpointTests.swift +++ b/Tests/MusadoraLabsKitTests/SongsEndpointTests.swift @@ -5,44 +5,46 @@ // Created by Rudrank Riyam on 19/04/22. // -import XCTest @testable import MusadoraLabsKit +import XCTest class SongsEndpointTests: XCTestCase { - // MARK: - Catalog Songs Tests - func testFetchACatalogSongsByIDEndpoint() async throws { - let id = "1560735548" - let endpoint = try await MusadoraLabsKit.catalogSong(id: id, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/songs/1560735548") - } - - func testFetchMultipleCatalogSongsByIDsEndpoint() async throws { - let ids = ["1560735548", "1572278914"] - let endpoint = try await MusadoraLabsKit.catalogSongs(ids: ids, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/songs?ids=1560735548,1572278914") - } - - func testFetchMultipleCatalogSongsByISRCEndpoint() async throws { - let isrcs = ["USUM72105936"] - let endpoint = try await MusadoraLabsKit.catalogSongs(isrcs: isrcs, storeFront: "us") - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/songs?filter[isrc]=USUM72105936") - } - - // MARK: - Library Songs Tests - func testFetchALibrarySongByIDEndpoint() async throws { - let id = "i.gelNOzPuL41Lxo" - let endpoint = try await MusadoraLabsKit.librarySong(id: id) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/songs/i.gelNOzPuL41Lxo") - } - - func testFetchMultipleLibrarySongsByIDsEndpoint() async throws { - let ids = ["i.gelNOzPuL41Lxo"] - let endpoint = try await MusadoraLabsKit.librarySongs(ids: ids) - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/songs?ids=i.gelNOzPuL41Lxo") - } - - func testFetchAllLibraryArtistsEndpoint() async throws { - let endpoint = try await MusadoraLabsKit.librarySongs() - XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/songs") - } + // MARK: - Catalog Songs Tests + + func testFetchACatalogSongsByIDEndpoint() async throws { + let id = "1560735548" + let endpoint = try await MusadoraLabsKit.catalogSong(id: id, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/songs/1560735548") + } + + func testFetchMultipleCatalogSongsByIDsEndpoint() async throws { + let ids = ["1560735548", "1572278914"] + let endpoint = try await MusadoraLabsKit.catalogSongs(ids: ids, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/songs?ids=1560735548,1572278914") + } + + func testFetchMultipleCatalogSongsByISRCEndpoint() async throws { + let isrcs = ["USUM72105936"] + let endpoint = try await MusadoraLabsKit.catalogSongs(isrcs: isrcs, storeFront: "us") + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/catalog/us/songs?filter[isrc]=USUM72105936") + } + + // MARK: - Library Songs Tests + + func testFetchALibrarySongByIDEndpoint() async throws { + let id = "i.gelNOzPuL41Lxo" + let endpoint = try await MusadoraLabsKit.librarySong(id: id) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/songs/i.gelNOzPuL41Lxo") + } + + func testFetchMultipleLibrarySongsByIDsEndpoint() async throws { + let ids = ["i.gelNOzPuL41Lxo"] + let endpoint = try await MusadoraLabsKit.librarySongs(ids: ids) + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/songs?ids=i.gelNOzPuL41Lxo") + } + + func testFetchAllLibraryArtistsEndpoint() async throws { + let endpoint = try await MusadoraLabsKit.librarySongs() + XCTAssertEqualEndpoint(endpoint, "https://api.music.apple.com/v1/me/library/songs") + } } diff --git a/Tests/MusadoraLabsKitTests/XCTAssertEqualEndpoint.swift b/Tests/MusadoraLabsKitTests/XCTAssertEqualEndpoint.swift index ba0cdecde..86264ffa3 100644 --- a/Tests/MusadoraLabsKitTests/XCTAssertEqualEndpoint.swift +++ b/Tests/MusadoraLabsKitTests/XCTAssertEqualEndpoint.swift @@ -1,6 +1,6 @@ // // XCTAssertEqualEndpoint.swift -// +// // // Created by Rudrank Riyam on 19/04/22. // @@ -8,6 +8,6 @@ import XCTest public func XCTAssertEqualEndpoint(_ endpoint: URL, _ url: String) { - let url = URL(string: url)! - XCTAssertEqual(endpoint, url) + let url = URL(string: url)! + XCTAssertEqual(endpoint, url) }