zendesk / zendesk/zendesk_api_client_php
Cannot get articles in specified category
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 344
- Forks
- 247
- Avg merge
- 27m
- Merged PRs (30d)
- 1
Description
The API docs indicate you should be able to GET /api/v2/help_center/categories/{category_id}/articles however I can't find a way to do this in this library. I would expect to find it in $zendeskHttpClient->helpCenter->categories($category_id)->articles()->iterator() but that doesn't exist. I tried $zendeskHttpClient->helpCenter->categories($category_id)->sections()->articles()->iterator() which gives all articles.
I think Zendesk\API\Resources\HelpCenter\Articles needs to be updated with something like (I tried it and it seems to work in my case, but I don't know what I'm missing)
public function getRoute($name, array $params = [])
{
$lastChained = $this->getLatestChainedParameter();
$params = $this->addChainedParametersToParams($params, [
'section_id' => Sections::class,
]);
if (empty($lastChained) || $name !== 'findAll') {
return $this->localesGetRoute($name, $params);
} else {
$chainedResourceName = array_keys($lastChained)[0];
$id = $lastChained[$chainedResourceName];
if ($chainedResourceName === Sections::class) {
$locales = $this->getLocale();
if ($locales) {
return "{$this->prefix}{$locales}/sections/$id/articles.json";
} else {
return "{$this->prefix}sections/$id/articles.json";
}
// This block is added:
} elseif ($chainedResourceName === Categories::class) {
$locales = $this->getLocale();
if ($locales) {
return "{$this->prefix}{$locales}/categories/$id/articles.json";
} else {
return "{$this->prefix}categories/$id/articles.json";
}
} else {
return $this->localesGetRoute($name, $params);
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Zendesk\API\Resources\HelpCenter\Articles::getRoute and compare the existing section-scoped article route with the category chain described in the issue. Verify that the category iterator requests the category-specific articles endpoint and returns only that category's articles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100