Skip to content

Commit 0a55973

Browse files
authored
Merge pull request #6 from packagist/t/jobs-api
Jobs: add show call
2 parents 9ecd491 + 44430d5 commit 0a55973

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

Diff for: README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ Full documentation can be found in the [Private Packagist documentation](https:/
3838

3939
##### Trigger a full synchronization
4040
```php
41-
$client->organization()->sync();
41+
$jobs = $client->organization()->sync();
4242
```
43+
Returns an array of created jobs. One for every synchronization.
4344

4445
#### Customer
4546

@@ -116,6 +117,14 @@ $packages = $client->packages()->all($filters);
116117
```
117118
Returns an array of packages.
118119

120+
#### Job
121+
122+
##### Show a job
123+
```php
124+
$job = $client->jobs()->show($jobId);
125+
```
126+
Returns the job.
127+
119128
## License
120129

121130
`private-packagist/api-client` is licensed under the MIT License

Diff for: src/Api/Jobs.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace PrivatePackagist\ApiClient\Api;
4+
5+
class Jobs extends AbstractApi
6+
{
7+
public function show($jobId)
8+
{
9+
return $this->get(sprintf('/jobs/%s', $jobId));
10+
}
11+
}

Diff for: src/Client.php

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public function packages()
5858
return new Api\Packages($this, $this->responseMediator);
5959
}
6060

61+
public function jobs()
62+
{
63+
return new Api\Jobs($this, $this->responseMediator);
64+
}
65+
6166
public function getHttpClient()
6267
{
6368
return $this->getHttpClientBuilder()->getHttpClient();

Diff for: tests/Api/JobsTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace PrivatePackagist\ApiClient\Api;
4+
5+
class JobsTest extends ApiTestCase
6+
{
7+
public function testShow()
8+
{
9+
$expected = [];
10+
$jobId = '46bf13150a86fece079ca979cb8ef57c78773faa';
11+
12+
/** @var Jobs&\PHPUnit_Framework_MockObject_MockObject $api */
13+
$api = $this->getApiMock();
14+
$api->expects($this->once())
15+
->method('get')
16+
->with($this->equalTo('/jobs/' . $jobId))
17+
->will($this->returnValue($expected));
18+
19+
$this->assertSame($expected, $api->show($jobId));
20+
}
21+
22+
protected function getApiClass()
23+
{
24+
return Jobs::class;
25+
}
26+
}

0 commit comments

Comments
 (0)