From 400d0383cdaea291b6b458fd11dfaf77ef32d0b3 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 9 Jun 2016 15:54:56 +0200 Subject: [PATCH] MT#20257 filter subscriber collection by subscriber's external_id Change-Id: Ib684686b87cfc64efcbbd69425c9e3ca45125f4c --- lib/NGCP/Panel/Controller/API/Subscribers.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/Subscribers.pm b/lib/NGCP/Panel/Controller/API/Subscribers.pm index abb63b30db..b5b74bbf23 100644 --- a/lib/NGCP/Panel/Controller/API/Subscribers.pm +++ b/lib/NGCP/Panel/Controller/API/Subscribers.pm @@ -128,6 +128,19 @@ sub query_params { }, }, }, + { + param => 'subscriber_external_id', + description => 'Filter for subscribers by subscriber\'s external_id.', + query => { + first => sub { + my $q = shift; + return { 'me.external_id' => { like => $q } }; + }, + second => sub { + return { }; + }, + }, + }, { param => 'is_pbx_group', description => 'Filter for subscribers who are (not) pbx_groups.', @@ -305,7 +318,7 @@ sub GET :Allow { $hal->resource({ total_count => $total_count, }); - my $response = HTTP::Response->new(HTTP_OK, undef, + my $response = HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new($hal->http_headers(skip_links => 1)), $hal->as_json); $c->response->headers($response->headers); $c->response->body($response->content); @@ -341,7 +354,7 @@ sub POST :Allow { my $guard = $schema->txn_scope_guard; { my $resource = $self->get_valid_post_data( - c => $c, + c => $c, media_type => 'application/json', ); last unless $resource; @@ -405,7 +418,7 @@ sub POST :Allow { $self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Failed to create subscriber."); last; } - + last unless $self->add_create_journal_item_hal($c,sub { my $self = shift; my ($c) = @_;