File Coverage

lib/Business/Fixflo/IssueDraftMedia.pm
Criterion Covered Total %
statement 21 21 100.0
branch 3 6 50.0
condition n/a
subroutine 7 7 100.0
pod 3 3 100.0
total 34 37 91.8


line stmt bran cond sub pod time code
1             package Business::Fixflo::IssueDraftMedia;
2              
3             =head1 NAME
4              
5             Business::Fixflo::IssueDraftMedia
6              
7             =head1 DESCRIPTION
8              
9             A class for a fixflo issue draft media, extends L
10              
11             =cut
12              
13 16     16   335 use strict;
  16         44  
  16         560  
14 16     16   100 use warnings;
  16         35  
  16         416  
15              
16 16     16   111 use Moo;
  16         59  
  16         116  
17              
18             extends 'Business::Fixflo::Resource';
19             with 'Business::Fixflo::Utils';
20              
21             =head1 ATTRIBUTES
22              
23             Id
24             IssueDraftId
25             Url
26             ContentType
27             ShortDesc
28             EncodedByteData
29              
30             =cut
31              
32             has [ qw/
33             Id
34             IssueDraftId
35             Url
36             ContentType
37             ShortDesc
38             EncodedByteData
39             / ] => (
40             is => 'rw',
41             );
42              
43             =head1 Operations on a issue draft media
44              
45             =head2 create
46              
47             Creates an issue draft media in the Fixflo API
48              
49             =head2 download
50              
51             Gets the binary content of the issue draft media.
52              
53             =head2 delete
54              
55             Deletes the issue draft media.
56              
57             =cut
58              
59             sub create {
60 3     3 1 2679 my ( $self,$update ) = @_;
61              
62             $self->SUPER::_create( $update,'IssueDraftMedia',sub {
63 2     2   4 my ( $self ) = @_;
64              
65 2 50       66 $self->Id or $self->Id( undef ); # force null in JSON request
66              
67 2         7 return { $self->to_hash };
68 3         26 } );
69             }
70              
71             sub download {
72 1     1 1 4 my ( $self ) = @_;
73              
74 1 50       5 Business::Fixflo::Exception->throw({
75             message => "Can't download IssueDraftMedia if Id is not set",
76             }) if ! $self->Id;
77              
78 1         10 return $self->client->api_get( 'IssueDraftMedia/' . $self->Id . '/Download' )
79             }
80              
81             sub delete {
82 1     1 1 3 my ( $self ) = @_;
83              
84 1 50       5 Business::Fixflo::Exception->throw({
85             message => "Can't delete IssueDraftMedia if Id is not set",
86             }) if ! $self->Id;
87              
88 1         6 my $post_data = { Id => $self->Id };
89              
90 1         5 return $self->_parse_envelope_data(
91             $self->client->api_post( 'IssueDraftMedia/Delete',$post_data )
92             );
93             }
94              
95             =head1 AUTHOR
96              
97             Lee Johnson - C
98              
99             This library is free software; you can redistribute it and/or modify it under
100             the same terms as Perl itself. If you would like to contribute documentation,
101             features, bug fixes, or anything else then please raise an issue / pull request:
102              
103             https://github.com/Humanstate/business-fixflo
104              
105             =cut
106              
107             1;
108              
109             # vim: ts=4:sw=4:et