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