File Coverage

blib/lib/Paymill/REST/Operations/Create.pm
Criterion Covered Total %
statement 6 17 35.2
branch 0 6 0.0
condition n/a
subroutine 2 3 66.6
pod 1 1 100.0
total 9 27 33.3


line stmt bran cond sub pod time code
1             package Paymill::REST::Operations::Create;
2              
3 9     9   5063 use Moose::Role;
  9         25  
  9         60  
4              
5             sub create {
6 0     0 1   my ($self, $data) = @_;
7              
8 0           my $factory = $self;
9 0 0         if ($self->can('_factory')) {
10 0           $factory = $self->_factory;
11             }
12              
13 0           my $uri = $factory->base_url . $factory->type . 's';
14              
15 0 0         if ($data->{id}) {
16 0           $uri .= '/' . delete $data->{id};
17             }
18              
19 0           my $item_attrs = $factory->_get_response({ uri => $uri, query => $data, method => 'POST' });
20              
21 0 0         if ($self->can('_type_create')) {
22 0           $item_attrs->{_type} = $self->_type_create;
23             }
24              
25 0           return $factory->_build_item($item_attrs);
26             }
27              
28 9     9   48028 no Moose::Role;
  9         27  
  9         51  
29             1;
30              
31             __END__
32              
33             =encoding utf-8
34              
35             =head1 NAME
36              
37             Paymill::REST::Operations::Create — Create operation for L<Paymill::REST> as Moose Role
38              
39             =head1 FUNCTIONS
40              
41             =head2 create
42              
43             To create a new item, eg. a transaction or client, via the PAYMILL
44             REST API, call this method on the respective item factory. Returns an
45             instance of the newly created item module (eg. L<Paymill::REST::Item::Transaction>).
46              
47             B<Note:> might return a different item module for some items, eg. when
48             creating a preauthorization a transaction is returned. This behavior
49             depends on the PAYMILL REST API.
50              
51             Expects a hash ref as parameter for creating the item. Please refer to
52             PAYMILL's API reference and use parameters as key and their values as
53             the key's values.
54              
55             =head1 AUTHOR
56              
57             Matthias Dietrich E<lt>perl@rainboxx.deE<gt>
58              
59             =head1 COPYRIGHT
60              
61             Copyright 2013 - Matthias Dietrich
62              
63             =head1 LICENSE
64              
65             This library is free software; you can redistribute it and/or modify
66             it under the same terms as Perl itself.