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

VERSION

version 1.02

NAME

Net::Google::CivicInformation::Representatives - All elected representatives for US addresses

SYNOPSIS

  my $client = Net::Google::CivicInformation::Representatives->new( api_key => '***' );

  my $res = $client->representatives_for_address('123 Main St Springfield MO 12345');

  if ( $res->{error} ) {
      # handle the error hash returned
  }
  else {
      for my $official ( $res->{officals} ) {
          # use the data hash
      }
  }

METHODS

representatives_for_address (NonEmptyStr $address)

Requires an address string as the only argument.

On error, the response will contain a key error containing a hashref like:

  {
    'error' => {
      'code' => 400,
      'errors' => [
        {
          'domain' => 'global',
          'message' => 'Failed to parse address',
          'reason' => 'parseError'
        }
      ],
      'message' => 'Failed to parse address'
    }
  }

On success, the response will contain a key officials containing an arrayref of hashrefs, ordered by descending seniority (head of state down). Each hashref represents a single official: there may be more than one record at the same "rank." The hashref will contain the following keys:

name (string)
title (string)
party (string)
addresses (arrayref of hashrefs)
phone_numbers (arrayref of strings)
websites (arrayref of strings)
social_media (arrayref of hashrefs)

AUTHOR

Nick Tonkin <tonkin@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by Nick Tonkin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.