MessageBird/API/HLR.pm

filter: Statementstmt 50.0% 10 / 20 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 100% 4 / 4 totaltotal 48.5% 17 / 35 CC 3 SCAR 12.4
CC
3
Cov
42%
get
6.0
remove
6.0
request
2.0
CRAP 3.4
« MessageBird/API/SMS.pm ↑ Summary MessageBird/API/Voice.pm »
1 package SMS::MessageBird::API::HLR;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use parent 'SMS::MessageBird::API';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 SMS::MessageBird::API::HLR - Sub-module for the SMS::MessageBird distribution.
11  
12  
13 =head1 SYNOPSIS
14  
15 This is a sub-module which is part of the SMS::MessageBird distribution.
16  
17 While this module can be used directly, it's designed to be used via
18 L<SMS::MessageBird>
19  
20  
21 =head1 DESCRIPTION
22  
23 This module provides the interface to the HLR related methods of the MessageBird
24 JSON API.
25  
26 The methods implmented acceept the paramteres as named in the MessageBird API
27 documentation which can be found at the L<MessageBird Developer Documentation|https://www.messagebird.com/en-gb/developers>.
28 If you're using this distribution you should be familiar with the API
29 documentation.
30  
31 =head2 Response Data
32  
33 Every method returns a standardised hashref containin the following keys:
34  
35 =over
36  
37 =item ok
38  
39 Value of 0 or 1. Indicates if the request was completed successfully or not.
40 This value is based on LWP::UserAgent's is_success() method.
41  
42 =item code
43  
44 This is the HTTP code returned by the API. In the event of ok => 0 - it's
45 possible that the request was a 401 etc. So this is provided for sanity
46 checking.
47  
48 =item content
49  
50 This is a Perl hashref data structure decoded from the API's response JSON
51 as-is.
52  
53 Please see the L<MessageBird Developer Documentation|https://www.messagebird.com/en-gb/developers>
54 for more information on the expected structure.
55  
56 =back
57  
58  
59 =head1 METHODS
60  
61 =head2 request
62  
63 In: %params - Hash of params accepted by the MessageBird API.
64 Out: $response - Hashref of response data. See "Response Data" above.
65  
66 This method implements the POST /hlr route of the API.
67  
68 Requests an HLR lookup for a given MSISDN.
69  
70 Accepted parameters are listed in the MessageBird API documentation.
71  
72 Require parameters are as follows:
73  
74 =over
75  
76 =item msisdn
77  
78 The MSISDN formatted telephone number to do the network query on.
79  
80 =item reference
81  
82 A client reference string for human reference.
83  
84 =back
85  
86 =cut
87  
88 sub request {
89 0 ▶ my ($self, %params) = @_;
Subroutine request: not called CC=1 SCAR=6.9
Pod documented
90  
91 0 return $self->_api_request(
92 post => "/hlr",
93 \%params,
94 );
95 }
96  
97  
98 =head2 get
99  
100 In: $hlr_id - The HLR ID returned by the request call.
101 Out: $response - Hashref of response data. See "Response Data" above.
102  
103 This method implements the GET /hlr/{hlr_id} route of the API.
104  
105 Attempts to retrieve the result of a previously requested HLR.
106  
107 Please see the L<MessageBird API Documentation|https://www.messagebird.com/en-gb/developers>
108 for more information.
109  
110 =cut
111  
112 sub get {
113 0 ▶ my ($self, $hlr_id) = @_;
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
114  
115 0 ▶ my $route = ($hlr_id) ? "/hlr/$hlr_id"
Branch: 1 branch
BranchTrueFalseTotal
$hlr_id ? : 0 0 0
116 : '/hlr';
117  
118 0 return $self->_api_request( get => $route );
119 }
120  
121  
122 =head2 remove
123  
124 In: $hlr_id - The HLR ID returned by the request call.
125 Out: $response - Hashref of response data. See "Response Data" above.
126  
127 This method implements the DELETE /hlr/{hlr_id} route of the API.
128  
129 Deletes the result of a previously requested HLR.
130  
131 Please see the L<MessageBird API Documentation|https://www.messagebird.com/en-gb/developers>
132 for more information.
133  
134 =cut
135  
136 sub remove {
137 0 ▶ my ($self, $hlr_id) = @_;
Subroutine remove: not called CC=2 SCAR=17.9
Pod documented
138  
139 0 ▶ return $self->_no_param_supplied('HLR ID') if !$hlr_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $hlr_id 0 0 0
140  
141 0 return $self->_api_request( delete => "/hlr/$hlr_id" );
142 }
143  
144  
145 =head2 del
146  
147 Synonym for the L<remove()|/"remove"> method.
148  
149 =cut
150  
151 sub del {
152 0 ▶ my ($self, $hlr_id) = @_;
Subroutine del: not called CC=1 SCAR=6.9
Pod documented
153  
154 0 return $self->remove($hlr_id);
155 }
156  
157  
158 =head1 AUTHOR
159  
160 James Ronan, C<< <james at ronanweb.co.uk> >>
161  
162 =head1 BUGS
163  
164 Please report any bugs or feature requests to C<bug-sms-messagebird at rt.cpan.org>,
165 or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-MessageBird>.
166 I will be notified, and then you'll automatically be notified of progress on your
167 bug as I make changes.
168  
169 Alternatively you can raise an issue on the source code which is available on
170 L<GitHub|https://github.com/jamesronan/SMS-MessageBird>.
171  
172 =head1 LICENSE AND COPYRIGHT
173  
174 Copyright 2016 James Ronan.
175  
176 This library is free software; you can redistribute it and/or modify it under
177 the same terms as Perl itself.
178  
179 =cut
180  
181 2 1;
182  
« MessageBird/API/SMS.pm ↑ Summary MessageBird/API/Voice.pm »