File Coverage

blib/lib/WebService/Slack/WebApi.pm
Criterion Covered Total %
statement 30 30 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 10 10 100.0
pod n/a
total 45 45 100.0


line stmt bran cond sub pod time code
1             package WebService::Slack::WebApi;
2 5     5   948284 use strict;
  5         13  
  5         223  
3 5     5   27 use warnings;
  5         10  
  5         343  
4 5     5   65 use utf8;
  5         10  
  5         36  
5              
6 5     5   2657 use Class::Load qw/ load_class /;
  5         141844  
  5         684  
7             use Class::Accessor::Lite::Lazy (
8 5         104 new => 1,
9             rw => [qw/ team_domain token opt ua /],
10             ro_lazy => [qw/ client api auth channels conversations chat dialog emoji files groups im oauth pins reactions rtm search stars team users dnd bots migration /],
11 5     5   3018 );
  5         18891  
12              
13 5     5   5760 use WebService::Slack::WebApi::Exception;
  5         34  
  5         218  
14 5     5   2872 use WebService::Slack::WebApi::Client;
  5         24  
  5         1176  
15              
16             our $VERSION = '0.19';
17              
18             sub _build_client {
19 12     12   221730 my $self = shift;
20 12 100 100     60 if( $self->opt && $self->ua ) {
21 1         24 WebService::Slack::WebApi::Exception::IllegalParameters->throw(
22             message => 'Illegal parameters. You cannot use both parameters \'opt\' and \'ua\' together',
23             );
24             }
25 11         162 return WebService::Slack::WebApi::Client->new(
26             team_domain => $self->team_domain,
27             token => $self->token,
28             opt => $self->opt,
29             useragent => $self->ua,
30             );
31             }
32              
33             for my $class_name (qw/ api auth channels conversations chat dialog emoji files groups im oauth pins reactions rtm search stars team users dnd bots migration /) {
34             my $method = sprintf '%s::_build_%s', __PACKAGE__, $class_name;
35             my $class = sprintf '%s::%s', __PACKAGE__, ucfirst($class_name);
36              
37 5     5   56 no strict 'refs';
  5         9  
  5         653  
38             *$method = sub {
39 43     43   1180954 load_class $class;
40 43         1952 return $class->new(client => shift->client)
41             };
42             }
43              
44             1;
45              
46             __END__