From 613272f413f070988ef3ef29d1b59bb2f677b713 Mon Sep 17 00:00:00 2001 From: Finn Date: Wed, 31 Jan 2018 12:52:52 +0000 Subject: [PATCH 1/2] Added routing and placeholder for medal data --- lib/Pear/LocalLoop.pm | 4 ++ .../Controller/Api/V1/User/Medals.pm | 47 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index 33742aa..59e1934 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -158,6 +158,10 @@ sub startup { my $api_v1 = $api->under('/v1'); + my $api_v1_user = $api_v1->under('/user'); + + $api_v1_user->post('/medals')->to('api-v1-user-medals#index'); + my $api_v1_supplier = $api_v1->under('/supplier'); $api_v1_supplier->post('/location')->to('api-v1-supplier-location#index'); diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm b/lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm new file mode 100644 index 0000000..98ab359 --- /dev/null +++ b/lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm @@ -0,0 +1,47 @@ +package Pear::LocalLoop::Controller::Api::V1::User::Medals; +use Mojo::Base 'Mojolicious::Controller'; +use Mojo::JSON qw/true false/; + +sub index { + my $c = shift; + + my $validation = $c->validation; + $validation->input( $c->stash->{api_json} ); + + my $global = { + group_name => { + threshold => { + awarded => true, + awarded_at => '2017-01-02T01:00:00Z', + threshold => 1, + points => 1, + }, + total => 1, + }, + }; + my $organisation = { + org_id => { + group_name => { + threshold => { + awarded => true, + awarded_at => '2017-01-02T01:00:00Z', + threshold => 1, + points => 1, + multiplier => 1, + }, + total => 1, + }, + name => 'Placeholder', + }, + }; + + return $c->render( + json => { + success => Mojo::JSON->true, + global => $global, + organisation => $organisation, + } + ); +} + +1; From 6879a8b3b81ad45e10a7e451e178bb05ceda6d1a Mon Sep 17 00:00:00 2001 From: Finn Date: Wed, 31 Jan 2018 12:54:14 +0000 Subject: [PATCH 2/2] made placeholder more obvious --- lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm b/lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm index 98ab359..2664935 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/User/Medals.pm @@ -8,7 +8,8 @@ sub index { my $validation = $c->validation; $validation->input( $c->stash->{api_json} ); - my $global = { + # Placeholder data + my $global_placeholder = { group_name => { threshold => { awarded => true, @@ -19,7 +20,7 @@ sub index { total => 1, }, }; - my $organisation = { + my $organisation_placeholder = { org_id => { group_name => { threshold => { @@ -38,8 +39,8 @@ sub index { return $c->render( json => { success => Mojo::JSON->true, - global => $global, - organisation => $organisation, + global => $global_placeholder, + organisation => $organisation_placeholder, } ); }