Skip to content

Commit d864754

Browse files
cosminlupuNyholm
authored andcommitted
Added documentation for GitData API (KnpLabs#613)
1 parent 21df374 commit d864754

File tree

6 files changed

+136
-0
lines changed

6 files changed

+136
-0
lines changed

doc/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ v3 APIs:
1414
* [Enterprise](enterprise.md)
1515
* [Gists](gists.md)
1616
* [Comments](gists/comments.md)
17+
* GitData
18+
* [Blobs](gitdata/blobs.md)
19+
* [Commits](gitdata/commits.md)
20+
* [References](gitdata/references.md)
21+
* [Tags](gitdata/tags.md)
22+
* [Trees](gitdata/trees.md)
1723
* [GraphQL](graphql.md)
1824
* [Issues](issues.md)
1925
* [Assignees](issue/assignees.md)

doc/gitdata/blobs.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Blobs API
2+
[Back to the navigation](../README.md)
3+
4+
### Show a blob
5+
6+
```php
7+
$blob = $client->api('gitData')->blobs()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
8+
```
9+
10+
### Create a blob
11+
12+
```php
13+
$blob = $client->api('gitData')->blobs()->create('KnpLabs', 'php-github-api', ['content' => 'Test content', 'encoding' => 'utf-8']);
14+
```

doc/gitdata/commits.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Commits API
2+
[Back to the navigation](../README.md)
3+
4+
### Show a commit
5+
6+
```php
7+
$commit = $client->api('gitData')->commits()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
8+
```
9+
10+
### Create a commit
11+
12+
```php
13+
$commitData = ['message' => 'Upgrading documentation', 'tree' => $treeSHA, 'parents' => [$parentCommitSHA]];
14+
$commit = $client->api('gitData')->commits()->create('KnpLabs', 'php-github-api', $commitData);
15+
```

doc/gitdata/references.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## References API
2+
[Back to the navigation](../README.md)
3+
4+
5+
### List all references
6+
```php
7+
$references = $client->api('gitData')->references()->all('KnpLabs', 'php-github-api');
8+
```
9+
10+
### Show a reference
11+
12+
```php
13+
$reference = $client->api('gitData')->references()->show('KnpLabs', 'php-github-api', 'heads/featureA');
14+
```
15+
16+
### Create a reference
17+
18+
```php
19+
$referenceData = ['ref' => 'refs/heads/featureA', 'sha' => '839e5185da9434753db47959bee16642bb4f2ce4'];
20+
$reference = $client->api('gitData')->references()->create('KnpLabs', 'php-github-api', $referenceData);
21+
```
22+
23+
### Update a reference
24+
25+
```php
26+
$referenceData = ['sha' => '839e5185da9434753db47959bee16642bb4f2ce4', 'force' => false ]; //Force is default false
27+
$reference = $client->api('gitData')->references()->update('KnpLabs', 'php-github-api', 'heads/featureA', $referenceData);
28+
```
29+
30+
### Delete a reference
31+
32+
```php
33+
$client->api('gitData')->references()->remove('KnpLabs', 'php-github-api', 'heads/featureA');
34+
```
35+
36+
### List all branches
37+
```php
38+
$references = $client->api('gitData')->references()->branches('KnpLabs', 'php-github-api');
39+
```
40+
41+
### List all tags
42+
```php
43+
$references = $client->api('gitData')->references()->tags('KnpLabs', 'php-github-api');
44+
```

doc/gitdata/tags.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Tags API
2+
[Back to the navigation](../README.md)
3+
4+
### Show all tags
5+
6+
```php
7+
$tags = $client->api('gitData')->tags()->all('KnpLabs', 'php-github-api');
8+
```
9+
10+
### Show a tag
11+
12+
```php
13+
$tag = $client->api('gitData')->tags()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
14+
```
15+
16+
### Create a tag
17+
18+
```php
19+
$tagData = [
20+
'tag' => 'v0.0.1',
21+
'message' => 'initial version',
22+
'object' => 'c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c',
23+
'type' => 'commit',
24+
'tagger' => [
25+
'name' => 'KnpLabs',
26+
'email' => 'hello@knplabs.com',
27+
'date' => '2017-06-17T14:53:35-07:00'
28+
]
29+
];
30+
31+
$tag = $client->api('gitData')->tags()->create('KnpLabs', 'php-github-api', $tagData);
32+
```

doc/gitdata/trees.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Trees API
2+
[Back to the navigation](../README.md)
3+
4+
### Show a tree
5+
6+
```php
7+
$tree = $client->api('gitData')->trees()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
8+
```
9+
10+
### Create a tree
11+
12+
```php
13+
$treeData = [
14+
'base_tree' => '839e5185da9434753db47959bee16642bb4f2ce4',
15+
'tree' => [
16+
[
17+
'path' => 'README.md',
18+
'mode' => '100644',
19+
'type' => 'blob',
20+
'content' => 'Updated Readme file'
21+
]
22+
]
23+
];
24+
$tree = $client->api('gitData')->trees()->create('KnpLabs', 'php-github-api', $treeData);
25+
```

0 commit comments

Comments
 (0)