From 78964d729759b796efbad372b3fbad378688240d Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 18 Sep 2017 17:31:29 +0100 Subject: [PATCH] Made endpoints org only --- lib/Pear/LocalLoop.pm | 7 ++++--- t/api/organisation.t | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index f41a504..dcd312b 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -144,9 +144,7 @@ sub startup { $api->post('/stats')->to('api-stats#post_index'); $api->post('/stats/leaderboard')->to('api-stats#post_leaderboards'); $api->post('/outgoing-transactions')->to('api-transactions#post_transaction_list_purchases'); - $api->post('/org/payroll/add')->to('api-organisation#post_payroll_add'); - $api->post('/org/supplier/add')->to('api-organisation#post_supplier_add'); - $api->post('/org/employee/add')->to('api-organisation#post_employee_add'); + my $api_v1 = $api->under('/v1'); @@ -154,6 +152,9 @@ sub startup { $api_v1_org->post('/graphs')->to('api-v1-organisation-graphs#index'); $api_v1_org->post('/snippets')->to('api-v1-organisation-snippets#index'); + $api_v1_org->post('/payroll/add')->to('api-organisation#post_payroll_add'); + $api_v1_org->post('/supplier/add')->to('api-organisation#post_supplier_add'); + $api_v1_org->post('/employee/add')->to('api-organisation#post_employee_add'); my $admin_routes = $r->under('/admin')->to('admin#under'); diff --git a/t/api/organisation.t b/t/api/organisation.t index 2331858..2ae3fa3 100644 --- a/t/api/organisation.t +++ b/t/api/organisation.t @@ -23,17 +23,17 @@ my $session_key = $framework->login({ ## Payroll Data Submission #No JSON sent -$t->post_ok('/api/org/payroll/add') +$t->post_ok('/api/v1/organisation/payroll/add') ->status_is(400) ->json_is('/success', Mojo::JSON->false) ->json_like('/message', qr/JSON is missing/i); #Empty JSON -$t->post_ok('/api/org/payroll/add' => json => {}) +$t->post_ok('/api/v1/organisation/payroll/add' => json => {}) ->json_is('/success', Mojo::JSON->false); # no session key -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { entry_period => '2017-12', employee_amount => '10', local_employee_amount => '10', @@ -49,7 +49,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/Invalid Session/); # No entry_period -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, employee_amount => '10', local_employee_amount => '10', @@ -65,7 +65,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/No entry period/); # No employee_amount -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', local_employee_amount => '10', @@ -81,7 +81,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/No employee amount/); # No local_employee_amount -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -97,7 +97,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/local employee amount/); # No gross_payroll -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -113,7 +113,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/No gross payroll/); # No payroll_income_tax -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -129,7 +129,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/No total income tax/); # No payroll_employee_ni -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -145,7 +145,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/No total employee NI/); # No payroll_employer_ni -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -161,7 +161,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/total employer NI/); # No payroll_total_pension -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -177,7 +177,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/No total total pension/); # No payroll_other_benefit -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -193,7 +193,7 @@ $t->post_ok('/api/org/payroll/add' => json => { ->json_like('/message', qr/No total other benefits total/); # Valid payroll submission -$t->post_ok('/api/org/payroll/add' => json => { +$t->post_ok('/api/v1/organisation/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10',