Skip to content

Commit

Permalink
Another removal of deprecated PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean151 committed Mar 28, 2024
1 parent 9b6dc80 commit 31ef293
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Before anything, you need to configure your feeder to communicate with our API.
### Manage your feeder

- `GET feeders/{id}` will send you current status & parameters of your feeder.
- `PUT feeders/{id}` with a name; to set a name to your feeder. I use the name of my pet for this.
- `PATCH feeders/{id}` with a name; to set a name to your feeder. I use the name of my pet for this.
- `POST feeders/{id}/feed` with an amount between 5 and 150 grams. Trigger an immediate meal.
- `PUT feeders/{id}/amount` with an amount between 5 and 150 grams. Set the amount of food distributed when you press the button.
- `PUT feeders/{id}/planning` with a set of meals. Allow to update the planned meals times and amount. Note that hours should be provided in UTC timezone, and is not sensitive to DST.
Expand Down
3 changes: 2 additions & 1 deletion src/Entity/AlnFeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\ApiResource\Dto\IdentifierInput;
Expand Down Expand Up @@ -77,7 +78,7 @@
],
security: 'is_granted(\'VIEW\', object)',
),
new Put(
new Patch(
openapiContext: [
'summary' => 'Update feeder name',
'description' => 'Update feeder name',
Expand Down
12 changes: 9 additions & 3 deletions tests/Api/PutFeederApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ private function putFeederNameRequest(int $feederId, string $newName, ?UserInter
{
$client = self::createClient();

return $client->request('PUT', "/feeders/{$feederId}", $this->getOptions($authenticatedAs)->setJson([
'name' => $newName,
])->toArray());
$options = $this
->getOptions($authenticatedAs)
->setJson(['name' => $newName])
->setHeaders([
'Accept' => 'application/json',
'Content-Type' => 'application/merge-patch+json',
]);

return $client->request('PATCH', "/feeders/{$feederId}", $options->toArray());
}
}

0 comments on commit 31ef293

Please sign in to comment.