MOYA和p2 / oauth2快速币库集成

时间:2018-08-07 13:25:27

标签: swift oauth-2.0 coinbase-api moya

我的poauth2正在与服务器连接。现在,我需要发出API请求,并尝试关注Moya文档等。这是到目前为止的内容:

        let requestClosure = { (endpoint: Endpoint, done:@escaping (Result<URLRequest,MoyaError>) -> ()) in
        let request = try! self.appDelegate.oauth2.request(forURL: endpoint.urlRequest().url!)

        // set up your request, e.g. `req.HTTPMethod = "POST"`
        let task = self.appDelegate.oauth2.session.dataTask(with: request) { (data, response, error) -> Void in
            DispatchQueue.main.async(execute: { () -> Void in
                if error == nil {
                    result(data as NSData?, nil)
                    done(result)
                } else {
                    result(nil, error as NSError?)
                }
            })
        }.resume()
    }


    let cbProvider = MoyaProvider<CoinbaseService>(requestClosure: requestClosure)

此行给出了编译错误:

       let requestClosure = { (endpoint: Endpoint, done:@escaping (Result<URLRequest,MoyaError>) -> ()) in

Generic type 'Result' specialized with too many type parameters (got 2, but expected 1)

但是,如果我删除第二个参数,则此行将无法编译:

MoyaProvider<CoinbaseService>(requestClosure: requestClosure)

这里的任何帮助都会很棒。

0 个答案:

没有答案