update getTime functions to support upstream since/before args

This commit is contained in:
James 2020-02-02 15:09:10 +00:00
parent b8a7da7a79
commit 83eea50cf9
2 changed files with 38 additions and 2 deletions

View File

@ -63,4 +63,20 @@ class Client{
$data=$this->request($url,'GET'); $data=$this->request($url,'GET');
return $data->data[0]; return $data->data[0];
} }
public function getCurrentUserTimes(\DateTime $since=null, \DateTime $before=null){
$args=[];
if($before){
$args['before'] = $before->format('c');
}
if($since){
$args['since'] = $since->format('c');
}
$url="{$this->url}user/times";
if($args){
$url.='?'.http_build_query($args);
}
$data=$this->request($url,'GET');
return $data;
}
} }

View File

@ -122,13 +122,33 @@ class Repo{
return $data; return $data;
} }
public function getTimes(){ public function getTimes(\DateTime $since=null, \DateTime $before=null){
$args=[];
if($before){
$args['before'] = $before->format('c');
}
if($since){
$args['since'] = $since->format('c');
}
$url="repos/{$this->user}/{$this->repo}/times"; $url="repos/{$this->user}/{$this->repo}/times";
if($args){
$url.='?'.http_build_query($args);
}
return $this->client->request($url,'GET'); return $this->client->request($url,'GET');
} }
public function getTimesByUsername($username){ public function getTimesByUsername($username,\DateTime $since=null, \DateTime $before=null){
$args=[];
if($before){
$args['before'] = $before->format('c');
}
if($since){
$args['since'] = $since->format('c');
}
$url="repos/{$this->user}/{$this->repo}/times/{$username}"; $url="repos/{$this->user}/{$this->repo}/times/{$username}";
if($args){
$url.='?'.http_build_query($args);
}
return $this->client->request($url,'GET'); return $this->client->request($url,'GET');
} }