Skip Menu |

This queue is for tickets about the WebService-Futu CPAN distribution.

Report information
The Basics
Id: 67208
Status: resolved
Priority: 0/
Queue: WebService-Futu

People
Owner: VASEKD [...] cpan.org
Requestors: vlastimil.holer [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.01
Fixed in: 0.01



Subject: Constructor parameters fix, add support for HTTP DELETE
Documentation proposes following use my $ws = WebService::Futu->new( user => 'username', pass => 'password' ); but with current CPAN code hash reference is needed my $ws = WebService::Futu->new({ user => 'username', pass => 'password' }); Attached patch: - fixes the constructor to expect parameters in documented (first) way - adds HTTP DELETE method support
Subject: futu.patch
diff -ur WebService.old/Futu.pm WebService/Futu.pm --- WebService.old/Futu.pm 2010-11-19 15:07:57.000000000 +0100 +++ WebService/Futu.pm 2011-04-04 01:59:39.499344294 +0200 @@ -77,16 +77,16 @@ sub new { my $class = shift; - my $hash = shift; + my %hash = @_; - unless ( (defined($hash->{'user'}) or defined($hash->{'id'})) && defined($hash->{'pass'}) ) { + unless ( (defined($hash{'user'}) or defined($hash{'id'})) && defined($hash{'pass'}) ) { die "Must define user and pass to initialise object"; } my $self; - $self->{_user} = $hash->{'user'} if exists $hash->{'user'}; - $self->{_id} = $hash->{'id'} if exists $hash->{'id'}; - $self->{_pass} = $hash->{'pass'}; - $self->{_url} = exists $hash->{'url'} ? $hash->{'url'} : 'https://www.futu.cz'; + $self->{_user} = $hash{'user'} if exists $hash{'user'}; + $self->{_id} = $hash{'id'} if exists $hash{'id'}; + $self->{_pass} = $hash{'pass'}; + $self->{_url} = exists $hash{'url'} ? $hash{'url'} : 'https://www.futu.cz'; return bless($self, $class); } @@ -154,6 +154,21 @@ return $self->_perform_auth('PUT', @other); } +=item perform_delete($content) + +Perform delete on the server. +Automatically request authentication token. +$content is used for sending content. + + my $personal = $self->perform_delete('/api/transaction/123', $content); + +=cut + +sub perform_delete { + my ($self, @other) = @_; + return $self->_perform_auth('DELETE', @other); +} + sub _perform_auth { my ($self, $method, $query, $content) = @_; @@ -226,7 +241,7 @@ } my $body = $ua->request($req); - print STDERR Dumper($body); + #print STDERR Dumper($body); return $body; }
Thanks, for the patch. The patch has been added as version 0.02 to the CPAN repository.