From cfe34795b1d9db7ada11d18c4f76444060cdf60d Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 2 Jan 2018 17:18:39 +0000 Subject: better structure, and test, for License --- lib/Ultramarine/Controller.pm6 | 7 ++++++- lib/Ultramarine/Model/License.pm6 | 10 +++------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/Ultramarine/Controller.pm6 b/lib/Ultramarine/Controller.pm6 index 208a50b..f5cbd64 100644 --- a/lib/Ultramarine/Controller.pm6 +++ b/lib/Ultramarine/Controller.pm6 @@ -53,9 +53,14 @@ class Ultramarine::Controller { before $!authorisation; post -> 'ping' { respond [] } post -> 'getLicense' { + my $expires = $.license.expires-at.DateTime.truncated-to('second'); respond [ :status, - license => [ |%($.license.status) ], + license => [ + :valid($.license.is-valid.Str.lc), + :email($.license.email), + :licenseExpires($expires.yyyy-mm-dd ~ ':' ~ $expires.hh-mm-ss), + ], ], } post -> 'getMusicFolders' { diff --git a/lib/Ultramarine/Model/License.pm6 b/lib/Ultramarine/Model/License.pm6 index 2ceeaa5..26380e0 100644 --- a/lib/Ultramarine/Model/License.pm6 +++ b/lib/Ultramarine/Model/License.pm6 @@ -1,11 +1,7 @@ use v6.d.PREVIEW; class Ultramarine::Model::License { - method status() { - return { - :valid, - :email, - :licenseExpires<2019-01-01:00:00:00>, - } - } + method is-valid() { True } + method email() { 'foo@bar.com' } + method expires-at { now.DateTime.later(:2years).Instant } } -- cgit v1.2.3