You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As an experiment I was trying to extend TanukiKit to get the builds for a project, the API structure for it is as follows:
All builds from project: /projects/(the id of the project)/builds
This gets a JSON array with all the builds, pretty similar to getting the project list. Example response:
- To get a specific build from the project:
`/projects/(the id of the project)/builds/(the id of the specific build)`
This gets a JSON with the info from the build. Example response:
Due to the similar response to a projects get, I tried to adapt it to get the builds, here is the code I have tried:
import Foundation
import RequestKit
@objcpublicclassapiBuildClass:NSObject{publicletid:Intpublicletuser:apiUserClasspublicvarstatus:String?publicvarstage:String?publicvarref:String?publicvartag:Bool?publicvarcoverage:Double?publicvarcreatedAt:String?publicvarstartedAt:String?publicvarfinishedAt:String?publicinit(_ json:[String:AnyObject]){
user =apiUserClass(json["user"]as?[String:AnyObject]??[:])iflet id =json["id"]as?Int{self.id = id
status =json["status"]as?String
stage =json["stage"]as?String
ref =json["ref"]as?String
tag =json["tag"]as?Bool
coverage =json["coverage"]as?Double
createdAt =json["created_at"]as?String
startedAt =json["started_at"]as?String
finishedAt =json["finished_at"]as?String}else{
id =-1}}}publicextensionTanukiKit{
/**
Fetches the Builds for the specified Project
- parameter Project: The Project to get the builds from.
- parameter Build: The specific build to get, if nil, gives a list of all the builds available.
- parameter completion: Callback for the outcome of the fetch.
*/
publicfunc builds(project:String, build:String, completion:(response:Response<[apiBuildClass]>)->Void){letrouter=BuildRouter.ReadProjectBuilds(configuration, project, build)
router.loadJSON([[String:AnyObject]].self){ json, error iniflet error = error {completion(response:Response.Failure(error))}iflet json = json {letrepos= json.map{apiBuildClass($0)}completion(response:Response.Success(repos))}}}}
// MARK: Router
enumBuildRouter:Router{case ReadProjectBuilds(Configuration,String,String)varconfiguration:Configuration{switchself{case.ReadProjectBuilds(let config, _, _):return config
}}varmethod:HTTPMethod{return.GET
}varencoding:HTTPEncoding{return.URL
}varparams:[String:String]{switchself{case.ReadProjectBuilds(_,let project,let build):return["project": project,"build": build]}}varpath:String{switchself{case.ReadProjectBuilds:return"/projects/\(params["project"])/builds/\(params["build"])"}}}
Everything builds and compiles perfectly, the public function builds is recognised but nothing outputs when I run it, not even the error. Can you give me hand on this @pietbrauer?
Thanks!
The text was updated successfully, but these errors were encountered:
As an experiment I was trying to extend TanukiKit to get the builds for a project, the API structure for it is as follows:
/projects/(the id of the project)/builds
This gets a JSON array with all the builds, pretty similar to getting the project list. Example response:

- To get a specific build from the project: `/projects/(the id of the project)/builds/(the id of the specific build)` This gets a JSON with the info from the build. Example response:Due to the similar response to a projects get, I tried to adapt it to get the builds, here is the code I have tried:
And this should work by calling it using:
Everything builds and compiles perfectly, the public function
builds
is recognised but nothing outputs when I run it, not even the error. Can you give me hand on this @pietbrauer?Thanks!
The text was updated successfully, but these errors were encountered: