| 1 | package Hibiscus::XMLRPC; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moo 2; # or Moo::Lax if you can't have Moo v2 | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Filter::signatures; # so the subroutine signatures work on Perls that don't support them | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | no warnings 'experimental::signatures'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use feature 'signatures'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use XMLRPC::PurePerl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Hibiscus::XMLRPC - talk to Hibiscus via XMLRPC | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | my $client = Hibiscus::XMLRPC->new( | ||||||||||||||||||||||||||||
| 20 | url => 'https://127.0.0.1:8080/xmlrpc/', # the default | ||||||||||||||||||||||||||||
| 21 | user => $hbciuser, | ||||||||||||||||||||||||||||
| 22 | password => $hbcipass, | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | my $tr = $client->transactions()->get; | ||||||||||||||||||||||||||||
| 25 | for my $transaction (@$tr) { | ||||||||||||||||||||||||||||
| 26 | ... | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | has 'ua' => ( | ||||||||||||||||||||||||||||
| 32 | is => 'lazy', | ||||||||||||||||||||||||||||
| 33 | 0 | ▶ | default => sub { require Future::HTTP; Future::HTTP->new }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 34 | 1 | ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | has 'url' => ( | ||||||||||||||||||||||||||||
| 37 | is => 'ro', | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | default => sub { URI->new('https://127.0.0.1:8080/xmlrpc/') }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 39 | 1 | ); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | has 'user' => ( | |||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | has 'password' => ( | |||||||||||||||||||||||||||
| 46 | is => 'rw', | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub call($self,$method,@params) { | ||||||||||||||||||||||||||
|
Subroutine
call: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 0 | my $payload = $self->encode_request($method,@params); | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | my $url = $self->url; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | my( $userinfo ) = $url->userinfo || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$url->userinfo || ''
MC/DC0%0/1
$url->userinfo || ''
$url->userinfo
Truth table0%0/2
A
A= $url->userinfo
| |||||||||||||||||||||||||||||
| 54 | 0 | my( $user, $password ) = split /:/, $userinfo; | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | $user ||= $self->user; | ||||||||||||||||||||||||||
|
Condition0%0/3
$user ||= $self->user
MC/DC0%0/2
$user ||= $self->user
$user
$self->user
Truth table0%0/3
A ||= B
A= $userB= $self->user
| |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $password ||= $self->password; | ||||||||||||||||||||||||||
|
Condition0%0/3
$password ||= $self->password
MC/DC0%0/2
$password ||= $self->password
$password
$self->password
Truth table0%0/3
A ||= B
A= $passwordB= $self->password
| |||||||||||||||||||||||||||||
| 57 | 0 | $url->userinfo( "$user:$password" ); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | $self->ua->http_post( | ||||||||||||||||||||||||||||
| 60 | $url, | ||||||||||||||||||||||||||||
| 61 | $payload, | ||||||||||||||||||||||||||||
| 62 | headers => { | ||||||||||||||||||||||||||||
| 63 | 'Content-Type' => 'text/xml', | ||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | )->then(sub($body, $headers) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 66 | 0 | Future->done( | |||||||||||||||||||||||||||
| 67 | $self->decode_result($body) | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | 0 | }); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub encode_request($self,$method,@params) { | ||||||||||||||||||||||||||
|
Subroutine
encode_request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 0 | XMLRPC::PurePerl->encode_call_xmlrpc($method,@params) | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub decode_result($self,$body) { | ||||||||||||||||||||||||||
|
Subroutine
decode_result: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | XMLRPC::PurePerl->decode_xmlrpc($body) | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub BUILDARGS($class, %options) { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | # Upgrade strings to URI::URL | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if( $options{ url } and not ref $options{ url }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options{"url"} and not ref $options{"url"}
MC/DC0%0/2
$options{"url"} and not ref $options{"url"}
$options{"url"}
not ref $options{"url"}
Truth table0%0/3
A and not(B)
A= $options{"url"}B= not ref $options{"url"}
| |||||||||||||||||||||||||||||
| 83 | 0 | $options{ url } = URI->new( $options{ url } ); | |||||||||||||||||||||||||||
| 84 | }; | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | \%options | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =head2 C<< ->transactions %filter >> | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | my $transactions = $jameica->transactions( | ||||||||||||||||||||||||||||
| 92 | { | ||||||||||||||||||||||||||||
| 93 | "datum:min" => '2015-01-01', # or '01.01.2015' | ||||||||||||||||||||||||||||
| 94 | 'datum:max' => '2015-12-31', # or '31.12.2015' | ||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | )->get; | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | Fetches all transactions that match the given filter and returns | ||||||||||||||||||||||||||||
| 99 | them as an arrayref. If no filter is given, all transactions are returned. | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | The keys for each transaction are: | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||
| 104 | 'konto_id' => '99', | ||||||||||||||||||||||||||||
| 105 | 'betrag' => '-999,99', | ||||||||||||||||||||||||||||
| 106 | 'gvcode' => '835', | ||||||||||||||||||||||||||||
| 107 | 'zweck' => 'Zins 999,99 Tilg 999,99', | ||||||||||||||||||||||||||||
| 108 | 'datum' => '2016-04-29', | ||||||||||||||||||||||||||||
| 109 | 'customer_ref' => 'NONREF', | ||||||||||||||||||||||||||||
| 110 | 'valuta' => '2016-04-30', | ||||||||||||||||||||||||||||
| 111 | 'id' => '657', | ||||||||||||||||||||||||||||
| 112 | 'umsatz_typ' => 'Kredit', | ||||||||||||||||||||||||||||
| 113 | 'empfaenger_name' => 'IBAN ...', | ||||||||||||||||||||||||||||
| 114 | 'saldo' => '99999.99' | ||||||||||||||||||||||||||||
| 115 | }, | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | See L<https://www.willuhn.de/wiki/doku.php?id=develop:xmlrpc:umsatz> | ||||||||||||||||||||||||||||
| 118 | for the list of allowed parameters. | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub transactions($self, %filter) { | ||||||||||||||||||||||||||
|
Subroutine
transactions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 0 | $self->call( | |||||||||||||||||||||||||||
| 124 | 'hibiscus.xmlrpc.umsatz.list', | ||||||||||||||||||||||||||||
| 125 | \%filter | ||||||||||||||||||||||||||||
| 126 | ) | ||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 1 | 1; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | __END__ | ||||||||||||||||||||||||||||