summaryrefslogtreecommitdiff
path: root/lib/MooseX/Net/API/Meta
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-07-16 16:10:41 +0200
committerfranck cuny <franck@lumberjaph.net>2010-07-16 16:10:41 +0200
commite97449eaa8bd3a408763057f9ca2253d93e2a3d0 (patch)
tree4fd0dc6ed899efe361e314adfc913b9aa6b0a1a4 /lib/MooseX/Net/API/Meta
parentcheck if auth_method is declared (diff)
downloadnet-http-api-e97449eaa8bd3a408763057f9ca2253d93e2a3d0.tar.gz
rename from mx::net::api to net::http::api
Diffstat (limited to '')
-rw-r--r--lib/MooseX/Net/API/Meta/Class.pm16
-rw-r--r--lib/Net/HTTP/API/Meta/Method.pm (renamed from lib/MooseX/Net/API/Meta/Method.pm)21
-rw-r--r--lib/Net/HTTP/API/Meta/Method/APIDeclare.pm (renamed from lib/MooseX/Net/API/Meta/Method/APIDeclare.pm)6
-rw-r--r--lib/Net/HTTP/API/Meta/Method/APIMethod.pm (renamed from lib/MooseX/Net/API/Meta/Method/APIMethod.pm)12
4 files changed, 20 insertions, 35 deletions
diff --git a/lib/MooseX/Net/API/Meta/Class.pm b/lib/MooseX/Net/API/Meta/Class.pm
deleted file mode 100644
index ad1b709..0000000
--- a/lib/MooseX/Net/API/Meta/Class.pm
+++ /dev/null
@@ -1,16 +0,0 @@
-package MooseX::Net::API::Meta::Class;
-
-# ABSTRACT: metaclass for all API client
-
-use Moose::Role;
-
-with qw/
- MooseX::Net::API::Meta::Method::APIMethod
- MooseX::Net::API::Meta::Method::APIDeclare
- /;
-
-1;
-
-=head1 SYNOPSIS
-
-=head1 DESCRIPTION
diff --git a/lib/MooseX/Net/API/Meta/Method.pm b/lib/Net/HTTP/API/Meta/Method.pm
index 8879e04..adda12c 100644
--- a/lib/MooseX/Net/API/Meta/Method.pm
+++ b/lib/Net/HTTP/API/Meta/Method.pm
@@ -1,9 +1,9 @@
-package MooseX::Net::API::Meta::Method;
+package Net::HTTP::API::Meta::Method;
# ABSTRACT: create api method
use Moose;
-use MooseX::Net::API::Error;
+use Net::HTTP::API::Error;
use Moose::Util::TypeConstraints;
use MooseX::Types::Moose qw/Str Int ArrayRef/;
@@ -86,13 +86,13 @@ before wrap => sub {
my ($class, %args) = @_;
if (!$args{params} && $args{required}) {
- die MooseX::Net::API::Error->new(
+ die Net::HTTP::API::Error->new(
reason => "You can't require a param that have not been declared");
}
if ( $args{required} ) {
foreach my $required ( @{ $args{required} } ) {
- die MooseX::Net::API::Error->new( reason =>
+ die Net::HTTP::API::Error->new( reason =>
"$required is required but is not declared in params" )
if ( !grep { $_ eq $required } @{ $args{params} }, @{$args{params_in_url}} );
}
@@ -122,7 +122,7 @@ sub wrap {
if ($method->has_expected
&& !$method->find_expected_code(sub {/$code/}))
{
- die MooseX::Net::API::Error->new(
+ die Net::HTTP::API::Error->new(
reason => "unexpected code",
http_error => $result
);
@@ -139,7 +139,7 @@ sub wrap {
}
}
- die MooseX::Net::API::Error->new(
+ die Net::HTTP::API::Error->new(
http_error => $result,
reason => $result->message,
);
@@ -167,7 +167,7 @@ sub _check_params_before_run {
if ( !$self->find_request_parameter(sub {/$arg/})
&& !$self->find_request_url_parameters(sub {/$arg/}))
{
- die MooseX::Net::API::Error->new(
+ die Net::HTTP::API::Error->new(
reason => "'$arg' is not declared as a param");
}
}
@@ -179,7 +179,7 @@ sub _check_required_before_run {
# check if all our params declared as required are present
foreach my $required ($self->required) {
if (!grep { $required eq $_ } keys %$args) {
- die MooseX::Net::API::Error->new(reason =>
+ die Net::HTTP::API::Error->new(reason =>
"'$required' is declared as required, but is not present");
}
}
@@ -198,10 +198,10 @@ sub _build_path {
$path =~ s/(?:\$|:)$match/$value/;
}
if ($max_iter > $i) {
- $path =~ s/(?:\/((?:\$|\:).*))?$//;
+ $path =~ s/\/(?:(\$|\:).*)?$//;
}
}
- $path =~ s/(?:\/((?:\$|\:).*))?$//;
+ $path =~ s/\/(?:(\$|\:).*)?$//;
return $path;
}
@@ -227,3 +227,4 @@ sub _build_uri {
=head1 SYNOPSIS
=head1 DESCRIPTION
+
diff --git a/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm b/lib/Net/HTTP/API/Meta/Method/APIDeclare.pm
index 0de38df..8718eaa 100644
--- a/lib/MooseX/Net/API/Meta/Method/APIDeclare.pm
+++ b/lib/Net/HTTP/API/Meta/Method/APIDeclare.pm
@@ -1,9 +1,9 @@
-package MooseX::Net::API::Meta::Method::APIDeclare;
+package Net::HTTP::API::Meta::Method::APIDeclare;
# ABSTRACT: declare API
use Moose::Role;
-use MooseX::Net::API::Error;
+use Net::HTTP::API::Error;
my @accepted_options = qw/
api_base_url
@@ -31,7 +31,7 @@ sub add_net_api_declare {
my ($meta, $name, %options) = @_;
if ($options{useragent}) {
- die MooseX::Net::API::Error->new(
+ die Net::HTTP::API::Error->new(
reason => "'useragent' must be a CODE ref")
unless ref $options{useragent} eq 'CODE';
$meta->set_api_option(useragent => delete $options{useragent});
diff --git a/lib/MooseX/Net/API/Meta/Method/APIMethod.pm b/lib/Net/HTTP/API/Meta/Method/APIMethod.pm
index 0ddcacd..8303770 100644
--- a/lib/MooseX/Net/API/Meta/Method/APIMethod.pm
+++ b/lib/Net/HTTP/API/Meta/Method/APIMethod.pm
@@ -1,10 +1,10 @@
-package MooseX::Net::API::Meta::Method::APIMethod;
+package Net::HTTP::API::Meta::Method::APIMethod;
# ABSTRACT: declare API method
use Moose::Role;
-use MooseX::Net::API::Error;
-use MooseX::Net::API::Meta::Method;
+use Net::HTTP::API::Error;
+use Net::HTTP::API::Meta::Method;
use MooseX::Types::Moose qw/Str ArrayRef/;
has local_net_api_methods => (
@@ -44,7 +44,7 @@ sub remove_net_api_method {
before add_net_api_method => sub {
my ($meta, $name) = @_;
if ($meta->_find_net_api_method_by_name(sub {/^$name$/})) {
- die MooseX::Net::API::Error->new(
+ die Net::HTTP::API::Error->new(
reason => "method '$name' is already declared in " . $meta->name);
}
};
@@ -58,7 +58,7 @@ sub add_net_api_method {
$meta->add_method(
$name,
- MooseX::Net::API::Meta::Method->wrap(
+ Net::HTTP::API::Meta::Method->wrap(
name => $name,
package_name => $meta->name,
body => $code,
@@ -74,7 +74,7 @@ after add_net_api_method => sub {
$name,
sub {
my $self = shift;
- die MooseX::Net::API::Error->new(
+ die Net::HTTP::API::Error->new(
reason => "'api_base_url' have not been defined")
unless $self->api_base_url;
}