Skip to content

Commit

Permalink
Add Repo::Keys->rm()
Browse files Browse the repository at this point in the history
  • Loading branch information
rsrchboy committed Apr 7, 2013
1 parent b37d6da commit 76f5e2b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
17 changes: 16 additions & 1 deletion lib/GitHub/API/Base.pm
Expand Up @@ -31,7 +31,7 @@ sub _post {
my $url = $self->{base_url} . $self->{url};
$url .= $path_part // q{};

#### POST to: $url
### POST to: $url
#### $content
my $resp = $self
->{ua}
Expand All @@ -41,6 +41,21 @@ sub _post {
return $resp->{content}->from_json;
}

sub _delete {
my ($self, $content, $path_part) = @_;

my $url = $self->{base_url} . $self->{url};
$url .= $path_part // q{};

### DELETE to: $url
my $resp = $self
->{ua}
->delete($url, { headers => $self->{headers} })
;

return $resp;
}

sub _next_append {
my ($self, $class, $url_append) = @_;

Expand Down
17 changes: 15 additions & 2 deletions lib/GitHub/API/Repo/Keys.pm
Expand Up @@ -38,13 +38,26 @@ for more information.
sub create {
my ($self, %key) = @_;

delete $self->{_keys};
my $key = $self->_post(\%key);
$self->{_keys}->push($key)
if defined $self->{_keys};

return $key;
}

=method rm($id)
Given a key id, deletes said key from the repository's list of deploy keys.
=cut

sub rm {
my ($self, $id) = @_;

delete $self->{_keys};
return $self->_delete(undef, "/$id");
}


!!42;
__END__
Expand Down

0 comments on commit 76f5e2b

Please sign in to comment.