Business-Fixflo
view release on metacpan or search on metacpan
lib/Business/Fixflo/Client.pm view on Meta::CPAN
%{ $data },
);
return $landlord;
}
sub _get_landlord_property {
my ( $self,$id_or_landlord_id,$property_id ) = @_;
my $data = $property_id
? $self->_api_request( 'GET',"LandlordProperty?LandlordId=$id_or_landlord_id&PropertyId=$property_id" )
: $self->_api_request( 'GET',"Landlord?LandlordPropertyId=$id_or_landlord_id" );
my $property = Business::Fixflo::LandlordProperty->new(
client => $self,
%{ $data },
);
return $property;
}
sub _get_property_address {
my ( $self,$id ) = @_;
my $data = $self->_api_request( 'GET',"PropertyAddress/$id" );
my $property_address = Business::Fixflo::PropertyAddress->new(
client => $self,
%{ $data },
);
return $property_address;
}
sub _get_quick_view_panels {
my ( $self,$id ) = @_;
my $data = $self->_api_request( 'GET',"qvp" );
my @qvps;
foreach my $qvp ( @{ $data // [] } ) {
push( @qvps,Business::Fixflo::QuickViewPanel->new(
client => $self,
%{ $qvp }
) );
}
return @qvps;
}
=head1 METHODS
api_get
api_post
api_delete
Make a request to the Fixflo API:
my $data = $Client->api_get( 'Issues',\%params );
May return a L<Business::Fixflo::Paginator> object (when calling endpoints
that return lists of items) or a Business::Fixflo:: object for the Issue,
Agency, etc.
=cut
sub api_get {
my ( $self,$path,$params ) = @_;
return $self->_api_request( 'GET',$path,$params );
}
sub api_post {
my ( $self,$path,$params ) = @_;
return $self->_api_request( 'POST',$path,$params );
}
sub api_delete {
my ( $self,$path,$params ) = @_;
return $self->_api_request( 'DELETE',$path,$params );
}
sub _api_request {
my ( $self,$method,$path,$params ) = @_;
carp( "$method -> $path" )
if $ENV{FIXFLO_DEBUG};
my $ua = LWP::UserAgent->new;
$ua->agent( $self->user_agent );
$path = $self->_add_query_params( $path,$params )
if $method eq 'GET';
my $req = $self->_build_request( $method,$path );
if ( $method =~ /POST|PUT|DELETE/ ) {
if ( $params ) {
$req->content_type( 'application/json' );
$req->content( JSON->new->encode( $params ) );
carp( $req->content )
if $ENV{FIXFLO_DEBUG};
}
}
if ( @{ $self->ua_proxy_settings } ) {
$ua->proxy( $self->ua_proxy_settings );
}
my $res = $ua->request( $req );
# work around the fact that a 200 status code can still mean a problem
# with the request, which we don't discover *until* we parse envelope
# data, at which point we have lost the request data. i can't return a
# list from this function as that will break backwards compatibility
# so instead i use a potentially evil global variable
$Business::Fixflo::Client::request_data = {
path => $path,
params => $params,
headers => $req->headers_as_string,
content => $req->content,
( run in 0.727 second using v1.01-cache-2.11-cpan-98e64b0badf )