89 lines
1.6 KiB
Perl
89 lines
1.6 KiB
Perl
#! /usr/bin/env perl
|
|
|
|
package API::Projects;
|
|
|
|
use v5.10.1;
|
|
use strict;
|
|
use warnings;
|
|
|
|
use ACU::API::Base;
|
|
|
|
sub add($)
|
|
{
|
|
my $project_name = shift;
|
|
|
|
my $res = API::Base::send('ResultHandler', "projects/projects/add.xml", [ project_name => $project_name ]);
|
|
|
|
if ($res->{result} eq '0') {
|
|
say "Projet ajouté correctement";
|
|
}
|
|
else {
|
|
say "Ajout non ok: ".$res->{message};
|
|
}
|
|
}
|
|
|
|
sub get($;$)
|
|
{
|
|
my $project_name = shift;
|
|
my $year = shift;
|
|
|
|
my $res = API::Base::get('ProjectMemberHandler', "projects/projects/get/$project_name.xml");
|
|
|
|
if ($res->{result} && $res->{result} eq '0') {
|
|
say "Projet ajouté correctement";
|
|
}
|
|
else {
|
|
say "Ajout non ok: ".$res->{message};
|
|
}
|
|
|
|
return $res;
|
|
}
|
|
|
|
sub get_users($;$)
|
|
{
|
|
my $project_name = shift;
|
|
my $year = shift;
|
|
|
|
my $url;
|
|
if ($year) {
|
|
$url = "projects/projects/users/$project_name/$year.xml";
|
|
}
|
|
else {
|
|
$url = "projects/projects/users/$project_name.xml";
|
|
}
|
|
|
|
my $res = API::Base::get('ProjectMemberHandler', $url);
|
|
|
|
if ($res->{result} && $res->{result} eq '0') {
|
|
say "Projet ajouté correctement";
|
|
}
|
|
else {
|
|
say "Ajout non ok: ".$res->{message};
|
|
}
|
|
|
|
return $res;
|
|
}
|
|
|
|
sub add_grades($;$)
|
|
{
|
|
my $project_name = shift;
|
|
my $year = shift;
|
|
my %data;
|
|
|
|
|
|
$data{project_name} = $project_name if ($project_name);
|
|
$data{year} = $year if ($year);
|
|
|
|
my $res = API::Base::send('ResultHandler', "projects/notes/add.xml", \%data);
|
|
|
|
if ($res->{result} && $res->{result} eq '0') {
|
|
say "Ajout de notes effectué.";
|
|
}
|
|
else {
|
|
say "Ajout non ok: ".$res->{message};
|
|
}
|
|
|
|
return $res;
|
|
}
|
|
|
|
1;
|