Skip to content

Commit

Permalink
Fix tags management for API v9
Browse files Browse the repository at this point in the history
  • Loading branch information
pilulu committed Apr 22, 2024
1 parent 9f96d97 commit dc3fcdb
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions src/TogglApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,26 +661,23 @@ public function getProjects($options = [])
/**
* Get workspace tasks.
*
* @param int $wid
* @param array $options
*
* @return bool|mixed|object
*/
public function getWorkspaceTasks($wid, $options = [])
public function getWorkspaceTasks($options = [])
{
return $this->GET('workspaces/'.$wid.'/tasks', $options);
return $this->GET("workspaces/{$this->workspaceId}/tasks", $options);
}

/**
* Get workspace tags.
*
* @param int $wid
*
* @return bool|mixed|object
*/
public function getWorkspaceTags($wid)
public function getWorkspaceTags()
{
return $this->GET('workspaces/'.$wid.'/tags');
return $this->GET("workspaces/{$this->workspaceId}/tags");
}

/**
Expand Down Expand Up @@ -746,31 +743,28 @@ public function getWorkspaceUserRelations($wid)
/**
* Create tag.
*
* @param array $tag
* Tag has the following properties
* - name: The name of the tag (string, required, unique in workspace)
* - wid: workspace ID, where the tag will be used (integer, required)
* @param string $tagName
*
* @return bool|mixed|object
*
* @see https://github.com/toggl/toggl_api_docs/blob/master/chapters/tags.md
* @see https://engineering.toggl.com/docs/api/tags
*/
public function createTag($tag)
public function createTag($tagName)
{
return $this->POST('tags', ['tag' => $tag]);
return $this->POST("workspaces/{$this->workspaceId}/tags", $tagName);
}

/**
* Update tag.
*
* @param int $tagId
* @param array $tag
* @param string $tagName
*
* @return bool|mixed|object
*/
public function updateTag($tagId, $tag)
public function updateTag($tagId, $tagName)
{
return $this->PUT('tags/'.$tagId, ['tag' => $tag]);
return $this->PUT("workspaces/{$this->workspaceId}/tags/{$tagId}", $tagName);
}

/**
Expand All @@ -782,10 +776,10 @@ public function updateTag($tagId, $tag)
*/
public function deleteTag($tagId)
{
return $this->DELETE('tags/'.$tagId);
return $this->DELETE("workspaces/{$this->workspaceId}/tags/{$tagId}");
}

/* TAGS (https://github.com/toggl/toggl_api_docs/blob/master/chapters/tags.md)
/* TAGS (https://engineering.toggl.com/docs/api/tags)
Expand Down

0 comments on commit dc3fcdb

Please sign in to comment.