class JGithubPackageRepositoriesContents extends JGithubPackage

GitHub API Repositories Contents class for the Joomla Platform.

These API methods let you retrieve the contents of files within a repository as Base64 encoded content. See media types for requesting raw or other formats.

Methods

__construct( Registry $options = null, JGithubHttp $client = null)

Constructor.

__get( string $name)

Magic method to lazily create API objects

object
getReadme( string $owner, string $repo, string $ref = '')

Get the README

object
get( string $owner, string $repo, string $path, string $ref = '')

Get contents

object
getArchiveLink( string $owner, string $repo, string $archive_format = 'zipball', string $ref = '')

Get archive link

Details

__construct( Registry $options = null, JGithubHttp $client = null)

Constructor.

Parameters

Registry $options GitHub options object.
JGithubHttp $client The HTTP client object.

JGithubPackage __get( string $name)

Magic method to lazily create API objects

Parameters

string $name Name of property to retrieve

Return Value

JGithubPackage GitHub API package object.

Exceptions

RuntimeException

object getReadme( string $owner, string $repo, string $ref = '')

Get the README

This method returns the preferred README for a repository.

GET /repos/:owner/:repo/readme

Parameters

ref Optional string - The String name of the Commit/Branch/Tag. Defaults to master.

Response

Status: 200 OK X-RateLimit-Limit: 5000 X-RateLimit-Remaining: 4999

{ "type": "file", "encoding": "base64", "_links": { "git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1", "self": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md", "html": "https://github.com/octokit/octokit.rb/blob/master/README.md" }, "size": 5362, "name": "README.md", "path": "README.md", "content": "encoded content ...", "sha": "3d21ec53a331a6f037a91c368710b99387d012c1" }

Parameters

string $owner The name of the owner of the GitHub repository.
string $repo The name of the GitHub repository.
string $ref The String name of the Commit/Branch/Tag. Defaults to master.

Return Value

object

object get( string $owner, string $repo, string $path, string $ref = '')

Get contents

This method returns the contents of any file or directory in a repository.

GET /repos/:owner/:repo/contents/:path

Parameters

path Optional string - The content path. ref Optional string - The String name of the Commit/Branch/Tag. Defaults to master.

Response

Status: 200 OK X-RateLimit-Limit: 5000 X-RateLimit-Remaining: 4999

{ "type": "file", "encoding": "base64", "_links": { "git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1", "self": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md", "html": "https://github.com/octokit/octokit.rb/blob/master/README.md" }, "size": 5362, "name": "README.md", "path": "README.md", "content": "encoded content ...", "sha": "3d21ec53a331a6f037a91c368710b99387d012c1" }

Parameters

string $owner The name of the owner of the GitHub repository.
string $repo The name of the GitHub repository.
string $path The content path.
string $ref The String name of the Commit/Branch/Tag. Defaults to master.

Return Value

object

Get archive link

This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request.

Note: For private repositories, these links are temporary and expire quickly.

GET /repos/:owner/:repo/:archive_format/:ref

Parameters

archive_format Either tarball or zipball ref Optional string - valid Git reference, defaults to master

Response

Status: 302 Found Location: http://github.com/me/myprivate/tarball/master?SSO=thistokenexpires X-RateLimit-Limit: 5000 X-RateLimit-Remaining: 4999

To follow redirects with curl, use the -L switch:

curl -L https://api.github.com/repos/octokit/octokit.rb/tarball > octokit.tar.gz

Parameters

string $owner The name of the owner of the GitHub repository.
string $repo The name of the GitHub repository.
string $archive_format Either tarball or zipball.
string $ref The String name of the Commit/Branch/Tag. Defaults to master.

Return Value

object

Exceptions

UnexpectedValueException