add subscription process delete endpoint

Cette révision appartient à :
Daniel Seifert 2025-01-03 09:25:09 +01:00
Parent abcfea9480
révision 395d6c3b2e
2 fichiers modifiés avec 43 ajouts et 0 suppressions

Voir le fichier

@ -102,4 +102,17 @@ class SubscriptionProcess extends Model
)
);
}
/**
* @throws BaseException
*/
public function delete(string $listId): bool
{
return (bool) current(
$this->connection->requestAndParse(
'DELETE',
'list/'.urlencode(trim($listId)).'.json'
)
);
}
}

Voir le fichier

@ -199,4 +199,34 @@ class SubscriptionProcessTest extends IntegrationTestCase
yield 'missing or empty list id' => [new Response(404, [], '["Kein Opt-In-Prozess mit dieser ID."]'), null, true];
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
}
/**
* @test
* @throws ReflectionException
* @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::delete
* @dataProvider deleteDataProvider
*/
public function testDelete(ResponseInterface $response, ?bool $expected, bool $expectException = false): void
{
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
}
$this->assertEquals(
$expected,
$this->callMethod(
$sut,
'delete',
['2354758']
)
);
}
public static function deleteDataProvider(): Generator
{
yield 'success' => [new Response(200, [], '[true]'), true];
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
}
}