The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WebService::IFConfig::Client - Client for Martin Polden's https://ifconfig.co

SYNOPSIS

    use strict;
    use warnings;
    use 5.12.0;

    use feature qw/say/;
    use WebService::IFConfig::Client;
    my $ifconfig = WebService::IFConfig::Client->new();

    say $ifconfig->get_city;
    say $ifconfig->get_country;
    say $ifconfig->get_hostname;
    say $ifconfig->get_ip;
    say $ifconfig->get_ip_decimal;

    # Time passes ...
    
    # Request again
    $ifconfig->request;

Calling new() with no arguments, defaults to requesting immediately from https://ifconfig.co.

To defer requesting, the data you can pass the argument 'run' => 0.

To use a different server, pass 'server' => $my_server.

METHODS

WebService::IFConfig::Client->new( 'run' => $boolean , 'server' => $my_server );

Constructor to create an new client. Default values are

  Argument  Default                     Meaning
  --------  -------                     -------
  run       1                           1 means run immediately.
                                        0 means do not run until a request is made.
  server    https://ifconfig.co/json    IPD Server, but you can run your own and provide it here.

get_server

Get the URL this client is configured to talk to

set_server

Set the URL this client is configured to talk to

get_raw_status

Get the HTTP Response Code of the latest request. Returns 0 if no request has been made.

get_status

Returns 1 if the HTTP Response Code of the latest request was 200, or 0 if not. Returns undef if no request has been made.

request

Makes a(nother) request from the server.

get_city

Get the City name. Forces a request if no valid data.

get_country

Get the Country name. Forces a request if no valid data.

get_hostname

Get the Hostname. Forces a request if no valid data.

get_ip

Get the IP address. Forces a request if no valid data.

get_ip_decimal

Get a decimal representation of the IP. Forces a request if no valid data.

AUTHOR

Nic Doye <nic@worldofnic.org>

BUGS

None. None whatsoever. (This is a lie).

LICENSE

   Copyright 2017 Nicolas Doye

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.