ALPHA STAGE, SUBJECT TO CHANGE
use WebService::GitHub;
my $gh = WebService::GitHub.new(
access-token => 'my-access-token'
);
my $res = $gh.request('/user');
say $res.data.name;
Patches welcome
- Break down modules (Users, Repos, etc.)
- Handle Errors
- Auto Pagination
- API Throttle
endpoint
Useful for GitHub Enterprise. Default to https://api.github.com
access-token
Required for Authorized API Request.
auth_login
&auth_password
Basic Authenticaation. useful to get access-token
.
per_page
from Doc, default to 30, max to 100.
jsonp_callback
time-zone
UTC by default, Doc
with
Builds the object with a particular role
my $gh = WebService::GitHub.new(
with => ('Debug')
);
raw
HTTP::Response instance
data
JSON decoded data
header(Str $field)
Get header of HTTP Response
first-page-url
,prev-page-url
,next-page-url
,last-page-url
Parsed from the Link header, Doc
x-ratelimit-limit
,x-ratelimit-remaining
,x-ratelimit-reset
Some of them are, or will be, included in the examples
directory.
my $gh = WebService::GitHub.new;
my $user = $gh.request('/users/fayland').data;
say $user<name>;
use WebService::GitHub::Search;
my $search = WebService::GitHub::Search.new;
my $data = $search.repositories({
:q<perl6>,
:sort<stars>,
:order<desc>
}).data;
examples/create_access_token.pl
use WebService::GitHub::OAuth;
my $gh = WebService::GitHub::OAuth.new(
auth_login => 'username',
auth_password => 'password'
);
my $auth = $gh.create_authorization({
:scopes(['user', 'public_repo', 'repo', 'gist']), # just ['public_repo']
:note<'test purpose'>
}).data;
say $auth<token>;
use WebService::GitHub::Gist;
my $gist = WebService::GitHub::Gist.new(
access-token => %*ENV<GITHUB_ACCESS_TOKEN>
);
my $data = $gist.create_gist({
description => 'Test from perl6 WebService::GitHub::Gist',
public => True,
files => {
'test.txt' => {
content => "Created on " ~ now
}
}
}).data;
say $data<url>;
$data = $gist.update_gist($id, {
files => {
"test_another.txt" => {
content => "Updated on " ~ now
}
}
}).data;
$res = $gist.delete_gist($id);
say 'Deleted' if $res.is-success;