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   348767 use strict;
  5         54  
  5         162  
3 5     5   28 use warnings;
  5         12  
  5         148  
4 5     5   25 use utf8;
  5         11  
  5         32  
5              
6 5     5   2745 use Class::Load qw/ load_class /;
  5         112043  
  5         589  
7             use Class::Accessor::Lite::Lazy (
8 5         86 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   2810 );
  5         14933  
12              
13 5     5   5623 use WebService::Slack::WebApi::Exception;
  5         18  
  5         171  
14 5     5   2657 use WebService::Slack::WebApi::Client;
  5         18  
  5         862  
15              
16             our $VERSION = '0.18';
17              
18             sub _build_client {
19 12     12   12654 my $self = shift;
20 12 100 100     47 if( $self->opt && $self->ua ) {
21 1         23 WebService::Slack::WebApi::Exception::IllegalParameters->throw(
22             message => 'Illegal parameters. You cannot use both parameters \'opt\' and \'ua\' together',
23             );
24             }
25 11         122 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   40 no strict 'refs';
  5         29  
  5         468  
38             *$method = sub {
39 43     43   75305 load_class $class;
40 43         1687 return $class->new(client => shift->client)
41             };
42             }
43              
44             1;
45              
46             __END__