mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add a patch resource api endpoint (wip)
This commit is contained in:
parent
af2eca0d03
commit
4f1540c541
@ -413,6 +413,25 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Resource::class,
|
||||
'name' => 'accompanying_period_resource',
|
||||
'base_path' => '/api/1.0/person/accompanying-period/resource',
|
||||
'base_role' => 'ROLE_USER',
|
||||
'actions' => [
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => false,
|
||||
Request::METHOD_PATCH => true,
|
||||
Request::METHOD_HEAD => false,
|
||||
Request::METHOD_DELETE => false,
|
||||
],
|
||||
'roles' => [
|
||||
//Request::METHOD_PATCH => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Origin::class,
|
||||
'name' => 'accompanying_period_origin',
|
||||
|
@ -47,7 +47,7 @@ class Resource
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
* @Groups({"read", "write"})
|
||||
*/
|
||||
private string $comment = '';
|
||||
private ?string $comment = '';
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
|
@ -353,6 +353,23 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
patchResource({ commit }, payload) {
|
||||
const body = { type: "accompanying_period_resource" };
|
||||
body['resource'] = {
|
||||
type: payload.result.type,
|
||||
id: payload.result.id
|
||||
};
|
||||
const url = `/api/1.0/person/accompanying-course/resource/${id}.json`;
|
||||
|
||||
return makeFetch('PATCH', url, body)
|
||||
.then((response) => {
|
||||
commit('patchResource', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('catchError', error);
|
||||
throw error;
|
||||
})
|
||||
},
|
||||
/**
|
||||
* On The Fly
|
||||
*/
|
||||
|
@ -38,6 +38,15 @@ class AccompanyingPeriodResourceNormalizer implements DenormalizerAwareInterface
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function normalize($resource, $format = null, array $context = [])
|
||||
{
|
||||
return [
|
||||
'type' => 'accompanying_period_resource',
|
||||
'id' => $resource->getId(),
|
||||
'comment' => $resource->getComment()
|
||||
];
|
||||
}
|
||||
|
||||
public function denormalize($data, $type, $format = null, array $context = [])
|
||||
{
|
||||
$resource = $this->extractObjectToPopulate($type, $context);
|
||||
|
@ -752,7 +752,6 @@ paths:
|
||||
resource:
|
||||
type: thirdparty
|
||||
id: 100
|
||||
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
@ -1234,6 +1233,54 @@ paths:
|
||||
404:
|
||||
description: "Not found"
|
||||
|
||||
/1.0/person/accompanying-period/resource/{id}.json:
|
||||
patch:
|
||||
tags:
|
||||
- accompanying-course-resource
|
||||
summary: "Alter the resource"
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
description: The resource's id
|
||||
schema:
|
||||
type: integer
|
||||
format: integer
|
||||
minimum: 1
|
||||
requestBody:
|
||||
description: "A resource"
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum:
|
||||
- "accompanying_period_resource"
|
||||
#id:
|
||||
# type: integer
|
||||
comment:
|
||||
type: string
|
||||
required:
|
||||
- type
|
||||
examples:
|
||||
Set the resource comment:
|
||||
value:
|
||||
type: accompanying_period_resource
|
||||
#id: 0
|
||||
comment: my judicious comment
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
404:
|
||||
description: "Not found"
|
||||
200:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "object with validation errors"
|
||||
|
||||
/1.0/person/household.json:
|
||||
get:
|
||||
tags:
|
||||
|
Loading…
x
Reference in New Issue
Block a user