Skip to content

Commit

Permalink
add result api
Browse files Browse the repository at this point in the history
  • Loading branch information
Seretos committed Oct 5, 2018
1 parent 5b68dec commit 259e8de
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 50 deletions.
21 changes: 10 additions & 11 deletions src/api/Configurations.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

class Configurations extends AbstractApi
{
private $cache = null;

private $cache = [];
public function all(int $projectId)
{
if($this->cache === null) {
$this->cache = $this->connector->send_get('get_configs/'.$this->encodePath($projectId));
if(!isset($this->cache[$projectId])) {
$this->cache[$projectId] = $this->connector->send_get('get_configs/' . $this->encodePath($projectId));
}
return $this->cache;
return $this->cache[$projectId];
}

public function findByGroupName(int $projectId, string $name){
Expand Down Expand Up @@ -49,37 +48,37 @@ public function createGroup(int $projectId, string $name)
{
$group = $this->connector->send_post('add_config_group/'.$this->encodePath($projectId),
['name' => $name]);
$this->cache = null;
unset($this->cache[$projectId]);
return $group;
}

public function updateGroup(int $groupId, string $name){
$group = $this->connector->send_post('update_config_group/'.$this->encodePath($groupId),['name' => $name]);
$this->cache = null;
$this->cache = [];
return $group;
}

public function deleteGroup(int $groupId){
$this->connector->send_post('delete_config_group/'.$this->encodePath($groupId),[]);
$this->cache = null;
$this->cache = [];
}

public function create(int $groupId, string $name)
{
$config = $this->connector->send_post('add_config/'.$this->encodePath($groupId),
['name' => $name]);
$this->cache = null;
$this->cache = [];
return $config;
}

public function update(int $configId, string $name){
$this->connector->send_post('update_config/'.$this->encodePath($configId),
['name' => $name]);
$this->cache = null;
$this->cache = [];
}

public function delete(int $configId){
$this->connector->send_post('delete_config/'.$this->encodePath($configId),[]);
$this->cache = null;
$this->cache = [];
}
}
17 changes: 8 additions & 9 deletions src/api/Milestones.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

class Milestones extends AbstractApi
{
private $cache = null;

private $cache = [];
public function all(int $projectId)
{
if($this->cache === null) {
$this->cache = $this->connector->send_get('get_milestones/'.$this->encodePath($projectId));
if(!isset($this->cache[$projectId])) {
$this->cache[$projectId] = $this->connector->send_get('get_milestones/' . $this->encodePath($projectId));
}
return $this->cache;
return $this->cache[$projectId];
}

public function get(int $milestoneId)
Expand Down Expand Up @@ -46,7 +45,7 @@ public function create(int $projectId, string $name, string $description = null,
['name' => $name,
'description' => $description,
'due_on' => $dueOn->getTimestamp()]);
$this->cache = null;
unset($this->cache[$projectId]);
return $milestone;
}

Expand All @@ -56,17 +55,17 @@ public function create(int $projectId, string $name, string $description = null,
* @var bool $is_completed
* @var bool $is_started
* @var int $parent_id
* @var timestamp $start_on
* @var int $start_on
* }
*/
public function update(int $milestoneId, array $parameters = []){
$milestone = $this->connector->send_post('update_milestone/'.$this->encodePath($milestoneId),$parameters);
$this->cache = null;
$this->cache = [];
return $milestone;
}

public function delete(int $milestoneId){
$this->connector->send_post('delete_milestone/'.$this->encodePath($milestoneId),[]);
$this->cache = null;
$this->cache = [];
}
}
23 changes: 11 additions & 12 deletions src/api/Plans.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

class Plans extends AbstractApi
{
private $cache = null;

private $cache = [];
public function all(int $projectId)
{
if($this->cache === null) {
$this->cache = $this->connector->send_get('get_plans/'.$this->encodePath($projectId));
if(!isset($this->cache[$projectId])) {
$this->cache[$projectId] = $this->connector->send_get('get_plans/' . $this->encodePath($projectId));
}
return $this->cache;
return $this->cache[$projectId];
}

public function get(int $planId)
Expand All @@ -43,14 +42,14 @@ public function create(int $projectId, string $name, string $description = null,
['name' => $name,
'description' => $description,
'milestone_id' => $milestoneId]);
$this->cache = null;
unset($this->cache[$projectId]);
return $plan;
}

public function createEntry(int $planId, int $suiteId, string $name, array $configIds = [], array $runs = [], string $description = null, bool $all = true, array $cases = []){
$entry = $this->connector->send_post('add_plan_entry/'.$this->encodePath($planId),
['suite_id' => $suiteId,'name' => $name, 'description' => $description, 'include_all' => $all, 'case_ids' => $cases, 'config_ids' => $configIds, 'runs' => $runs]);
$this->cache = null;
$this->cache = [];
return $entry;
}

Expand All @@ -64,29 +63,29 @@ public function createEntry(int $planId, int $suiteId, string $name, array $conf
*/
public function update(int $planId, array $parameters = []){
$plan = $this->connector->send_post('update_plan/'.$this->encodePath($planId),$parameters);
$this->cache = null;
$this->cache = [];
return $plan;
}

public function updateEntry(int $planId, int $entryId, array $parameters = []){
$entry = $this->connector->send_post('update_plan_entry/'.$this->encodePath($planId).'/'.$this->encodePath($entryId),$parameters);
$this->cache = null;
$this->cache = [];
return $entry;
}

public function delete(int $planId){
$this->connector->send_post('delete_plan/'.$this->encodePath($planId),[]);
$this->cache = null;
$this->cache = [];
}

public function deleteEntry(int $planId, int $entryId){
$this->connector->send_post('delete_plan_entry/'.$this->encodePath($planId).'/'.$this->encodePath($entryId),[]);
$this->cache = null;
$this->cache = [];
}

public function close(int $planId){
$plan = $this->connector->send_post('close_plan/'.$this->encodePath($planId),[]);
$this->cache = null;
$this->cache = [];
return $plan;
}
}
2 changes: 1 addition & 1 deletion src/api/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Projects extends AbstractApi
public function all()
{
if($this->cache === null) {
$this->cache = $this->connector->send_get('get_projects');
$this->cache = $this->connector->send_get('get_projects');
}
return $this->cache;
}
Expand Down
14 changes: 7 additions & 7 deletions src/api/Sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

class Sections extends AbstractApi
{
private $cache = null;
private $cache = [];
public function all(int $projectId, int $suiteId)
{
if($this->cache === null) {
$this->cache = $this->connector->send_get('get_sections/' . $this->encodePath($projectId) . '&suite_id=' . $this->encodePath($suiteId));
if(!isset($this->cache[$projectId][$suiteId])) {
$this->cache[$projectId][$suiteId] = $this->connector->send_get('get_sections/' . $this->encodePath($projectId) . '&suite_id=' . $this->encodePath($suiteId));
}
return $this->cache;
return $this->cache[$projectId][$suiteId];
}

public function get(int $sectionId)
Expand Down Expand Up @@ -54,7 +54,7 @@ public function create(int $projectId, int $suiteId, string $name, string $descr
'description' => $description,
'suite_id' => $suiteId,
'parent_id' => $parent_id]);
$this->cache = null;
unset($this->cache[$projectId][$suiteId]);
return $section;
}

Expand All @@ -68,12 +68,12 @@ public function create(int $projectId, int $suiteId, string $name, string $descr
*/
public function update(int $sectionId, array $parameters = []){
$section = $this->connector->send_post('update_section/'.$this->encodePath($sectionId),$parameters);
$this->cache = null;
$this->cache = [];
return $section;
}

public function delete(int $sectionId){
$this->connector->send_post('delete_section/'.$this->encodePath($sectionId),[]);
$this->cache = null;
$this->cache = [];
}
}
1 change: 0 additions & 1 deletion src/api/Statuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
class Statuses extends AbstractApi
{
private $cache = null;

public function all()
{
if($this->cache === null) {
Expand Down
15 changes: 7 additions & 8 deletions src/api/Suites.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@

class Suites extends AbstractApi
{
private $cache = null;

private $cache = [];
public function all(int $projectId)
{
if($this->cache === null) {
$this->cache = $this->connector->send_get('get_suites/' . $this->encodePath($projectId));
if(!isset($this->cache[$projectId])) {
$this->cache[$projectId] = $this->connector->send_get('get_suites/' . $this->encodePath($projectId));
}
return $this->cache;
return $this->cache[$projectId];
}

public function get(int $suiteId)
Expand All @@ -42,7 +41,7 @@ public function create(int $projectId, string $name, string $description = null)
$suite = $this->connector->send_post('add_suite/'.$this->encodePath($projectId),
['name' => $name,
'description' => $description]);
$this->cache = null;
unset($this->cache[$projectId]);
return $suite;
}

Expand All @@ -56,12 +55,12 @@ public function create(int $projectId, string $name, string $description = null)
*/
public function update(int $suiteId, array $parameters = []){
$suite = $this->connector->send_post('update_suite/'.$this->encodePath($suiteId),$parameters);
$this->cache = null;
$this->cache = [];
return $suite;
}

public function delete(int $suiteId){
$this->connector->send_post('delete_suite/'.$this->encodePath($suiteId),[]);
$this->cache = null;
$this->cache = [];
}
}
2 changes: 1 addition & 1 deletion src/api/Types.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Types extends AbstractApi
public function all()
{
if($this->cache === null) {
$this->cache = $this->connector->send_get('get_case_types');
$this->cache = $this->connector->send_get('get_case_types');
}
return $this->cache;
}
Expand Down

0 comments on commit 259e8de

Please sign in to comment.