@@ -, +, @@ --- Koha/REST/V1/Tickets.pm | 10 ++++++++++ Koha/Ticket.pm | 2 +- api/v1/swagger/definitions/ticket.yaml | 7 +++++++ api/v1/swagger/paths/tickets.yaml | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) --- a/Koha/REST/V1/Tickets.pm +++ a/Koha/REST/V1/Tickets.pm @@ -86,8 +86,18 @@ sub add { # FIXME: We should allow impersonation at a later date to # allow an API user to submit on behalf of a user + # Capture additional_fields + my $extended_attributes = delete $body->{extended_attributes} // []; + + # Create ticket my $ticket = Koha::Ticket->new_from_api($body)->store; $ticket->discard_changes; + + # Set additional_fields + my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; + $ticket->extended_attributes(\@extended_attributes); + + # Respond $c->res->headers->location( $c->req->url->to_string . '/' . $ticket->id ); return $c->render( --- a/Koha/Ticket.pm +++ a/Koha/Ticket.pm @@ -17,7 +17,7 @@ package Koha::Ticket; use Modern::Perl; -use base qw(Koha::Object); +use base qw(Koha::Object Koha::Object::Mixin::AdditionalFields); use C4::Letters; --- a/api/v1/swagger/definitions/ticket.yaml +++ a/api/v1/swagger/definitions/ticket.yaml @@ -9,6 +9,7 @@ properties: type: string enum: - catalog + - opac_problem reported_date: type: - string @@ -62,6 +63,12 @@ properties: - integer - "null" description: Number of updates + extended_attributes: + type: + - array + items: + $ref: additional_field_value.yaml + description: Related additional field values additionalProperties: false required: - source --- a/api/v1/swagger/paths/tickets.yaml +++ a/api/v1/swagger/paths/tickets.yaml @@ -28,6 +28,7 @@ - resolver - biblio - updates+count + - extended_attributes collectionFormat: csv responses: "200": --