|
Lines 53-59
Controller method that handles retrieving a single domain limit
Link Here
|
| 53 |
sub get { |
53 |
sub get { |
| 54 |
my $c = shift->openapi->valid_input or return; |
54 |
my $c = shift->openapi->valid_input or return; |
| 55 |
return try { |
55 |
return try { |
| 56 |
my $rec = Koha::MailDomainLimits->search_with_group_domain->find( $c->validation->param('domain_limit_id') ); |
56 |
my $rec = Koha::MailDomainLimits->search_with_group_domain->find( $c->param('domain_limit_id') ); |
| 57 |
return $c->render( _render_helper( 404, undef, error => "Domain limit not found" ) ) if !$rec; |
57 |
return $c->render( _render_helper( 404, undef, error => "Domain limit not found" ) ) if !$rec; |
| 58 |
return $c->render( _render_helper( 200, undef, result => $rec->to_api ) ); |
58 |
return $c->render( _render_helper( 200, undef, result => $rec->to_api ) ); |
| 59 |
} catch { |
59 |
} catch { |
|
Lines 70-76
Controller method that handles adding a new domain limit
Link Here
|
| 70 |
sub add { |
70 |
sub add { |
| 71 |
my $c = shift->openapi->valid_input or return; |
71 |
my $c = shift->openapi->valid_input or return; |
| 72 |
return try { |
72 |
return try { |
| 73 |
my $limit = Koha::MailDomainLimit->new_from_api( $c->validation->param('body') ); |
73 |
my $limit = Koha::MailDomainLimit->new_from_api( $c->req->json ); |
| 74 |
$limit->store->discard_changes; |
74 |
$limit->store->discard_changes; |
| 75 |
$c->res->headers->location( $c->req->url->to_string . '/' . $limit->id ); |
75 |
$c->res->headers->location( $c->req->url->to_string . '/' . $limit->id ); |
| 76 |
return $c->render( _render_helper( 201, undef, result => $limit->to_api ) ); |
76 |
return $c->render( _render_helper( 201, undef, result => $limit->to_api ) ); |
|
Lines 97-106
Controller method that handles updating a domain limit
Link Here
|
| 97 |
|
97 |
|
| 98 |
sub update { |
98 |
sub update { |
| 99 |
my $c = shift->openapi->valid_input or return; |
99 |
my $c = shift->openapi->valid_input or return; |
| 100 |
my $limit = Koha::MailDomainLimits->find( $c->validation->param('domain_limit_id') ); |
100 |
my $limit = Koha::MailDomainLimits->find( $c->param('domain_limit_id') ); |
| 101 |
return $c->render( _render_helper( 404, undef, error => "Object not found" ) ) if !$limit; |
101 |
return $c->render( _render_helper( 404, undef, error => "Object not found" ) ) if !$limit; |
| 102 |
return try { |
102 |
return try { |
| 103 |
$limit->set_from_api( $c->validation->param('body') ); |
103 |
$limit->set_from_api( $c->req->json ); |
| 104 |
$limit->store->discard_changes; |
104 |
$limit->store->discard_changes; |
| 105 |
return $c->render( _render_helper( 200, undef, result => $limit->to_api ) ); |
105 |
return $c->render( _render_helper( 200, undef, result => $limit->to_api ) ); |
| 106 |
} catch { |
106 |
} catch { |
|
Lines 126-132
Controller method that handles deleting a domain limit
Link Here
|
| 126 |
|
126 |
|
| 127 |
sub delete { |
127 |
sub delete { |
| 128 |
my $c = shift->openapi->valid_input or return; |
128 |
my $c = shift->openapi->valid_input or return; |
| 129 |
my $limit = Koha::MailDomainLimits->find( $c->validation->param('domain_limit_id') ); |
129 |
my $limit = Koha::MailDomainLimits->find( $c->param('domain_limit_id') ); |
| 130 |
return $c->render( _render_helper( 404, undef, error => "Domain limit not found" ) ) if !$limit; |
130 |
return $c->render( _render_helper( 404, undef, error => "Domain limit not found" ) ) if !$limit; |
| 131 |
return try { |
131 |
return try { |
| 132 |
$limit->delete; |
132 |
$limit->delete; |
| 133 |
- |
|
|