The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::RDAP::JCard::Address - a subclass of Net::RDAP::JCard::Property representing a postal address.

SYNOPSIS

    #
    # get an object by calling the jcard() method on a Net::RDAP::Object::Entity
    #
    my $jcard = $entity->jcard;

    #
    # get the first address. You can also uses $jcard->addresses() to get all
    # ADR properties.
    #
    my $adr = $jcard->first_address;

    if ($adr->structured) {
        #
        # This is a structured address so we can extract the individual components:
        #

        map { say "Street: ".$_ } @{$adr->street};
        say "Locality: ".$adr->locality;
        say "Region: ".$adr->region;
        say "Postal Code: ".$adr->code;
        say "Country: ".($adr->cc || $adr->country);

    } else {
        #
        # This is an unstructured address, so just print it:
        #
        say "Address:".$adr->address;

    }

DESCRIPTION

The vCard and jCard representations of postal address data can be quite difficult to deal with, and often cause difficulties.

Net::RDAP::JCard::Address provides an ergonomic interface to ADR properties in jCard objects.

To get a Net::RDAP::JCard::Address, use the first_address() or addresses() methods of Net::RDAP::JCard to get an array of address objects.

METHODS

Net::RDAP::JCard::Address inherits from Net::RDAP::JCard::Property, and therefore inherits all that module's methods, in addition to the following:

ADDRESS TYPE

    $structured = $adr->structured;

Returns true if the address is "structured" (see Section 3.3.1.3 of RFC 7095).

FLAT ADDRESS

    say $adr->address;

Returns a multi-line text string containing the address. For "unstructured" addresses, this is the only format available, and is therefore the simplest way to display the address information.

P.O. BOX NUMBER

    say $adr->pobox;

Returns the Post Office box number, or undef.

EXTENDED ADDRESS

    say $adr->extended;

Returns the "extended" address component, such as the apartment or suite number, or undef.

STREET ADDRESS

    map { say $_ } @{$adr->street};

Some structured addresses have a single street address, but some have multiple street addresses which are represented as an arrayref.

This method will always return an arrayref, which may contain zero, one, or many values.

LOCALITY

    say $adr->locality;

Returns the locality, or undef.

REGION

    say $adr->region;

Returns the region, or undef.

POSTAL CODE

    say $adr->code;

Returns the postal code, or undef.

COUNTRY CODE

    say $adr->cc;

Returns the ISO-3166-alpha2 country code (see Section 3.1 of RFC 8605), or undef.

COUNTRY NAME

    say $adr->country;

Returns the country name, or undef.

COPYRIGHT

Copyright 2024 Gavin Brown. All rights reserved.

LICENSE

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the author not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.