Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP API Endpoints for Organization management #276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

HTTP API Endpoints for Organization management #276

wants to merge 2 commits into from

Conversation

rommem
Copy link

@rommem rommem commented Apr 26, 2019

Bonjour Benjamin,

Merci pour cette application de gestion de congés. Elle est vraiment super.
J'ai développé des endpoints rest pour gérer les organisations via l'API. Je te l'envoie si tu souhaites l'intégrer dans une future version de Jorani.

Bonne continuation,

Mickael

@bbalet bbalet changed the title Création d'endpoints rest pour gérer l'organisation HTTP API Endpoints for Organization management May 2, 2019
$route['api/deletenodeorganization/(:num)'] = 'api/deletenodeorganization/$1';
$route['api/renamenodeorganization/(:num)'] = 'api/renamenodeorganization/$1';
$route['api/attachEmployee/(:num)/(:num)'] = 'api/attachEmployee/$1/$2';
$route['api/detachEmployee/(:num)/(:num)'] = 'api/detachEmployee/$1/$2';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route has two parameters but only one is used

$route['api/deletenodeorganization/(:num)'] = 'api/deletenodeorganization/$1';
$route['api/renamenodeorganization/(:num)'] = 'api/renamenodeorganization/$1';
$route['api/attachEmployee/(:num)/(:num)'] = 'api/attachEmployee/$1/$2';
$route['api/detachEmployee/(:num)/(:num)'] = 'api/detachEmployee/$1/$2';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REST: api/entities/employees/(:num)/detach

$route['api/movenodeorganization/(:num)/(:num)'] = 'api/movenodeorganization/$1/$2';
$route['api/deletenodeorganization/(:num)'] = 'api/deletenodeorganization/$1';
$route['api/renamenodeorganization/(:num)'] = 'api/renamenodeorganization/$1';
$route['api/attachEmployee/(:num)/(:num)'] = 'api/attachEmployee/$1/$2';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REST: api/entities/(:num)/employees/(:num)/attach Or (POST) api/entities/(:num)/employees/(:num)

if (!$this->server->verifyResourceRequest(OAuth2\Request::createFromGlobals())) {
$this->server->getResponse()->send();
} else {
$this->load->model('Organization_model');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Organization_model should be in lower case everywhere

* Get one node of the organization
* @author Mickael ROMMME
*/
public function organization_node($id) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use underscore and use meaningful name, such as getEntity as Organization is composed of entities

@@ -1792,4 +1792,131 @@ private function validateDate($date, $format = 'Y-m-d')
return $d && $d->format($format) === $date;
}

/**
* Get one node of the organization
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing OpenAPI notation, see 32dbe5a

} else {
$this->load->model('Organization_model');
$result = $this->Organization_model->getName($id);
echo json_encode($result);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MIMETYPE (output encoding) is not set. You should rely on the framework, e.g.:

            $this->output
                ->set_content_type('application/json')
                ->set_output(json_encode($result));

}

/**
* Get id of all childrem of one node of the organization
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment more clearly with expected parameters passed in POST request

@bbalet
Copy link
Owner

bbalet commented May 2, 2019

Hi,

Unfortunately, I cannot merge your work without modification.

Starting from 32dbe5a I am adopting an URL format that looks more REST. And I am using the other HTTP verbs (PUT, POST, PATCH).

The HTTP API must be documented with OpenAPI (ex-swagger). This allow us to test is easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants