Business-Fixflo
view release on metacpan or search on metacpan
lib/Business/Fixflo/PropertyAddress.pm view on Meta::CPAN
package Business::Fixflo::PropertyAddress;
=head1 NAME
Business::Fixflo::Property::Address
=head1 DESCRIPTION
A class for a fixflo property address, extends L<Business::Fixflo::Property>
=cut
use strict;
use warnings;
use Moo;
extends 'Business::Fixflo::Property';
use Try::Tiny;
use Carp qw/ carp /;
use Business::Fixflo::Property;
use Business::Fixflo::Address;
use Business::Fixflo::Exception;
use Carp qw/ confess /;
=head1 Operations on a property address
=head2 get
Gets a property address based on the Id
=head2 merge
merges a property address into a property:
$PropertyAddress = $PropertyAddress->merge( $Property );
$Property must be a Business::Fixflo::Property object and have its Id set
=head2 split
splits a property address from a property
=head2 property
gets the L<Business::Fixflo::Property> object associated with the property
address:
my $Property = $PropertyAddress->property;
=cut
sub get {
my ( $self ) = @_;
my $data = $self->client->api_get(
'PropertyAddress/' . $self->Id
);
foreach my $attr ( keys( %{ $data } ) ) {
try { $self->$attr( $data->{$attr} ); }
catch {
carp( "Couldn't set $attr on @{[ ref( $self ) ]}: $_" );
};
}
return $self;
}
sub merge {
my ( $self,$Property ) = @_;
Business::Fixflo::Exception->throw({
message => 'PropertyAddress->merge requires a Business::Fixflo::Property',
}) if ref( $Property ) ne 'Business::Fixflo::Property';
Business::Fixflo::Exception->throw({
message => 'PropertyAddress->Id must be set to merge',
( run in 2.985 seconds using v1.01-cache-2.11-cpan-98e64b0badf )