| 1 | package SMS::MessageBird::API::Lookup; | ||||||||||
| 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::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<SMS::MessageBird> | ||||||||||
| 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<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 | |||||||||||
| 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<MessageBird API Documentation|https://www.messagebird.com/en-gb/developers> | ||||||||||
| 72 | for more information. | ||||||||||
| 73 | |||||||||||
| 74 | =cut | ||||||||||
| 75 | |||||||||||
| 76 | sub get { | ||||||||||
| 77 | 0 | ▶ | my ($self, $msisdn) = @_; | ||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | return $self->_no_param_supplied('MSISDN') if !$msisdn; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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<MessageBird API Documentation|https://www.messagebird.com/en-gb/developers> | ||||||||||
| 95 | for more information. | ||||||||||
| 96 | |||||||||||
| 97 | =cut | ||||||||||
| 98 | |||||||||||
| 99 | sub request_hlr { | ||||||||||
| 100 | 0 | ▶ | my ($self, $msisdn) = @_; | ||||||||
|
Subroutine
request_hlr: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 101 | |||||||||||
| 102 | 0 | ▶ | return $self->_no_param_supplied('MSISDN') if !$msisdn; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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<MessageBird API Documentation|https://www.messagebird.com/en-gb/developers> | ||||||||||
| 118 | for more information. | ||||||||||
| 119 | |||||||||||
| 120 | =cut | ||||||||||
| 121 | |||||||||||
| 122 | sub get_hlr { | ||||||||||
| 123 | 0 | ▶ | my ($self, $msisdn) = @_; | ||||||||
|
Subroutine
get_hlr: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 124 | |||||||||||
| 125 | 0 | ▶ | return $self->_no_param_supplied('MSISDN') if !$msisdn; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | |||||||||||
| 127 | 0 | return $self->_api_request( get => "/lookup/$msisdn/hlr" ); | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | |||||||||||
| 131 | =head1 AUTHOR | ||||||||||
| 132 | |||||||||||
| 133 | James Ronan, C<< <james at ronanweb.co.uk> >> | ||||||||||
| 134 | |||||||||||
| 135 | =head1 BUGS | ||||||||||
| 136 | |||||||||||
| 137 | Please report any bugs or feature requests to C<bug-sms-messagebird at rt.cpan.org>, | ||||||||||
| 138 | or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-MessageBird>. | ||||||||||
| 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<GitHub|https://github.com/jamesronan/SMS-MessageBird>. | ||||||||||
| 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 | 2 | 1; | |||||||||
| 155 | |||||||||||