Skip to content

Commit

Permalink
add category trait
Browse files Browse the repository at this point in the history
  • Loading branch information
hadian90 committed Aug 22, 2019
1 parent d21d5e8 commit c1fb12b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private function setupResources()

//Solution
$this->solution = new Solution($this);
$this->folder = new Folder($this);
$this->folders = new Folder($this);

//Admin
$this->products = new Product($this);
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Freshdesk\Resources;

use Freshdesk\Resources\Traits\AllTrait;
use Freshdesk\Resources\Traits\CategoryTrait;
use Freshdesk\Resources\Traits\DeleteTrait;
use Freshdesk\Resources\Traits\UpdateTrait;
use Freshdesk\Resources\Traits\ViewTrait;
Expand All @@ -17,7 +17,7 @@
class Folder extends AbstractResource
{

use AllTrait, ViewTrait, UpdateTrait, DeleteTrait;
use CategoryTrait, ViewTrait, UpdateTrait, DeleteTrait;

/**
* The resource endpoint
Expand All @@ -37,7 +37,7 @@ class Folder extends AbstractResource
protected $categoryEndpoint = '/solutions/categories';

/**
* Creates the category endpoint (for creating forums)
* Creates the category endpoint (for creating folders)
*
* @param integer $id
* @return string
Expand Down
46 changes: 46 additions & 0 deletions src/Resources/Traits/CategoryTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Freshdesk\Resources\Traits;

/**
* View Trait
*
* @package Freshdesk\Resources\Traits
*
*/
trait CategoryTrait
{

/**
* @return \Freshdesk\Api
* @internal
*/
abstract protected function api();

/**
* View a resource
*
* Use 'include' to embed additional details in the response. Each include will consume an additional credit.
* For example if you embed the requester and company information you will be charged a total of 3 API credits for the call.
* See Freshdesk's documentation for details.
*
* @api
* @param int $id The resource id
* @param array|null $query
* @return array|null
* @throws \Freshdesk\Exceptions\AccessDeniedException
* @throws \Freshdesk\Exceptions\ApiException
* @throws \Freshdesk\Exceptions\AuthenticationException
* @throws \Freshdesk\Exceptions\ConflictingStateException
* @throws \Freshdesk\Exceptions\NotFoundException
* @throws \Freshdesk\Exceptions\RateLimitExceededException
* @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
* @throws \Freshdesk\Exceptions\MethodNotAllowedException
* @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
* @throws \Freshdesk\Exceptions\ValidationException
*/
public function forCategory($id, array $query = null)
{
return $this->api()->request('GET', $this->categoryEndpoint($id) . $this->endpoint, null, $query);
}
}

0 comments on commit c1fb12b

Please sign in to comment.