File Coverage

blib/lib/SMS/MessageBird/API/Lookup.pm
Criterion Covered Total %
statement 9 18 50.0
branch 0 6 0.0
condition n/a
subroutine 3 6 50.0
pod 3 3 100.0
total 15 33 45.4


line stmt bran cond sub pod time code
1             package SMS::MessageBird::API::Lookup;
2              
3 2     2   6 use strict;
  2         3  
  2         42  
4 2     2   6 use warnings;
  2         2  
  2         38  
5              
6 2     2   5 use parent 'SMS::MessageBird::API';
  2         2  
  2         16  
7              
8             =head1 NAME
9              
10             SMS::MessageBird::API::Lookup - 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
19              
20              
21             =head1 DESCRIPTION
22              
23             This module provides the interface to the Lookup related methods of the
24             MessageBird 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.
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
54             for more information on the expected structure.
55              
56             =back
57              
58              
59             =head1 METHODS
60              
61              
62             =head2 get
63              
64             In: $msisdn - MSISDN to perform the Lookup on.
65             Out: $response - Hashref of response data. See "Response Data" above.
66              
67             This method implements the GET /lookup/{msisdn} route of the API.
68              
69             Requests a network look up for the supplied $msisdn.
70              
71             Please see the L
72             for more information.
73              
74             =cut
75              
76             sub get {
77 0     0 1   my ($self, $msisdn) = @_;
78              
79 0 0         return $self->_no_param_supplied('MSISDN') if !$msisdn;
80              
81 0           return $self->_api_request( get => "/lookup/$msisdn" );
82             }
83              
84              
85             =head2 request_hlr
86              
87             In: $msisdn - MSISDN to request the HLR for.
88             Out: $response - Hashref of response data. See "Response Data" above.
89              
90             This method implements the POST /lookup/{msisdn}/hlr route of the API.
91              
92             Requests a HLR lookup is carried out for the supplied $msisdn.
93              
94             Please see the L
95             for more information.
96              
97             =cut
98              
99             sub request_hlr {
100 0     0 1   my ($self, $msisdn) = @_;
101              
102 0 0         return $self->_no_param_supplied('MSISDN') if !$msisdn;
103              
104 0           return $self->_api_request( post => "/lookup/$msisdn/hlr" );
105             }
106              
107              
108             =head2 get_hlr
109              
110             In: $msisdn - MSISDN the requested HLR was for.
111             Out: $response - Hashref of response data. See "Response Data" above.
112              
113             This method implements the GET /lookup/{msisdn}/hlr route of the API.
114              
115             Attempts to retrieve the HLR previously requested for the supplied $msisdn.
116              
117             Please see the L
118             for more information.
119              
120             =cut
121              
122             sub get_hlr {
123 0     0 1   my ($self, $msisdn) = @_;
124              
125 0 0         return $self->_no_param_supplied('MSISDN') if !$msisdn;
126              
127 0           return $self->_api_request( get => "/lookup/$msisdn/hlr" );
128             }
129              
130              
131             =head1 AUTHOR
132              
133             James Ronan, C<< >>
134              
135             =head1 BUGS
136              
137             Please report any bugs or feature requests to C,
138             or through the web interface at L.
139             I will be notified, and then you'll automatically be notified of progress on your
140             bug as I make changes.
141              
142             Alternatively you can raise an issue on the source code which is available on
143             L.
144              
145             =head1 LICENSE AND COPYRIGHT
146              
147             Copyright 2016 James Ronan.
148              
149             This library is free software; you can redistribute it and/or modify it under
150             the same terms as Perl itself.
151              
152             =cut
153              
154             1;
155