refactor: separated GitRepo types into own module

feat: added more query params for GitRepo API
This commit is contained in:
Jef Roosens 2022-05-19 07:54:33 +02:00
parent 5e81dadce3
commit 6bd5b7cb48
Signed by untrusted user: Jef Roosens
GPG key ID: B580B976584B5F30
12 changed files with 114 additions and 122 deletions

View file

@ -29,7 +29,10 @@ fn (c &Client) send_request_raw(method Method, url string, params map[string]str
// Escape each query param
for k, v in params {
params_escaped[k] = urllib.query_escape(v)
// An empty parameter should be the same as not providing it at all
if v != '' {
params_escaped[k] = urllib.query_escape(v)
}
}
params_str := params_escaped.keys().map('$it=${params[it]}').join('&')

View file

@ -1,13 +1,12 @@
module client
import db { GitRepo, GitRepoFilter }
import models { GitRepo, GitRepoFilter }
import net.http { Method }
import response { Response }
import util
// get_git_repos returns the current list of repos.
pub fn (c &Client) get_git_repos(filter GitRepoFilter) ?[]GitRepo {
params := util.struct_to_map(filter)
params := models.params_from(filter)
data := c.send_request<[]GitRepo>(Method.get, '/api/repos', params)?
return data.data