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
|
|
141
|
use strict; |
|
16
|
|
|
|
|
26
|
|
|
16
|
|
|
|
|
411
|
|
14
|
16
|
|
|
16
|
|
67
|
use warnings; |
|
16
|
|
|
|
|
27
|
|
|
16
|
|
|
|
|
470
|
|
15
|
|
|
|
|
|
|
|
16
|
16
|
|
|
16
|
|
102
|
use Moo; |
|
16
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
223
|
|
17
|
16
|
|
|
16
|
|
12258
|
use Try::Tiny; |
|
16
|
|
|
|
|
20963
|
|
|
16
|
|
|
|
|
896
|
|
18
|
16
|
|
|
16
|
|
97
|
use Carp qw/ carp /; |
|
16
|
|
|
|
|
24
|
|
|
16
|
|
|
|
|
798
|
|
19
|
16
|
|
|
16
|
|
428
|
use Business::Fixflo::Exception; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
329
|
|
20
|
16
|
|
|
16
|
|
7134
|
use Business::Fixflo::Address; |
|
16
|
|
|
|
|
47
|
|
|
16
|
|
|
|
|
682
|
|
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
|
|
166
|
use Carp qw/ confess /; |
|
16
|
|
|
|
|
28
|
|
|
16
|
|
|
|
|
10204
|
|
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
|
45
|
my ( $self,$update ) = @_; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$self->SUPER::_create( $update,'Property',sub { |
125
|
3
|
|
|
3
|
|
7
|
my ( $self ) = @_; |
126
|
|
|
|
|
|
|
|
127
|
3
|
50
|
|
|
|
94
|
$self->PropertyId or $self->PropertyId( 0 ); |
128
|
|
|
|
|
|
|
|
129
|
3
|
|
|
|
|
20
|
my $post_data = { $self->to_hash }; |
130
|
|
|
|
|
|
|
$post_data->{Address} = { $post_data->{Address}->to_hash } |
131
|
3
|
50
|
|
|
|
8
|
if $post_data->{Address}; |
132
|
3
|
|
|
|
|
5
|
return $post_data; |
133
|
5
|
|
|
|
|
27
|
} ); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub get { |
137
|
4
|
|
|
4
|
1
|
11
|
my ( $self ) = @_; |
138
|
|
|
|
|
|
|
|
139
|
4
|
100
|
|
|
|
43
|
my $data = $self->client->api_get( $self->ExternalPropertyRef |
140
|
|
|
|
|
|
|
? ( 'Property',$self->_params ) |
141
|
|
|
|
|
|
|
: ( "Property/".$self->Id ) |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
4
|
|
|
|
|
11
|
foreach my $attr ( keys( %{ $data } ) ) { |
|
4
|
|
|
|
|
13
|
|
145
|
13
|
|
|
13
|
|
880
|
try { $self->$attr( $data->{$attr} ); } |
146
|
|
|
|
|
|
|
catch { |
147
|
0
|
|
|
0
|
|
0
|
carp( "Couldn't set $attr on @{[ ref( $self ) ]}: $_" ); |
|
0
|
|
|
|
|
0
|
|
148
|
13
|
|
|
|
|
202
|
}; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
4
|
|
|
|
|
56
|
return $self; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub _params { |
155
|
1
|
|
|
1
|
|
2
|
my ( $self ) = @_; |
156
|
|
|
|
|
|
|
|
157
|
1
|
50
|
|
|
|
7
|
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 |