https://github.com/starhoshi/lastfmclient
A Swifty last.fm api client using Codable.
https://github.com/starhoshi/lastfmclient
codable ios lastfm lastfm-api swift
Last synced: 9 months ago
JSON representation
A Swifty last.fm api client using Codable.
- Host: GitHub
- URL: https://github.com/starhoshi/lastfmclient
- Owner: starhoshi
- License: mit
- Created: 2018-02-17T04:41:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-06T14:54:37.000Z (over 8 years ago)
- Last Synced: 2025-02-20T02:37:12.897Z (over 1 year ago)
- Topics: codable, ios, lastfm, lastfm-api, swift
- Language: Swift
- Homepage:
- Size: 85 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LastfmClient
A Swifty last.fm api client using Codable.
Lastfm's API is not very good. Nested Dictionary, Nonexistent key, etc.
If you use LastfmClient, you can handle last.fm api type-safely and Swifty.
# TODO
* [ ] User
* [x] user.getTopTracks
* [x] user.getRecentTracks
* [x] user.getInfo
* [ ] ...
* [ ] Track
* [ ] Tag
* [ ] Library
* [ ] Geo
* [ ] Chart
* [ ] Auth
* [ ] Artist
* [ ] Album
# Installation
```
pod install LastfmClient
```
# Usage
```swift
import LastfmClient
Configuration.shared.configure(apiKey: "YOUR_LASTFM_API_KEY")
let user = UserAPI(user: "star__hoshi")
user.getInfo { result in
switch result {
case .success(let user):
XCTAssertEqual(user.name, "star__hoshi")
case .failure(let error):
XCTFail("\(error)")
}
}
```
# Test
1. Get your lastfm api key from [here](https://www.last.fm/api/account/create).
2. Add `TestConfiguration.swift` to LastfmClientTests.
* Please copy `TestConfiguration.sample.swift` and use it.
* Set lastfm api key.
3. Run tests!