1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage GitHub
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * GitHub API Data Blobs class for the Joomla Platform.
14 *
15 * Since blobs can be any arbitrary binary data, the input and responses for the blob API
16 * takes an encoding parameter that can be either utf-8 or base64. If your data cannot be
17 * losslessly sent as a UTF-8 string, you can base64 encode it.
18 *
19 * @documentation https://developer.github.com/v3/git/blobs/
20 *
21 * @since 11.3
22 * @deprecated 4.0 Use the `joomla/github` package via Composer instead
23 */
24 class JGithubPackageDataBlobs extends JGithubPackage
25 {
26 /**
27 * Get a Blob.
28 *
29 * @param string $owner Repository owner.
30 * @param string $repo Repository name.
31 * @param string $sha The commit SHA.
32 *
33 * @return object
34 */
35 public function get($owner, $repo, $sha)
36 {
37 // Build the request path.
38 $path = '/repos/' . $owner . '/' . $repo . '/git/blobs/' . $sha;
39
40 return $this->processResponse(
41 $this->client->get($this->fetchUrl($path))
42 );
43 }
44
45 /**
46 * Create a Blob.
47 *
48 * @param string $owner Repository owner.
49 * @param string $repo Repository name.
50 * @param string $content The content of the blob.
51 * @param string $encoding The encoding to use.
52 *
53 * @return object
54 */
55 public function create($owner, $repo, $content, $encoding = 'utf-8')
56 {
57 // Build the request path.
58 $path = '/repos/' . $owner . '/' . $repo . '/git/blobs';
59
60 $data = array(
61 'content' => $content,
62 'encoding' => $encoding,
63 );
64
65 return $this->processResponse(
66 $this->client->post($this->fetchUrl($path), json_encode($data)),
67 201
68 );
69 }
70 }
71