add subscription process create endpoint

This commit is contained in:
Daniel Seifert 2025-01-03 09:19:29 +01:00
bovenliggende 549078f1b7
commit abcfea9480
2 gewijzigde bestanden met toevoegingen van 43 en 0 verwijderingen

Bestand weergeven

@ -48,6 +48,24 @@ class SubscriptionProcess extends Model
return new SubscriptionEntity($data);
}
/**
* @throws BaseException
*/
public function create(?string $name): SubscriptionEntity
{
$data = $this->connection->requestAndParse(
'POST',
'list.json',
[
RequestOptions::FORM_PARAMS => array_filter([
'name' => trim($name ?? ''),
]),
]
);
return new SubscriptionEntity($data);
}
/**
* @throws BaseException
*/

Bestand weergeven

@ -113,6 +113,31 @@ class SubscriptionProcessTest extends IntegrationTestCase
yield 'access denied' => [new Response(403, [], '["API Zugriff verweigert"]'), null, true];
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::create
* @dataProvider getDataProvider
*/
public function testCreate(ResponseInterface $response, ?Subscription $expected, bool $expectException = false)
{
$sut = new SubscriptionProcess($this->getConnectionMock($response));
if ($expectException) {
$this->expectException(BaseException::class);
}
$this->assertEquals(
$expected,
$this->callMethod(
$sut,
'create',
['newName']
)
);
}
/**
* @test
* @throws ReflectionException