Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOME-1780: added roles endpoint #36

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Api/Endpoints/PermissionTemplates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Lokalise\Endpoints;

use Lokalise\Exceptions\LokaliseApiException;
use Lokalise\Exceptions\LokaliseResponseException;
use Lokalise\LokaliseApiResponse;

/**
* Class PermissionTemplates
* @package Lokalise\Endpoints]
* @link https://app.lokalise.com/api2docs/curl/#resource-permission-templates
*/
class PermissionTemplates extends Endpoint
{

/**
* @link https://app.lokalise.com/api2docs/curl/#transition-list-permission-templates-get
*
* @param array $queryParams
*
* @return LokaliseApiResponse
*
* @throws LokaliseApiException
* @throws LokaliseResponseException
*/
public function list(int $teamId): LokaliseApiResponse
{
return $this->request(
'GET',
"teams/$teamId/roles",
[]
);
}
}
49 changes: 49 additions & 0 deletions Tests/Endpoints/PermissionTemplatesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/** @noinspection PhpUnhandledExceptionInspection */

namespace Lokalise\Tests\Endpoints;

use Lokalise\Endpoints\Endpoint;
use Lokalise\Endpoints\EndpointInterface;
use Lokalise\Endpoints\PermissionTemplates;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

final class PermissionTemplatesTest extends TestCase
{
use MockEndpointTrait;

/** @var MockObject|PermissionTemplates */
private $mockedPermisionTemplates;

protected function setUp(): void
{
$this->mockedPermisionTemplates = $this->createEndpointMock(PermissionTemplates::class);
}

protected function tearDown(): void
{
$this->mockedPermisionTemplates = null;
}

public function testEndpointClass(): void
{
self::assertInstanceOf(Endpoint::class, $this->mockedPermisionTemplates);
self::assertInstanceOf(EndpointInterface::class, $this->mockedPermisionTemplates);
}

public function testList(): void
{
$teamId = '1';

self::assertEquals(
[
'requestType' => 'GET',
'uri' => "teams/$teamId/roles",
'queryParams' => [],
'body' => [],
],
$this->mockedPermisionTemplates->list($teamId)->getContent()
);
}
}
Loading