Skip to content

Commit

Permalink
Fixed a bug where the Spotify ids were not being sent in the correct …
Browse files Browse the repository at this point in the history
…format in the following methods (see #66):

    * `SpotifyAPI.saveAlbumsForCurrentUser` �
    * `SpotifyAPI.removeSavedAlbumsForCurrentUser`
    * `SpotifyAPI.saveEpisodesForCurrentUser`
    * `SpotifyAPI.removeSavedEpisodesForCurrentUser`
    * `SpotifyAPI.saveShowsForCurrentUser`
    * `SpotifyAPI.removeSavedShowsForCurrentUser`
    * `SpotifyAPI.saveTracksForCurrentUser`
    * `SpotifyAPI.removeSavedTracksForCurrentUser`
  • Loading branch information
Peter-Schorn committed Nov 23, 2024
1 parent daccfb0 commit 9f364b6
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
LastUpgradeVersion = "1610"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion .swiftpm/xcode/xcshareddata/xcschemes/SpotifyAPI.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
LastUpgradeVersion = "1610"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.4]

* Fixed a bug where the Spotify ids were not being sent in the correct format in the following methods (see [#66](https://github.com/Peter-Schorn/SpotifyAPI/issues/66)):
* `SpotifyAPI.saveAlbumsForCurrentUser`
* `SpotifyAPI.removeSavedAlbumsForCurrentUser`
* `SpotifyAPI.saveEpisodesForCurrentUser`
* `SpotifyAPI.removeSavedEpisodesForCurrentUser`
* `SpotifyAPI.saveShowsForCurrentUser`
* `SpotifyAPI.removeSavedShowsForCurrentUser`
* `SpotifyAPI.saveTracksForCurrentUser`
* `SpotifyAPI.removeSavedTracksForCurrentUser`


## [3.0.2] - 6-07-2024

* Fixed a bug that caused `extendPagesConcurrently` to only return the initial page of results
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if canImport(WebKit)
import Foundation
import SpotifyWebAPI
import WebKit
@preconcurrency import WebKit

/// Can open an authorization URL and click the accept or cancel dialog and
/// then return the redirect URI with the query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ extension AuthorizationCodeFlowPKCEBackendManager: _AuthorizationCodeFlowPKCEMan

}

extension ClientCredentialsFlowBackendManager: @retroactive Equatable {}
extension ClientCredentialsFlowBackendManager: _ClientCredentialsFlowManagerProtocol { }


12 changes: 8 additions & 4 deletions Sources/SpotifyWebAPI/API/SpotifyAPI+Library.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private extension SpotifyAPI where
queryItems: [:],
httpMethod: "PUT",
makeHeaders: Headers.bearerAuthorizationAndContentTypeJSON(_:),
body: ids,
body: ["ids": ids],
requiredScopes: [.userLibraryModify]
)

Expand Down Expand Up @@ -105,7 +105,7 @@ private extension SpotifyAPI where
],
httpMethod: "DELETE",
makeHeaders: Headers.bearerAuthorizationAndContentTypeJSON(_:),
body: ids,
body: ["ids": ids],
requiredScopes: [.userLibraryModify]
)

Expand Down Expand Up @@ -667,7 +667,10 @@ public extension SpotifyAPI where
) -> AnyPublisher<Void, Error> {

return self.saveItemsForCurrentUser(
uris: uris, types: [.show], path: "/me/shows"
uris: uris,
types: [.show],
path: "/me/shows",
idsInBody: false
)

}
Expand Down Expand Up @@ -816,7 +819,8 @@ public extension SpotifyAPI where
uris: uris,
types: [.show],
path: "/me/shows",
market: market
market: market,
idsInBody: false
)

}
Expand Down
34 changes: 34 additions & 0 deletions Tests/SpotifyAPIMainTests/API Tests/SpotifyAPIAlbumsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,40 @@ extension SpotifyAPIAlbumsTests {

}

func trackLink() {

func receiveTrackLink(_ album: Album) {
encodeDecode(album)

XCTAssertEqual(album.name, "")
}

let hrefString = """
https://api.spotify.com/v1/albums/2zffBP6FVUDZ3dsKodfQi6
"""

let href = URL(string: hrefString)!

let expectation = XCTestExpectation(
description: "testTrackLink"
)

Self.spotify.getFromHref(href, responseType: Album.self)
.assertNoFailure()
.receiveOnMain()
.sink(
receiveCompletion: { _ in expectation.fulfill() },
receiveValue: receiveTrackLink(_:)
)
.store(in: &Self.cancellables)

self.wait(
for: [expectation],
timeout: 60
)

}

func receiveAlbumTracksPage1(_ page: PagingObject<Track>) {
print("begin receiveAlbumTracksPage1")

Expand Down

0 comments on commit 9f364b6

Please sign in to comment.