Eixo-Rest

 view release on metacpan or  search on metacpan

lib/Eixo/Rest/Api.pm  view on Meta::CPAN

    }

	$self->client->$method(@args);
}


sub DESTROY {}

sub initialize{

    my ($self, $endpoint, %opts) = @_;

    $self->client(
        Eixo::Rest::Client->new($endpoint, %opts)
    );

    $self->SUPER::initialize(%opts);

    $self;
}

sub produce{
	my ($self, $class, %args) = @_;
	

lib/Eixo/Rest/Client.pm  view on Meta::CPAN




my $REQ_PARSER = qr/\:\:([a-z]+)([A-Z]\w+?)$/;

my $USER_AGENT_VERSION = 'EixoAgent/0.1';

has(

    ua=>undef,
    endpoint=>undef,
    format=>'json',
    error_callback => undef,
    current_method => undef,
);

sub initialize{
    my ($self, $endpoint, %opts) = @_;

    $self->endpoint($endpoint);

    die("API ENDPOINT NEEDED") unless($self->endpoint);

    $self->ua($USER_AGENT_VERSION, %opts);

    $self;
}

sub ua {
    my ($self, $ua_str, %opts) = @_;

    if($ua_str){

lib/Eixo/Rest/Client.pm  view on Meta::CPAN


    $req->header("Content-Type", "$content_type; charset=utf-8");
    $req->add_content_utf8($content) if($content);

}


sub build_uri {
    my ($self, $entity, $id,$action, $implicit_format) = @_;

    my $uri = $self->{endpoint}.'/'.$entity;
    
    $uri .= '/'.$id if(defined($id));
    $uri .= '/'.$action if(defined($action));

    return URI->new($uri) if($implicit_format);

        ($self->current_method =~ /^get/)?

            URI->new($uri.'/'.$self->{format}) :

            URI->new($uri);
}

sub build_predefined_uri{
    my ($self, $uri) = @_;

    my $endpoint = $self->{endpoint};
    
    $endpoint .= "/" unless($endpoint =~ /\/$/);

    $uri =~ s/^\///;

    return URI->new($endpoint . $uri)
}


sub generate_query_str {
    my ($self, %args) = @_;

    join '&', map {"$_=$args{$_}"} keys(%args);
}




( run in 0.423 second using v1.01-cache-2.11-cpan-beeb90c9504 )