File Coverage

lib/Business/Fixflo/LandlordProperty.pm
Criterion Covered Total %
statement 38 38 100.0
branch 2 2 100.0
condition n/a
subroutine 13 13 100.0
pod 4 4 100.0
total 57 57 100.0


line stmt bran cond sub pod time code
1             package Business::Fixflo::LandlordProperty;
2              
3             =head1 NAME
4              
5             Business::Fixflo::LandlordProperty
6              
7             =head1 DESCRIPTION
8              
9             A class for a fixflo landlord property, extends L
10              
11             =cut
12              
13 16     16   124 use strict;
  16         39  
  16         551  
14 16     16   104 use warnings;
  16         36  
  16         429  
15              
16 16     16   99 use Moo;
  16         40  
  16         112  
17 16     16   6540 use Business::Fixflo::Exception;
  16         46  
  16         696  
18              
19             extends 'Business::Fixflo::Resource';
20              
21 16     16   111 use Business::Fixflo::Property;
  16         42  
  16         567  
22 16     16   100 use Business::Fixflo::Address;
  16         34  
  16         367  
23 16     16   102 use Business::Fixflo::Landlord;
  16         35  
  16         599  
24              
25             =head1 ATTRIBUTES
26              
27             Id
28             CompanyName
29             Title
30             FirstName
31             Surname
32             EmailAddress
33             ContactNumber
34             ContactNumberAlt
35             DisplayName
36             WorksAuthorisationLimit
37             EmailCC
38             IsDeleted
39             ExternalRef
40              
41             =cut
42              
43 16     16   119 use Carp qw/ confess /;
  16         55  
  16         6093  
44              
45             has [ qw/
46             Id
47             LandlordId
48             PropertyId
49             DateFrom
50             DateTo
51             Address
52             / ] => (
53             is => 'rw',
54             );
55              
56             =head1 Operations on a landlord address
57              
58             =head2 create
59              
60             Creates a landlord property in the Fixflo API
61              
62             =head2 update
63              
64             Updates a landlord property in the Fixflo API - will throw an exception if the Id
65             is not set
66              
67             =head2 property
68              
69             Returns the property as a L object
70              
71             =head2 address
72              
73             Returns the address as a L object
74              
75             =head2 landlord
76              
77             Returns the landlord as a L object
78              
79             =cut
80              
81             sub create {
82 5     5 1 60 my ( $self,$update ) = @_;
83              
84             $self->SUPER::_create( $update,'LandlordProperty',sub {
85 3     3   6 my ( $self ) = @_;
86              
87 3 100       13 $self->Id or $self->Id( undef ); # force Id of null in JSON
88 3         12 return { $self->to_hash };
89 5         36 } );
90             }
91              
92             sub property {
93 1     1 1 6 my ( $self ) = @_;
94              
95 1         16 my $Property = Business::Fixflo::Property->new(
96             client => $self->client,
97             Id => $self->PropertyId,
98             );
99              
100 1         16 return $Property->get;
101             }
102              
103             sub address {
104 1     1 1 5 my ( $self ) = @_;
105              
106             return Business::Fixflo::Address->new(
107             client => $self->client,
108 1         5 %{ $self->Address },
  1         12  
109             );
110             }
111              
112             sub landlord {
113 1     1 1 523 my ( $self ) = @_;
114              
115 1         13 my $Landlord = Business::Fixflo::Landlord->new(
116             client => $self->client,
117             Id => $self->LandlordId,
118             );
119              
120 1         13 return $Landlord->get;
121             }
122              
123             1;
124            
125             # vim: ts=4:sw=4:et