目录
目录README.md

FanboyKit

Search iTunes with FanboyKit. This Swift package provides a client for fanboy-http, a caching proxy for the iTunes Search API. FanboyKit is used in the Podest podcast app.

Example

Querying for suggestions matching the term "crook" limiting the result to 10.

import Foundation
import Patron
import FanboyKit

let url = URL(string: "https://your.endpoint")!
let s = URLSession(configuration: .default)
let p = Patron(URL: url, session: s)
let svc = Fanboy(client: p)

try! svc.suggestions(matching: "crook", limit: 10) { result, error in
  print(error ?? result)
}

Please refer to fanboy-http for details.

Types

FanboyError

enum FanboyError: Error {
  case unexpectedResult(result: AnyObject?)
  case cancelledByUser
  case invalidTerm
}

FanboyService

protocol FanboyService {
  var client: JSONService { get }

  @discardableResult func version(
    completionHandler cb: @escaping (_ version: String?, Error?) -> Void
  ) -> URLSessionTask

  @discardableResult func search(
    term: String,
    completionHandler cb: @escaping (
      _ podcasts: [[String : AnyObject]]?, _ error: Error?) -> Void
  ) throws -> URLSessionTask

  @discardableResult func lookup(
    guids: [String],
    completionHandler cb: @escaping (
      _ podcasts: [[String : AnyObject]]?, _ error: Error?) -> Void
  ) -> URLSessionTask

  @discardableResult func suggestions(
    matching: String,
    limit: Int,
    completionHandler cb: @escaping (
      _ terms: [String]?, _ error: Error?) -> Void
  ) throws -> URLSessionTask
}

client

var client: JSONService { get }

The client property of the FanboyService object gives access to the underlying Patron client, providing hostname and status of the remote service.

Test

With fanboy-http running, do:

$ swift test

Install

📦 Add https://github.com/michaelnisi/fanboy-kit to your package manifest.

License

MIT License

关于
82.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号