Auth0/Management.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 20 Podpod 0.0% 0 / 18 totaltotal 0.0% 0 / 80 CC 2 SCAR 8.7
CC
2
Cov
0%
create
6.0
blacklists
2.0
client_grants
2.0
CRAP 2.4
1 package WebService::Auth0::Management;
2  
3 use Moo;
4 use Module::Runtime qw(use_module);
5  
6 has domain => (
7 is=>'ro',
8 required=>1 );
9  
10 has token => (
11 is=>'ro',
12 predicate=>'has_token',
13 required=>0 );
14  
15 has ua => (
16 is=>'ro',
17 required=>1 );
18  
19 has mgmt_path_parts => (
20 is=>'ro',
21 required=>1,
22 isa=>sub { ref($_) eq 'ARRAY' },
23 default=>sub {['api', 'v2']} );
24  
25 sub create {
26 my ($self, $module, $args) = @_;
27 my %args = (
28 domain => $self->domain,
29 ua => $self->ua,
30 mgmt_path_parts => $self->mgmt_path_parts,
31 %{$args||+{}});
32  
33 $args{token} = $self->token if $self->has_token;
34 return use_module(ref($self)."::$module")->new(%args);
35 }
36  
37 sub blacklists { shift->create('Blacklists',@_) }
38 sub client_grants { shift->create('ClientGrants',@_) }
39 sub clients { shift->create('Clients',@_) }
40 sub connections { shift->create('Connections',@_) }
41 sub device_credentials { shift->create('DeviceCredentials',@_) }
42 sub emails { shift->create('Emails',@_) }
43 sub guardian{ shift->create('Guardian',@_) }
44 sub jobs { shift->create('Jobs',@_) }
45 sub logs { shift->create('Logs',@_) }
46 sub resource_servers { shift->create('ResourceServers',@_) }
47 sub rules { shift->create('Rules',@_) }
48 sub stats { shift->create('Stats',@_) }
49 sub template { shift->create('Template',@_) }
50 sub tenants { shift->create('Tenants',@_) }
51 sub tickets { shift->create('Tickets',@_) }
52 sub user_blocks { shift->create('UserBlocks',@_) }
53 sub users { shift->create('Users',@_) }
54  
55  
56 =head1 NAME
57  
58 WebService::Auth0::Management - Factory class for the Management API
59  
60 =head1 SYNOPSIS
61  
62 my $mgmt = WebService::Auth0::Management->new(
63 ua => $ua,
64 domain => $ENV{AUTH0_DOMAIN},
65 token => $ENV{AUTH0_TOKEN},
66 );
67  
68 my $rules = $mgmt->create('Rules');
69 my $future = $rules->get;
70  
71 =head1 DESCRIPTION
72  
73 Factory class for the various modules that make up the Management API.
74 I'm actually not keen on this approach but it seems like the way that
75 Auth0 did all the SDKs in other languages so I figured its probably
76 best to play to the standard.
77  
78 You can also create each Management module standalone.
79  
80 =head1 ATTRIBUTES
81  
82 This class defines the following attributes:
83  
84 =head2 domain
85  
86 =head2 token
87  
88 =head2 ua
89  
90 =head2 mgmt_path_parts
91  
92 =head1 METHODS
93  
94 This class defines the following methods:
95  
96 =head2 create ($module, \%args)
97  
98 my $rules = $mgmt->create('Rules');
99  
100 Create a module based on the current arguments. You may pass in override
101 arguments as the second argument of this method.
102  
103 =head1 PROXY METHODS
104  
105 The following methods are proxies to create a sub module
106  
107 =head2 blacklists
108  
109 =head2 client_grants
110  
111 =head2 clients
112  
113 =head2 connections
114  
115 =head2 device_credentials
116  
117 =head2 emails
118  
119 =head2 guardian
120  
121 =head2 jobs
122  
123 =head2 logs
124  
125 =head2 resource_servers
126  
127 =head2 rules
128  
129 =head2 stats
130  
131 =head2 template
132  
133 =head2 tenants
134  
135 =head2 tickets
136  
137 =head2 user_blocks
138  
139 =head2 users
140  
141 =head1 SEE ALSO
142
143 L<WebService::Auth0>, L<https://auth0.com>.
144  
145 =head1 AUTHOR
146
147 See L<WebService::Auth0>
148
149 =head1 COPYRIGHT & LICENSE
150
151 See L<WebService::Auth0>
152  
153 =cut
154  
155 1;