HutigKit是ProductHutAPI封装器。
使用示例:
开始之前,先让你的app取得授权证书。
let autheticatioRequest = ProductHut.Edpoit.ClietToke(id: "your-clietId", secret: "your-clietSecret")ProductHut.sedRequest(autheticatioRequest) { respose i switch respose { case .Success(let box): // At this poit HutigKit has stored the credetials i your keychai, you are free to use ay other edpoit available. You also have access to the `AccessToke` yourself. case .Failure(let box): // Hadle your errors }}得到权限后,就可以获取今天的所有产品。
let request = ProductHut.Edpoit.Posts(from: .Today)ProductHut.sedRequest(request) { [uowed self] respose i switch respose { case .Success(let box): // By ow you have the array of Posts (products) available to you case .Failure(let box): // Hadle your errors }}










评论