Changed endpoints in API

This commit is contained in:
Finn 2017-09-18 17:26:35 +01:00
parent 616181def3
commit e388d360ac
3 changed files with 19 additions and 19 deletions

View file

@ -144,9 +144,9 @@ sub startup {
$api->post('/stats')->to('api-stats#post_index'); $api->post('/stats')->to('api-stats#post_index');
$api->post('/stats/leaderboard')->to('api-stats#post_leaderboards'); $api->post('/stats/leaderboard')->to('api-stats#post_leaderboards');
$api->post('/outgoing-transactions')->to('api-transactions#post_transaction_list_purchases'); $api->post('/outgoing-transactions')->to('api-transactions#post_transaction_list_purchases');
$api->post('/org/payroll')->to('api-organisation#post_payroll'); $api->post('/org/payroll/add')->to('api-organisation#post_payroll_add');
$api->post('/org/supplier')->to('api-organisation#post_supplier'); $api->post('/org/supplier/add')->to('api-organisation#post_supplier_add');
$api->post('/org/employee')->to('api-organisation#post_employee'); $api->post('/org/employee/add')->to('api-organisation#post_employee_add');
my $api_v1 = $api->under('/v1'); my $api_v1 = $api->under('/v1');

View file

@ -62,7 +62,7 @@ has error_messages => sub {
}; };
}; };
sub post_payroll { sub post_payroll_add {
my $c = shift; my $c = shift;
my $user = $c->stash->{api_user}; my $user = $c->stash->{api_user};
@ -115,7 +115,7 @@ sub post_payroll {
}); });
} }
sub post_supplier { sub post_supplier_add {
my $c = shift; my $c = shift;
my $user = $c->stash->{api_user}; my $user = $c->stash->{api_user};
@ -148,7 +148,7 @@ sub post_supplier {
}); });
} }
sub post_employee { sub post_employee_add {
my $c = shift; my $c = shift;
my $user = $c->stash->{api_user}; my $user = $c->stash->{api_user};

View file

@ -23,17 +23,17 @@ my $session_key = $framework->login({
## Payroll Data Submission ## Payroll Data Submission
#No JSON sent #No JSON sent
$t->post_ok('/api/org/payroll') $t->post_ok('/api/org/payroll/add')
->status_is(400) ->status_is(400)
->json_is('/success', Mojo::JSON->false) ->json_is('/success', Mojo::JSON->false)
->json_like('/message', qr/JSON is missing/i); ->json_like('/message', qr/JSON is missing/i);
#Empty JSON #Empty JSON
$t->post_ok('/api/org/payroll' => json => {}) $t->post_ok('/api/org/payroll/add' => json => {})
->json_is('/success', Mojo::JSON->false); ->json_is('/success', Mojo::JSON->false);
# no session key # no session key
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
local_employee_amount => '10', local_employee_amount => '10',
@ -49,7 +49,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/Invalid Session/); ->json_like('/message', qr/Invalid Session/);
# No entry_period # No entry_period
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
employee_amount => '10', employee_amount => '10',
local_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/); ->json_like('/message', qr/No entry period/);
# No employee_amount # No employee_amount
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
local_employee_amount => '10', local_employee_amount => '10',
@ -81,7 +81,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/No employee amount/); ->json_like('/message', qr/No employee amount/);
# No local_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, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
@ -97,7 +97,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/local employee amount/); ->json_like('/message', qr/local employee amount/);
# No gross_payroll # No gross_payroll
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
@ -113,7 +113,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/No gross payroll/); ->json_like('/message', qr/No gross payroll/);
# No payroll_income_tax # No payroll_income_tax
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
@ -129,7 +129,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/No total income tax/); ->json_like('/message', qr/No total income tax/);
# No payroll_employee_ni # No payroll_employee_ni
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
@ -145,7 +145,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/No total employee NI/); ->json_like('/message', qr/No total employee NI/);
# No payroll_employer_ni # No payroll_employer_ni
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
@ -161,7 +161,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/total employer NI/); ->json_like('/message', qr/total employer NI/);
# No payroll_total_pension # No payroll_total_pension
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
@ -177,7 +177,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/No total total pension/); ->json_like('/message', qr/No total total pension/);
# No payroll_other_benefit # No payroll_other_benefit
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',
@ -193,7 +193,7 @@ $t->post_ok('/api/org/payroll' => json => {
->json_like('/message', qr/No total other benefits total/); ->json_like('/message', qr/No total other benefits total/);
# Valid payroll submission # Valid payroll submission
$t->post_ok('/api/org/payroll' => json => { $t->post_ok('/api/org/payroll/add' => json => {
session_key => $session_key, session_key => $session_key,
entry_period => '2017-12', entry_period => '2017-12',
employee_amount => '10', employee_amount => '10',