Skip to content

Commit

Permalink
Merge pull request #61 from packagist/synchronizations-endpoint
Browse files Browse the repository at this point in the history
API: add list synchronizations endpoint
  • Loading branch information
zanbaldwin authored Feb 2, 2023
2 parents c3516f0 + cbfc578 commit a943d30
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Api/Synchronizations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace PrivatePackagist\ApiClient\Api;

class Synchronizations extends AbstractApi
{
public function all()
{
return $this->get('/synchronizations/');
}
}
5 changes: 5 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public function tokens()
return new Api\Tokens($this, $this->responseMediator);
}

public function synchronizations()
{
return new Api\Synchronizations($this, $this->responseMediator);
}

public function getHttpClient()
{
return $this->getHttpClientBuilder()->getHttpClient();
Expand Down
42 changes: 42 additions & 0 deletions tests/Api/SynchronizationsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php declare(strict_types=1);

namespace PrivatePackagist\ApiClient\Api;

use PHPUnit\Framework\MockObject\MockObject;

class SynchronizationsTest extends ApiTestCase
{
public function testAll()
{
$expected = [
[
"id" => 42,
"name" => "Acme Organization",
"isPrimary" => true,
"integration" => [
"name" => "GitHub",
"target" => "github",
"url" => "https://github.com"
],
"credentials" => 432,
]
];

/** @var Synchronizations&MockObject $api */
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with($this->equalTo('/synchronizations/'))
->willReturn($expected);

$this->assertSame($expected, $api->all());
}

/**
* @return string
*/
protected function getApiClass()
{
return Synchronizations::class;
}
}

0 comments on commit a943d30

Please sign in to comment.