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   127 use strict;
  16         47  
  16         540  
14 16     16   91 use warnings;
  16         34  
  16         442  
15              
16 16     16   88 use Moo;
  16         38  
  16         98  
17 16     16   6655 use Business::Fixflo::Exception;
  16         39  
  16         722  
18              
19             extends 'Business::Fixflo::Resource';
20              
21 16     16   116 use Business::Fixflo::Property;
  16         33  
  16         555  
22 16     16   105 use Business::Fixflo::Address;
  16         37  
  16         469  
23 16     16   103 use Business::Fixflo::Landlord;
  16         38  
  16         505  
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   103 use Carp qw/ confess /;
  16         36  
  16         6303  
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 63 my ( $self,$update ) = @_;
83              
84             $self->SUPER::_create( $update,'LandlordProperty',sub {
85 3     3   6 my ( $self ) = @_;
86              
87 3 100       10 $self->Id or $self->Id( undef ); # force Id of null in JSON
88 3         10 return { $self->to_hash };
89 5         35 } );
90             }
91              
92             sub property {
93 1     1 1 4 my ( $self ) = @_;
94              
95 1         13 my $Property = Business::Fixflo::Property->new(
96             client => $self->client,
97             Id => $self->PropertyId,
98             );
99              
100 1         13 return $Property->get;
101             }
102              
103             sub address {
104 1     1 1 3 my ( $self ) = @_;
105              
106             return Business::Fixflo::Address->new(
107             client => $self->client,
108 1         5 %{ $self->Address },
  1         11  
109             );
110             }
111              
112             sub landlord {
113 1     1 1 511 my ( $self ) = @_;
114              
115 1         16 my $Landlord = Business::Fixflo::Landlord->new(
116             client => $self->client,
117             Id => $self->LandlordId,
118             );
119              
120 1         14 return $Landlord->get;
121             }
122              
123             1;
124            
125             # vim: ts=4:sw=4:et