| 1 | package CSAF::ROLIE::Entry; | ||
| 2 | |||
| 3 | use 5.010001; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | use utf8; | ||
| 7 | |||
| 8 | use Moo; | ||
| 9 | use CSAF::Util qw(parse_datetime); | ||
| 10 | |||
| 11 | has id => (is => 'rw', required => 1); | ||
| 12 | has title => (is => 'rw', required => 1); | ||
| 13 | has published => (is => 'rw', coerce => \&parse_datetime); | ||
| 14 | has updated => (is => 'rw', required => 1, coerce => \&parse_datetime); | ||
| 15 | has format => (is => 'rw', required => 1); | ||
| 16 | has link => (is => 'rw', required => 1); | ||
| 17 | has content => (is => 'rw', required => 1); | ||
| 18 | has summary => (is => 'rw'); | ||
| 19 | |||
| 20 | sub TO_JSON { | ||
| 21 | |||
| 22 | my $self = shift; | ||
| 23 | |||
| 24 | my $json = { | ||
| 25 | id => $self->id, | ||
| 26 | title => $self->title, | ||
| 27 | published => $self->published->datetime, | ||
| 28 | updated => $self->updated->datetime, | ||
| 29 | format => $self->format, | ||
| 30 | link => $self->link, | ||
| 31 | content => $self->content | ||
| 32 | }; | ||
| 33 | |||
| 34 | $json->{summary} = $self->summary if ($self->summary); | ||
| 35 | |||
| 36 | return $json; | ||
| 37 | |||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | __END__ |