-
-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71fec50
commit f4e822e
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Github\Api\Copilot; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
class Usage extends AbstractApi | ||
{ | ||
public function orgUsageSummary(string $organization, array $params = []): array | ||
{ | ||
return $this->get('/orgs/' . rawurlencode($organization) . '/copilot/usage', $params); | ||
} | ||
|
||
public function orgTeamUsageSummary(string $organization, string $teamSlug, array $params = []): array | ||
{ | ||
return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($teamSlug) . '/copilot/usage', $params); | ||
} | ||
|
||
public function enterpriseUsageSummary(string $enterprise, array $params = []): array | ||
{ | ||
return $this->get('/enterprises/' . rawurlencode($enterprise) . '/copilot/usage', $params); | ||
} | ||
|
||
public function enterpriseTeamUsageSummary(string $enterprise, string $teamSlug, array $params = []): array | ||
{ | ||
return $this->get('/enterprises/' . rawurlencode($enterprise) . '/teams/' . rawurlencode($teamSlug) . '/copilot/usage', $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Github\Tests\Api\Copilot; | ||
|
||
use Github\Api\Copilot\Usage; | ||
use Github\Tests\Api\TestCase; | ||
|
||
class UsageTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldGetOrgUsageSummary(): void | ||
{ | ||
$expectedValue = ['usage1', 'usage2']; | ||
|
||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('/orgs/KnpLabs/copilot/usage', []) | ||
->will($this->returnValue($expectedValue)); | ||
|
||
$this->assertEquals($expectedValue, $api->orgUsageSummary('KnpLabs')); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetOrgTeamUsageSummary(): void | ||
{ | ||
$expectedValue = ['usage1', 'usage2']; | ||
|
||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('/orgs/KnpLabs/teams/php-github-api/copilot/usage', []) | ||
->will($this->returnValue($expectedValue)); | ||
|
||
$this->assertEquals($expectedValue, $api->orgTeamUsageSummary('KnpLabs', 'php-github-api')); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetEnterpriseUsageSummary(): void | ||
{ | ||
$expectedValue = ['usage1', 'usage2']; | ||
|
||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('/enterprises/KnpLabs/copilot/usage', []) | ||
->will($this->returnValue($expectedValue)); | ||
|
||
$this->assertEquals($expectedValue, $api->enterpriseUsageSummary('KnpLabs')); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetEnterpriseTeamUsageSummary(): void | ||
{ | ||
$expectedValue = ['usage1', 'usage2']; | ||
|
||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('/enterprises/KnpLabs/teams/php-github-api/copilot/usage', []) | ||
->will($this->returnValue($expectedValue)); | ||
|
||
$this->assertEquals($expectedValue, $api->enterpriseTeamUsageSummary('KnpLabs', 'php-github-api')); | ||
} | ||
|
||
protected function getApiClass(): string | ||
{ | ||
return Usage::class; | ||
} | ||
} |