From e388d360ac62ba81c736318061314fa152bb7d83 Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 18 Sep 2017 17:26:35 +0100 Subject: [PATCH] Changed endpoints in API --- lib/Pear/LocalLoop.pm | 6 ++--- .../LocalLoop/Controller/Api/Organisation.pm | 6 ++--- t/api/organisation.t | 26 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index 2130334..f41a504 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -144,9 +144,9 @@ 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')->to('api-organisation#post_payroll'); - $api->post('/org/supplier')->to('api-organisation#post_supplier'); - $api->post('/org/employee')->to('api-organisation#post_employee'); + $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'); diff --git a/lib/Pear/LocalLoop/Controller/Api/Organisation.pm b/lib/Pear/LocalLoop/Controller/Api/Organisation.pm index effd9ee..7182a68 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Organisation.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Organisation.pm @@ -62,7 +62,7 @@ has error_messages => sub { }; }; -sub post_payroll { +sub post_payroll_add { my $c = shift; my $user = $c->stash->{api_user}; @@ -115,7 +115,7 @@ sub post_payroll { }); } -sub post_supplier { +sub post_supplier_add { my $c = shift; my $user = $c->stash->{api_user}; @@ -148,7 +148,7 @@ sub post_supplier { }); } -sub post_employee { +sub post_employee_add { my $c = shift; my $user = $c->stash->{api_user}; diff --git a/t/api/organisation.t b/t/api/organisation.t index 7f05b87..2331858 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') +$t->post_ok('/api/org/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' => json => {}) +$t->post_ok('/api/org/payroll/add' => json => {}) ->json_is('/success', Mojo::JSON->false); # no session key -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { entry_period => '2017-12', employee_amount => '10', local_employee_amount => '10', @@ -49,7 +49,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/Invalid Session/); # No entry_period -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, employee_amount => '10', local_employee_amount => '10', @@ -65,7 +65,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/No entry period/); # No employee_amount -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/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' => json => { ->json_like('/message', qr/No employee amount/); # No local_employee_amount -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -97,7 +97,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/local employee amount/); # No gross_payroll -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -113,7 +113,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/No gross payroll/); # No payroll_income_tax -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -129,7 +129,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/No total income tax/); # No payroll_employee_ni -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -145,7 +145,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/No total employee NI/); # No payroll_employer_ni -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -161,7 +161,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/total employer NI/); # No payroll_total_pension -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -177,7 +177,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/No total total pension/); # No payroll_other_benefit -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10', @@ -193,7 +193,7 @@ $t->post_ok('/api/org/payroll' => json => { ->json_like('/message', qr/No total other benefits total/); # Valid payroll submission -$t->post_ok('/api/org/payroll' => json => { +$t->post_ok('/api/org/payroll/add' => json => { session_key => $session_key, entry_period => '2017-12', employee_amount => '10',