Skip to content

Commit 2412ac9

Browse files
Add merge request award emoji endpoints (#881)
Co-authored-by: Anton Komarev <1849174+antonkomarev@users.noreply.github.com>
1 parent 7deb9bd commit 2412ac9

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
* Add support for additional filters and ordering options in `MergeRequests::all`
2626
* Add support for project CI/CD job token scope endpoints
2727
* Add support for merge request resource label event endpoints
28+
* Add support for merge request and merge request note award emoji endpoints
2829
* Add support for `Environments::stopStale`
2930
* Add support for `last_activity_after` and `last_activity_before` in `Groups::projects`
3031
* Fix `Projects::pipelines` date filters to include time information

‎src/Api/MergeRequests.php‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@ public function removeNote(int|string $project_id, int $mr_iid, int $note_id): m
342342
return $this->delete($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id)));
343343
}
344344

345+
public function showNoteAwardEmojis(int|string $project_id, int $mr_iid, int $note_id): mixed
346+
{
347+
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji'));
348+
}
349+
350+
public function showNoteAwardEmoji(int|string $project_id, int $mr_iid, int $note_id, int $award_id): mixed
351+
{
352+
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji/'.self::encodePath($award_id)));
353+
}
354+
355+
public function addNoteAwardEmoji(int|string $project_id, int $mr_iid, int $note_id, string $name): mixed
356+
{
357+
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji'), ['name' => $name]);
358+
}
359+
360+
public function removeNoteAwardEmoji(int|string $project_id, int $mr_iid, int $note_id, int $award_id): mixed
361+
{
362+
return $this->delete($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/notes/'.self::encodePath($note_id).'/award_emoji/'.self::encodePath($award_id)));
363+
}
364+
345365
public function showDiscussions(int|string $project_id, int $mr_iid): mixed
346366
{
347367
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid)).'/discussions');
@@ -429,6 +449,16 @@ public function awardEmoji(int|string $project_id, int $mr_iid): mixed
429449
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji'));
430450
}
431451

452+
public function showAwardEmoji(int|string $project_id, int $mr_iid, int $award_id): mixed
453+
{
454+
return $this->get($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji/'.self::encodePath($award_id)));
455+
}
456+
457+
public function addAwardEmoji(int|string $project_id, int $mr_iid, string $name): mixed
458+
{
459+
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji'), ['name' => $name]);
460+
}
461+
432462
public function removeAwardEmoji(int|string $project_id, int $mr_iid, int $award_id): mixed
433463
{
434464
return $this->delete($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/award_emoji/'.self::encodePath($award_id)));

‎tests/Api/MergeRequestsTest.php‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,68 @@ public function shouldRemoveNote(): void
410410
$this->assertEquals($expectedBool, $api->removeNote(1, 2, 3));
411411
}
412412

413+
#[Test]
414+
public function shouldShowMergeRequestNoteAwardEmojis(): void
415+
{
416+
$expectedArray = [
417+
['id' => 1, 'name' => 'sparkles'],
418+
['id' => 2, 'name' => 'heart_eyes'],
419+
];
420+
421+
$api = $this->getApiMock();
422+
$api->expects($this->once())
423+
->method('get')
424+
->with('projects/1/merge_requests/2/notes/3/award_emoji')
425+
->willReturn($expectedArray)
426+
;
427+
428+
$this->assertEquals($expectedArray, $api->showNoteAwardEmojis(1, 2, 3));
429+
}
430+
431+
#[Test]
432+
public function shouldShowMergeRequestNoteAwardEmoji(): void
433+
{
434+
$expectedArray = ['id' => 4, 'name' => 'sparkles'];
435+
436+
$api = $this->getApiMock();
437+
$api->expects($this->once())
438+
->method('get')
439+
->with('projects/1/merge_requests/2/notes/3/award_emoji/4')
440+
->willReturn($expectedArray)
441+
;
442+
443+
$this->assertEquals($expectedArray, $api->showNoteAwardEmoji(1, 2, 3, 4));
444+
}
445+
446+
#[Test]
447+
public function shouldAddMergeRequestNoteAwardEmoji(): void
448+
{
449+
$expectedArray = ['id' => 4, 'name' => 'sparkles'];
450+
451+
$api = $this->getApiMock();
452+
$api->expects($this->once())
453+
->method('post')
454+
->with('projects/1/merge_requests/2/notes/3/award_emoji', ['name' => 'sparkles'])
455+
->willReturn($expectedArray)
456+
;
457+
458+
$this->assertEquals($expectedArray, $api->addNoteAwardEmoji(1, 2, 3, 'sparkles'));
459+
}
460+
461+
#[Test]
462+
public function shouldRemoveMergeRequestNoteAwardEmoji(): void
463+
{
464+
$expectedBool = true;
465+
466+
$api = $this->getApiMock();
467+
$api->expects($this->once())
468+
->method('delete')
469+
->with('projects/1/merge_requests/2/notes/3/award_emoji/4')
470+
->willReturn($expectedBool);
471+
472+
$this->assertEquals($expectedBool, $api->removeNoteAwardEmoji(1, 2, 3, 4));
473+
}
474+
413475
#[Test]
414476
public function shouldGetMergeRequestParticipants(): void
415477
{
@@ -705,6 +767,36 @@ public function shouldIssueMergeRequestAwardEmoji(): void
705767
$this->assertEquals($expectedArray, $api->awardEmoji(1, 2));
706768
}
707769

770+
#[Test]
771+
public function shouldShowMergeRequestAwardEmoji(): void
772+
{
773+
$expectedArray = ['id' => 3, 'name' => 'sparkles'];
774+
775+
$api = $this->getApiMock();
776+
$api->expects($this->once())
777+
->method('get')
778+
->with('projects/1/merge_requests/2/award_emoji/3')
779+
->willReturn($expectedArray)
780+
;
781+
782+
$this->assertEquals($expectedArray, $api->showAwardEmoji(1, 2, 3));
783+
}
784+
785+
#[Test]
786+
public function shouldAddMergeRequestAwardEmoji(): void
787+
{
788+
$expectedArray = ['id' => 3, 'name' => 'sparkles'];
789+
790+
$api = $this->getApiMock();
791+
$api->expects($this->once())
792+
->method('post')
793+
->with('projects/1/merge_requests/2/award_emoji', ['name' => 'sparkles'])
794+
->willReturn($expectedArray)
795+
;
796+
797+
$this->assertEquals($expectedArray, $api->addAwardEmoji(1, 2, 'sparkles'));
798+
}
799+
708800
#[Test]
709801
public function shouldRevokeMergeRequestAwardEmoji(): void
710802
{

0 commit comments

Comments
 (0)