-
-
Notifications
You must be signed in to change notification settings - Fork 592
Expand file tree
/
Copy pathBlobs.php
More file actions
68 lines (60 loc) · 1.63 KB
/
Blobs.php
File metadata and controls
68 lines (60 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Github\Api\GitData;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
use Github\Exception\MissingArgumentException;
/**
* @link http://developer.github.com/v3/git/blobs/
*
* @author Joseph Bielawski <stloyd@gmail.com>
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class Blobs extends AbstractApi
{
use AcceptHeaderTrait;
/**
* Configure the Accept header depending on the blob type.
*
* @param string|null $bodyType
*
* @return $this
*/
public function configure($bodyType = null)
{
if ('raw' === $bodyType) {
$this->acceptHeaderValue = 'application/vnd.github.raw';
}
return $this;
}
/**
* Show a blob of a sha for a repository.
*
* @param string $username
* @param string $repository
* @param string $sha
*
* @return array
*/
public function show($username, $repository, $sha)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/blobs/'.rawurlencode($sha));
}
/**
* Create a blob of a sha for a repository.
*
* @param string $username
* @param string $repository
* @param array $params
*
* @throws \Github\Exception\MissingArgumentException
*
* @return array
*/
public function create($username, $repository, array $params)
{
if (!isset($params['content'])) {
throw new MissingArgumentException('content');
}
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/blobs', $params);
}
}