| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::Fixflo::Property; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::Fixflo::Property |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
A class for a fixflo property, extends L |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
|
12
|
|
|
|
|
|
|
|
|
13
|
16
|
|
|
16
|
|
116
|
use strict; |
|
|
16
|
|
|
|
|
36
|
|
|
|
16
|
|
|
|
|
483
|
|
|
14
|
16
|
|
|
16
|
|
83
|
use warnings; |
|
|
16
|
|
|
|
|
32
|
|
|
|
16
|
|
|
|
|
579
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
16
|
|
|
16
|
|
124
|
use Moo; |
|
|
16
|
|
|
|
|
33
|
|
|
|
16
|
|
|
|
|
241
|
|
|
17
|
16
|
|
|
16
|
|
14753
|
use Try::Tiny; |
|
|
16
|
|
|
|
|
23895
|
|
|
|
16
|
|
|
|
|
1073
|
|
|
18
|
16
|
|
|
16
|
|
122
|
use Carp qw/ carp /; |
|
|
16
|
|
|
|
|
36
|
|
|
|
16
|
|
|
|
|
617
|
|
|
19
|
16
|
|
|
16
|
|
526
|
use Business::Fixflo::Exception; |
|
|
16
|
|
|
|
|
37
|
|
|
|
16
|
|
|
|
|
351
|
|
|
20
|
16
|
|
|
16
|
|
7377
|
use Business::Fixflo::Address; |
|
|
16
|
|
|
|
|
60
|
|
|
|
16
|
|
|
|
|
1038
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
extends 'Business::Fixflo::Resource'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Id |
|
27
|
|
|
|
|
|
|
AssignedAgent |
|
28
|
|
|
|
|
|
|
AssignedTeam |
|
29
|
|
|
|
|
|
|
BlockId |
|
30
|
|
|
|
|
|
|
BlockName |
|
31
|
|
|
|
|
|
|
Created |
|
32
|
|
|
|
|
|
|
ExternalPropertyRef |
|
33
|
|
|
|
|
|
|
PropertyManager |
|
34
|
|
|
|
|
|
|
PropertyAddressId |
|
35
|
|
|
|
|
|
|
KeyReference |
|
36
|
|
|
|
|
|
|
Address |
|
37
|
|
|
|
|
|
|
Addresses |
|
38
|
|
|
|
|
|
|
Issues |
|
39
|
|
|
|
|
|
|
IsDeleted |
|
40
|
|
|
|
|
|
|
IsNotManaged |
|
41
|
|
|
|
|
|
|
UpdateDate |
|
42
|
|
|
|
|
|
|
Warranties |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
16
|
|
|
16
|
|
187
|
use Carp qw/ confess /; |
|
|
16
|
|
|
|
|
38
|
|
|
|
16
|
|
|
|
|
12559
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has [ qw/ |
|
49
|
|
|
|
|
|
|
Id |
|
50
|
|
|
|
|
|
|
AssignedAgent |
|
51
|
|
|
|
|
|
|
AssignedTeam |
|
52
|
|
|
|
|
|
|
BlockId |
|
53
|
|
|
|
|
|
|
BlockName |
|
54
|
|
|
|
|
|
|
Created |
|
55
|
|
|
|
|
|
|
ExternalPropertyRef |
|
56
|
|
|
|
|
|
|
PropertyAddressId |
|
57
|
|
|
|
|
|
|
PropertyManager |
|
58
|
|
|
|
|
|
|
KeyReference |
|
59
|
|
|
|
|
|
|
UpdateDate |
|
60
|
|
|
|
|
|
|
Warranties |
|
61
|
|
|
|
|
|
|
IsDeleted |
|
62
|
|
|
|
|
|
|
IsNotManaged |
|
63
|
|
|
|
|
|
|
/ ] => ( |
|
64
|
|
|
|
|
|
|
is => 'rw', |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has 'PropertyId' => ( |
|
68
|
|
|
|
|
|
|
is => 'rw', |
|
69
|
|
|
|
|
|
|
lazy => 1, |
|
70
|
|
|
|
|
|
|
default => sub { shift->Id || 0 }, |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has 'Address' => ( |
|
74
|
|
|
|
|
|
|
is => 'rw', |
|
75
|
|
|
|
|
|
|
isa => sub { |
|
76
|
|
|
|
|
|
|
confess( "$_[0] is not a Business::Fixflo::Address" ) |
|
77
|
|
|
|
|
|
|
if ref $_[0] ne 'Business::Fixflo::Address'; |
|
78
|
|
|
|
|
|
|
}, |
|
79
|
|
|
|
|
|
|
lazy => 1, |
|
80
|
|
|
|
|
|
|
coerce => sub { |
|
81
|
|
|
|
|
|
|
$_[0] = Business::Fixflo::Address->new( $_[0] ) |
|
82
|
|
|
|
|
|
|
if ref( $_[0] ) ne 'Business::Fixflo::Address'; |
|
83
|
|
|
|
|
|
|
return $_[0]; |
|
84
|
|
|
|
|
|
|
}, |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has 'Addresses' => ( |
|
88
|
|
|
|
|
|
|
is => 'rw', |
|
89
|
|
|
|
|
|
|
lazy => 1, |
|
90
|
|
|
|
|
|
|
default => sub { |
|
91
|
|
|
|
|
|
|
shift->_paginated_items( 'Property','Addresses','PropertyAddress' ); |
|
92
|
|
|
|
|
|
|
}, |
|
93
|
|
|
|
|
|
|
); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
has 'Issues' => ( |
|
96
|
|
|
|
|
|
|
is => 'rw', |
|
97
|
|
|
|
|
|
|
lazy => 1, |
|
98
|
|
|
|
|
|
|
default => sub { |
|
99
|
|
|
|
|
|
|
shift->_paginated_items( 'Property','Issues','Issue' ); |
|
100
|
|
|
|
|
|
|
}, |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 Operations on a property |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 get |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Gets a property based on either the ExternalPropertyRef or the PropertyId |
|
108
|
|
|
|
|
|
|
(ExternalPropertyRef is favoured if this is set) |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 create |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Creates a property in the Fixflo API |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 update |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Updates a property in the Fixflo API - will throw an exception if the PropertyId |
|
117
|
|
|
|
|
|
|
is not set |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub create { |
|
122
|
5
|
|
|
5
|
1
|
62
|
my ( $self,$update ) = @_; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$self->SUPER::_create( $update,'Property',sub { |
|
125
|
3
|
|
|
3
|
|
9
|
my ( $self ) = @_; |
|
126
|
|
|
|
|
|
|
|
|
127
|
3
|
50
|
|
|
|
77
|
$self->PropertyId or $self->PropertyId( 0 ); |
|
128
|
|
|
|
|
|
|
|
|
129
|
3
|
|
|
|
|
24
|
my $post_data = { $self->to_hash }; |
|
130
|
|
|
|
|
|
|
$post_data->{Address} = { $post_data->{Address}->to_hash } |
|
131
|
3
|
50
|
|
|
|
12
|
if $post_data->{Address}; |
|
132
|
3
|
|
|
|
|
7
|
return $post_data; |
|
133
|
5
|
|
|
|
|
102
|
} ); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub get { |
|
137
|
4
|
|
|
4
|
1
|
12
|
my ( $self ) = @_; |
|
138
|
|
|
|
|
|
|
|
|
139
|
4
|
100
|
|
|
|
52
|
my $data = $self->client->api_get( $self->ExternalPropertyRef |
|
140
|
|
|
|
|
|
|
? ( 'Property',$self->_params ) |
|
141
|
|
|
|
|
|
|
: ( "Property/".$self->Id ) |
|
142
|
|
|
|
|
|
|
); |
|
143
|
|
|
|
|
|
|
|
|
144
|
4
|
|
|
|
|
15
|
foreach my $attr ( keys( %{ $data } ) ) { |
|
|
4
|
|
|
|
|
17
|
|
|
145
|
13
|
|
|
13
|
|
1054
|
try { $self->$attr( $data->{$attr} ); } |
|
146
|
|
|
|
|
|
|
catch { |
|
147
|
0
|
|
|
0
|
|
0
|
carp( "Couldn't set $attr on @{[ ref( $self ) ]}: $_" ); |
|
|
0
|
|
|
|
|
0
|
|
|
148
|
13
|
|
|
|
|
247
|
}; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
4
|
|
|
|
|
68
|
return $self; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub _params { |
|
155
|
1
|
|
|
1
|
|
3
|
my ( $self ) = @_; |
|
156
|
|
|
|
|
|
|
|
|
157
|
1
|
50
|
|
|
|
8
|
return $self->ExternalPropertyRef |
|
158
|
|
|
|
|
|
|
? { 'ExternalPropertyRef' => $self->ExternalPropertyRef } |
|
159
|
|
|
|
|
|
|
: { 'PropertyId' => $self->Id }; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Lee Johnson - C |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
|
167
|
|
|
|
|
|
|
the same terms as Perl itself. If you would like to contribute documentation, |
|
168
|
|
|
|
|
|
|
features, bug fixes, or anything else then please raise an issue / pull request: |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
https://github.com/Humanstate/business-fixflo |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |