File Coverage

blib/lib/Net/API/Telegram/PassportFile.pm
Criterion Covered Total %
statement 7 11 63.6
branch n/a
condition n/a
subroutine 3 7 42.8
pod 4 4 100.0
total 14 22 63.6


line stmt bran cond sub pod time code
1             # -*- perl -*-
2             ##----------------------------------------------------------------------------
3             ## Net/API/Telegram/PassportFile.pm
4             ## Version 0.1
5             ## Copyright(c) 2019 Jacques Deguest
6             ## Author: Jacques Deguest <jack@deguest.jp>
7             ## Created 2019/05/29
8             ## Modified 2020/05/20
9             ## All rights reserved.
10             ##
11             ## This program is free software; you can redistribute it and/or modify it
12             ## under the same terms as Perl itself.
13             ##----------------------------------------------------------------------------
14             package Net::API::Telegram::PassportFile;
15             BEGIN
16             {
17 1     1   817 use strict;
  1         2  
  1         29  
18 1     1   6 use parent qw( Net::API::Telegram::Generic );
  1         2  
  1         4  
19 1     1   140 our( $VERSION ) = '0.1';
20             };
21              
22 0     0 1   sub download { return( shift->_download( @_ ) ); }
23              
24 0     0 1   sub file_date { return( shift->_set_get_datetime( 'file_date', @_ ) ); }sub file_id { return( shift->_set_get_scalar( 'file_id', @_ ) ); }
  0     0 1    
25              
26 0     0 1   sub file_size { return( shift->_set_get_number( 'file_size', @_ ) ); }
27              
28             1;
29              
30             __END__
31              
32             =encoding utf-8
33              
34             =head1 NAME
35              
36             Net::API::Telegram::PassportFile - A file uploaded to Telegram Passport
37              
38             =head1 SYNOPSIS
39              
40             my $msg = Net::API::Telegram::PassportFile->new( %data ) ||
41             die( Net::API::Telegram::PassportFile->error, "\n" );
42              
43             =head1 DESCRIPTION
44              
45             L<Net::API::Telegram::PassportFile> is a Telegram Message Object as defined here L<https://core.telegram.org/bots/api#passportfile>
46              
47             This module has been automatically generated from Telegram API documentation by the script scripts/telegram-doc2perl-methods.pl.
48              
49             =head1 METHODS
50              
51             =over 4
52              
53             =item B<new>( {INIT HASH REF}, %PARAMETERS )
54              
55             B<new>() will create a new object for the package, pass any argument it might receive
56             to the special standard routine B<init> that I<must> exist.
57             Then it returns what returns B<init>().
58              
59             The valid parameters are as follow. Methods available here are also parameters to the B<new> method.
60              
61             =over 8
62              
63             =item * I<verbose>
64              
65             =item * I<debug>
66              
67             =back
68              
69             =item B<download>( file_id, [ file extension ] )
70              
71             Given a file id like file_id, this will call the B<getFile>() method from the parent L<Net::API::Telegram> package and receive a L<Net::API::Telegram::File> object in return, which contains a file path valid for only one hour according to Telegram api here L<https://core.telegram.org/bots/api#getfile>. With this file path, this B<download> method will issue a http get request and retrieve the file and save it locally in a temproary file generated by L<File::Temp>. If an extension is provided, it will be appended to the temproary file name such as C<myfile.jpg> otherwise the extension will be gussed from the mime type returned by the Telegram http server, if any.
72              
73             This method returns undef() on error and sets a L<Net::API::Telegram::Error> or, on success, returns a hash reference with the following properties:
74              
75             =over 8
76              
77             =item I<filepath>
78              
79             The full path to the temporary file
80              
81             =item I<mime>
82              
83             The mime type returned by the server.
84              
85             =item I<response>
86              
87             The L<HTTP::Response>
88              
89             =item I<size>
90              
91             The size in bytes of the file fetched
92              
93             =back
94             =item B<download>( )
95              
96              
97              
98             =item B<file_date>( Date )
99              
100             Unix time when the file was uploaded
101              
102             =item B<file_id>( String )
103              
104             Identifier for this file
105              
106             =item B<file_size>( Integer )
107              
108             File size
109              
110             =back
111              
112             =head1 COPYRIGHT
113              
114             Copyright (c) 2000-2019 DEGUEST Pte. Ltd.
115              
116             =head1 AUTHOR
117              
118             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
119              
120             =head1 SEE ALSO
121              
122             L<Net::API::Telegram>
123              
124             =head1 COPYRIGHT & LICENSE
125              
126             Copyright (c) 2018-2019 DEGUEST Pte. Ltd.
127              
128             You can use, copy, modify and redistribute this package and associated
129             files under the same terms as Perl itself.
130              
131             =cut
132