can get endpoints raw element, get entity by a separate call
Cette révision appartient à :
Parent
55bad44a22
révision
a88bb6d33f
@ -339,7 +339,7 @@ class Subscriber extends ArrayCollection
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentTags = $this->endpoint->get($this->getId())->getTags();
|
$currentTags = $this->endpoint->getEntity($this->getId())->getTags();
|
||||||
|
|
||||||
$removeTags = array_diff($currentTags->toArray(), $this->getTags()->toArray());
|
$removeTags = array_diff($currentTags->toArray(), $this->getTags()->toArray());
|
||||||
if (count($removeTags)) {
|
if (count($removeTags)) {
|
||||||
|
@ -88,14 +88,20 @@ class Account extends Model
|
|||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
public function get(): AccountEntity
|
public function get(): array
|
||||||
{
|
{
|
||||||
$data = $this->connection->requestAndParse(
|
return $this->connection->requestAndParse(
|
||||||
'GET',
|
'GET',
|
||||||
'account.json'
|
'account.json'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return new AccountEntity($data, $this);
|
/**
|
||||||
|
* @throws BaseException
|
||||||
|
*/
|
||||||
|
public function getEntity(): AccountEntity
|
||||||
|
{
|
||||||
|
return new AccountEntity($this->get(), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,14 +41,20 @@ class Field extends Model
|
|||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
public function get(string $fieldId): FieldEntity
|
public function get(string $fieldId): array
|
||||||
{
|
{
|
||||||
$data = $this->connection->requestAndParse(
|
return $this->connection->requestAndParse(
|
||||||
'GET',
|
'GET',
|
||||||
'field/'.urlencode(trim($fieldId)).'.json'
|
'field/'.urlencode(trim($fieldId)).'.json'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return new FieldEntity($data, $this);
|
/**
|
||||||
|
* @throws BaseException
|
||||||
|
*/
|
||||||
|
public function getEntity(string $fieldId): FieldEntity
|
||||||
|
{
|
||||||
|
return new FieldEntity($this->get($fieldId), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,14 +90,20 @@ class Subscriber extends Model
|
|||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
public function get(string $subscriberId): SubscriberEntity
|
public function get(string $subscriberId): array
|
||||||
{
|
{
|
||||||
$data = $this->connection->requestAndParse(
|
return $this->connection->requestAndParse(
|
||||||
'GET',
|
'GET',
|
||||||
'subscriber/'.urlencode(trim($subscriberId)).'.json'
|
'subscriber/'.urlencode(trim($subscriberId)).'.json'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return new SubscriberEntity($data, $this);
|
/**
|
||||||
|
* @throws BaseException
|
||||||
|
*/
|
||||||
|
public function getEntity(string $subscriberId): SubscriberEntity
|
||||||
|
{
|
||||||
|
return new SubscriberEntity($this->get($subscriberId), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -352,7 +358,7 @@ class Subscriber extends Model
|
|||||||
$id = $this->subscribe($newMailAddress ?? $mailAddress, null, null, $fields, $smsNumber);
|
$id = $this->subscribe($newMailAddress ?? $mailAddress, null, null, $fields, $smsNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->get($id);
|
return $this->getEntity($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -360,7 +366,7 @@ class Subscriber extends Model
|
|||||||
*/
|
*/
|
||||||
public function getSubscriberByMailAddress(string $mailAddress): SubscriberEntity
|
public function getSubscriberByMailAddress(string $mailAddress): SubscriberEntity
|
||||||
{
|
{
|
||||||
return $this->get(
|
return $this->getEntity(
|
||||||
$this->search($mailAddress)
|
$this->search($mailAddress)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,20 @@ class SubscriptionProcess extends Model
|
|||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
public function get(string $listId): SubscriptionEntity
|
public function get(string $listId): array
|
||||||
{
|
{
|
||||||
$data = $this->connection->requestAndParse(
|
return $this->connection->requestAndParse(
|
||||||
'GET',
|
'GET',
|
||||||
'list/'.urlencode(trim($listId)).'.json'
|
'list/'.urlencode(trim($listId)).'.json'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return new SubscriptionEntity($data);
|
/**
|
||||||
|
* @throws BaseException
|
||||||
|
*/
|
||||||
|
public function getEntity(string $listId): SubscriptionEntity
|
||||||
|
{
|
||||||
|
return new SubscriptionEntity($this->get($listId), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,14 +42,20 @@ class Tag extends Model
|
|||||||
/**
|
/**
|
||||||
* @throws BaseException
|
* @throws BaseException
|
||||||
*/
|
*/
|
||||||
public function get(string $tagId): TagEntity
|
public function get(string $tagId): array
|
||||||
{
|
{
|
||||||
$data = $this->connection->requestAndParse(
|
return $this->connection->requestAndParse(
|
||||||
'GET',
|
'GET',
|
||||||
'tag/'.urlencode(trim($tagId)).'.json'
|
'tag/'.urlencode(trim($tagId)).'.json'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return new TagEntity($data, $this);
|
/**
|
||||||
|
* @throws BaseException
|
||||||
|
*/
|
||||||
|
public function getEntity(string $tagId): TagEntity
|
||||||
|
{
|
||||||
|
return new TagEntity($this->get($tagId), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,6 +136,7 @@ class AccountTest extends IntegrationTestCase
|
|||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @covers \D3\KlicktippPhpClient\Resources\Account::get
|
* @covers \D3\KlicktippPhpClient\Resources\Account::get
|
||||||
|
* @covers \D3\KlicktippPhpClient\Resources\Account::getEntity
|
||||||
* @dataProvider getDataProvider
|
* @dataProvider getDataProvider
|
||||||
*/
|
*/
|
||||||
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
||||||
@ -148,7 +149,7 @@ class AccountTest extends IntegrationTestCase
|
|||||||
|
|
||||||
$return = $this->callMethod(
|
$return = $this->callMethod(
|
||||||
$sut,
|
$sut,
|
||||||
'get'
|
'getEntity'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(AccountEntity::class, $return);
|
$this->assertInstanceOf(AccountEntity::class, $return);
|
||||||
|
@ -99,6 +99,7 @@ class FieldTest extends IntegrationTestCase
|
|||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @covers \D3\KlicktippPhpClient\Resources\Field::get
|
* @covers \D3\KlicktippPhpClient\Resources\Field::get
|
||||||
|
* @covers \D3\KlicktippPhpClient\Resources\Field::getEntity
|
||||||
* @dataProvider getDataProvider
|
* @dataProvider getDataProvider
|
||||||
*/
|
*/
|
||||||
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
||||||
@ -111,7 +112,7 @@ class FieldTest extends IntegrationTestCase
|
|||||||
|
|
||||||
$return = $this->callMethod(
|
$return = $this->callMethod(
|
||||||
$sut,
|
$sut,
|
||||||
'get',
|
'getEntity',
|
||||||
['12514414']
|
['12514414']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ class SubscriberTest extends IntegrationTestCase
|
|||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @covers \D3\KlicktippPhpClient\Resources\Subscriber::get
|
* @covers \D3\KlicktippPhpClient\Resources\Subscriber::get
|
||||||
|
* @covers \D3\KlicktippPhpClient\Resources\Subscriber::getEntity
|
||||||
* @dataProvider getDataProvider
|
* @dataProvider getDataProvider
|
||||||
*/
|
*/
|
||||||
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
||||||
@ -105,7 +106,7 @@ class SubscriberTest extends IntegrationTestCase
|
|||||||
|
|
||||||
$return = $this->callMethod(
|
$return = $this->callMethod(
|
||||||
$sut,
|
$sut,
|
||||||
'get',
|
'getEntity',
|
||||||
['155988456']
|
['155988456']
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -622,14 +623,14 @@ class SubscriberTest extends IntegrationTestCase
|
|||||||
|
|
||||||
$sut = $this->getMockBuilder(Subscriber::class)
|
$sut = $this->getMockBuilder(Subscriber::class)
|
||||||
->setConstructorArgs([$this->getConnectionMock($responses)])
|
->setConstructorArgs([$this->getConnectionMock($responses)])
|
||||||
->onlyMethods(['search', 'update', 'subscribe', 'get'])
|
->onlyMethods(['search', 'update', 'subscribe', 'getEntity'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$sut->expects($this->once())->method('search')->will(
|
$sut->expects($this->once())->method('search')->will(
|
||||||
$foundId ? $this->returnValue($foundId) : $this->throwException(new BaseException())
|
$foundId ? $this->returnValue($foundId) : $this->throwException(new BaseException())
|
||||||
);
|
);
|
||||||
$sut->expects($updateInvocations)->method('update')->willReturn(true);
|
$sut->expects($updateInvocations)->method('update')->willReturn(true);
|
||||||
$sut->expects($subscribeInvocations)->method('subscribe')->willReturn('myId');
|
$sut->expects($subscribeInvocations)->method('subscribe')->willReturn('myId');
|
||||||
$sut->expects($this->once())->method('get')->with(
|
$sut->expects($this->once())->method('getEntity')->with(
|
||||||
$this->identicalTo('myId')
|
$this->identicalTo('myId')
|
||||||
)->willReturn($entityMock);
|
)->willReturn($entityMock);
|
||||||
|
|
||||||
@ -678,10 +679,10 @@ class SubscriberTest extends IntegrationTestCase
|
|||||||
|
|
||||||
$sut = $this->getMockBuilder(Subscriber::class)
|
$sut = $this->getMockBuilder(Subscriber::class)
|
||||||
->setConstructorArgs([$this->getConnectionMock($responses)])
|
->setConstructorArgs([$this->getConnectionMock($responses)])
|
||||||
->onlyMethods(['search', 'get'])
|
->onlyMethods(['search', 'getEntity'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$sut->expects($this->once())->method('search')->willReturn('myId');
|
$sut->expects($this->once())->method('search')->willReturn('myId');
|
||||||
$sut->expects($this->once())->method('get')->with(
|
$sut->expects($this->once())->method('getEntity')->with(
|
||||||
$this->identicalTo('myId')
|
$this->identicalTo('myId')
|
||||||
)->willReturn(new SubscriberEntity());
|
)->willReturn(new SubscriberEntity());
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
|
|||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::get
|
* @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::get
|
||||||
|
* @covers \D3\KlicktippPhpClient\Resources\SubscriptionProcess::getEntity
|
||||||
* @dataProvider getDataProvider
|
* @dataProvider getDataProvider
|
||||||
*/
|
*/
|
||||||
public function testGet(ResponseInterface $response, ?Subscription $expected, bool $expectException = false)
|
public function testGet(ResponseInterface $response, ?Subscription $expected, bool $expectException = false)
|
||||||
@ -84,7 +85,7 @@ class SubscriptionProcessTest extends IntegrationTestCase
|
|||||||
$expected,
|
$expected,
|
||||||
$this->callMethod(
|
$this->callMethod(
|
||||||
$sut,
|
$sut,
|
||||||
'get',
|
'getEntity',
|
||||||
['470370']
|
['470370']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -70,6 +70,7 @@ class TagTest extends IntegrationTestCase
|
|||||||
* @test
|
* @test
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @covers \D3\KlicktippPhpClient\Resources\Tag::get
|
* @covers \D3\KlicktippPhpClient\Resources\Tag::get
|
||||||
|
* @covers \D3\KlicktippPhpClient\Resources\Tag::getEntity
|
||||||
* @dataProvider getDataProvider
|
* @dataProvider getDataProvider
|
||||||
*/
|
*/
|
||||||
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
public function testGet(ResponseInterface $response, ?array $expected, bool $expectException = false)
|
||||||
@ -82,7 +83,7 @@ class TagTest extends IntegrationTestCase
|
|||||||
|
|
||||||
$return = $this->callMethod(
|
$return = $this->callMethod(
|
||||||
$sut,
|
$sut,
|
||||||
'get',
|
'getEntity',
|
||||||
['12514414']
|
['12514414']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -640,9 +640,9 @@ class SubscriberTest extends TestCase
|
|||||||
|
|
||||||
$endpointMock = $this->getMockBuilder(SubscriberEndpoint::class)
|
$endpointMock = $this->getMockBuilder(SubscriberEndpoint::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->onlyMethods(['get', 'tag', 'untag'])
|
->onlyMethods(['getEntity', 'tag', 'untag'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$endpointMock->expects($endpointInvocation)->method('get')->willReturn($entityMock);
|
$endpointMock->expects($endpointInvocation)->method('getEntity')->willReturn($entityMock);
|
||||||
$endpointMock->expects($setTagInvocation)->method('tag')->willReturn(true);
|
$endpointMock->expects($setTagInvocation)->method('tag')->willReturn(true);
|
||||||
$endpointMock->expects($removeTagInvocation)->method('untag')->willReturn(true);
|
$endpointMock->expects($removeTagInvocation)->method('untag')->willReturn(true);
|
||||||
|
|
||||||
|
Chargement…
x
Référencer dans un nouveau ticket
Bloquer un utilisateur