From 82a1be5c3e43453460b5f706d80811a0eeb4428d Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Thu, 24 Mar 2016 17:09:16 +0100 Subject: [PATCH] MT#17801 added NGCP::API::Client::Result->result() method Change-Id: I439475ceb0da5e84b5c1cceac3c2dcdbb7cf1fd1 --- lib/NGCP/API/Client.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/NGCP/API/Client.pm b/lib/NGCP/API/Client.pm index 836a21d..7178b93 100644 --- a/lib/NGCP/API/Client.pm +++ b/lib/NGCP/API/Client.pm @@ -96,6 +96,15 @@ sub as_hash { return from_json($self->content, { utf8 => 1 }); } +sub result { + my $self = shift; + + my $location = $self->headers->header('Location') || ''; + return $self->is_success + ? sprintf "%s %s", $self->status_line, $location + : sprintf "%s %s", $self->status_line, $self->content; +} + 1; __END__ @@ -184,6 +193,10 @@ Return: undef Return: result as a hash reference +=head2 NGCP::API::Client::Result->result() + +Return: return a result string based on the request success + =head1 BUGS AND LIMITATIONS L