update getTime functions to support upstream since/before args
This commit is contained in:
parent
b8a7da7a79
commit
83eea50cf9
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
24
src/Repo.php
24
src/Repo.php
@ -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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user