Created
October 27, 2022 17:37
-
-
Save thowe/b2b32d94a5ce99ab854915dd9f77fc54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojo::Base -strict; | |
use Mojo::UserAgent; | |
use Getopt::Long; | |
#edit these to your data | |
my $api_key = 'fffffff-ffff-ffff-ffff-fffffffff'; | |
my $id = 'libd_id_0000'; | |
my $tn; | |
# Print information on correct command line usage. | |
sub usage { | |
my $instructions = <<END; | |
USAGE: | |
TN must be 11 digits with 1 in front. | |
libdqs.pl --tn 15415551111 | |
END | |
say $instructions; | |
exit; | |
} | |
# Assign settings from command line options. | |
sub set_options { | |
GetOptions('tn=i' => \$tn, ); | |
usage() unless ($tn); | |
usage() unless $tn =~ /\A\d{11}\z/; | |
} | |
set_options(); | |
my $ua = Mojo::UserAgent->new; | |
my $base = Mojo::URL->new( 'https://lidb.io/' ); | |
my $full_path = $base->clone; | |
$full_path->path->merge('rcwe/'); | |
$full_path->path->merge('+' . $tn); | |
$full_path->query('key' => $api_key, 'id' => $id); | |
my $tx = $ua->get( $full_path ); | |
unless( $tx->result->is_success ) { die "GET failed" }; | |
if( $tx->res->code == 400 ) { | |
say "Bad Request code returned;" | |
} | |
else { | |
my $code; | |
$code = "CNAM data: " if( $tx->res->code == 200 ); | |
$code = "Wireless Caller Data: " if( $tx->res->code == 201 ); | |
$code = "Third party or rate center data: " if( $tx->res->code == 203 ); | |
say $code . $tx->result->body; | |
} | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment