Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed AI_PLAN.md
Empty file.
21 changes: 19 additions & 2 deletions src/DocScan/Session/Create/SdkConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class SdkConfig implements \JsonSerializable
*/
private $brandId;

/**
* @var array<string>|null
*/
private $suppressedScreens;

/**
* @param string|null $allowedCaptureMethods
* @param string|null $primaryColour
Expand All @@ -99,6 +104,7 @@ class SdkConfig implements \JsonSerializable
* @param string|null $darkMode
* @param string|null $primaryColourDarkMode
* @param string|null $brandId
* @param array<string>|null $suppressedScreens
*/
public function __construct(
?string $allowedCaptureMethods,
Expand All @@ -115,7 +121,8 @@ public function __construct(
?string $biometricConsentFlow = null,
?string $darkMode = null,
?string $primaryColourDarkMode = null,
?string $brandId = null
?string $brandId = null,
?array $suppressedScreens = null
) {
$this->allowedCaptureMethods = $allowedCaptureMethods;
$this->primaryColour = $primaryColour;
Expand All @@ -134,6 +141,7 @@ public function __construct(
$this->darkMode = $darkMode;
$this->primaryColourDarkMode = $primaryColourDarkMode;
$this->brandId = $brandId;
$this->suppressedScreens = $suppressedScreens;
}

/**
Expand All @@ -156,7 +164,8 @@ public function jsonSerialize(): \stdClass
'biometric_consent_flow' => $this->getBiometricConsentFlow(),
'dark_mode' => $this->getDarkMode(),
'primary_colour_dark_mode' => $this->getPrimaryColourDarkMode(),
'brand_id' => $this->getBrandId()
'brand_id' => $this->getBrandId(),
'suppressed_screens' => $this->getSuppressedScreens()
]);
}

Expand Down Expand Up @@ -279,4 +288,12 @@ public function getBrandId(): ?string
{
return $this->brandId;
}

/**
* @return array<string>|null
*/
public function getSuppressedScreens(): ?array
{
return $this->suppressedScreens;
}
}
18 changes: 17 additions & 1 deletion src/DocScan/Session/Create/SdkConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ class SdkConfigBuilder
*/
private $brandId;

/**
* @var array<string>|null
*/
private $suppressedScreens;

public function withAllowsCamera(): self
{
return $this->withAllowedCaptureMethod(self::CAMERA);
Expand Down Expand Up @@ -251,6 +256,16 @@ public function withBrandId(string $brandId): self
return $this;
}

/**
* @param array<string> $suppressedScreens
* @return $this
*/
public function withSuppressedScreens(array $suppressedScreens): self
{
$this->suppressedScreens = $suppressedScreens;
return $this;
}

public function build(): SdkConfig
{
return new SdkConfig(
Expand All @@ -268,7 +283,8 @@ public function build(): SdkConfig
$this->biometricConsentFlow,
$this->darkMode,
$this->primaryColourDarkMode,
$this->brandId
$this->brandId,
$this->suppressedScreens
);
}
}
73 changes: 73 additions & 0 deletions tests/DocScan/Session/Create/SdkConfigBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SdkConfigBuilderTest extends TestCase
private const SOME_DARK_MODE = 'someDarkMode';
private const SOME_PRIMARY_COLOUR_DARK_MODE = 'somePrimaryColourDarkMode';
private const SOME_BRAND_ID = 'someBrandId';
private const SOME_SUPPRESSED_SCREEN = 'someScreen';

/**
* @test
Expand All @@ -41,6 +42,7 @@ class SdkConfigBuilderTest extends TestCase
* @covers ::withPrivacyPolicyUrl
* @covers ::withAllowHandoff
* @covers ::withBrandId
* @covers ::withSuppressedScreens
* @covers \Yoti\DocScan\Session\Create\SdkConfig::__construct
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getAllowedCaptureMethods
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getPrimaryColour
Expand All @@ -55,9 +57,12 @@ class SdkConfigBuilderTest extends TestCase
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getDarkMode
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getPrimaryColourDarkMode
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getBrandId
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getSuppressedScreens
*/
public function shouldCorrectlyBuildSdkConfig()
{
$suppressedScreens = [self::SOME_SUPPRESSED_SCREEN, 'anotherScreen'];

$result = (new SdkConfigBuilder())
->withAllowedCaptureMethod(self::SOME_CAPTURE_METHOD)
->withPrimaryColour(self::SOME_PRIMARY_COLOUR)
Expand All @@ -73,6 +78,7 @@ public function shouldCorrectlyBuildSdkConfig()
->withDarkMode(self::SOME_DARK_MODE)
->withPrimaryColourDarkMode(self::SOME_PRIMARY_COLOUR_DARK_MODE)
->withBrandId(self::SOME_BRAND_ID)
->withSuppressedScreens($suppressedScreens)
->build();

$this->assertEquals(self::SOME_CAPTURE_METHOD, $result->getAllowedCaptureMethods());
Expand All @@ -89,6 +95,7 @@ public function shouldCorrectlyBuildSdkConfig()
$this->assertEquals(self::SOME_DARK_MODE, $result->getDarkMode());
$this->assertEquals(self::SOME_PRIMARY_COLOUR_DARK_MODE, $result->getPrimaryColourDarkMode());
$this->assertEquals(self::SOME_BRAND_ID, $result->getBrandId());
$this->assertEquals($suppressedScreens, $result->getSuppressedScreens());
}

/**
Expand Down Expand Up @@ -348,4 +355,70 @@ public function shouldSetCorrectValueWithDarkModeOff()

$this->assertEquals('OFF', $result->getDarkMode());
}

/**
* @test
* @covers ::withSuppressedScreens
* @covers ::build
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getSuppressedScreens
*/
public function shouldSetSuppressedScreens()
{
$suppressedScreens = ['screen1', 'screen2', 'screen3'];

$result = (new SdkConfigBuilder())
->withSuppressedScreens($suppressedScreens)
->build();

$this->assertEquals($suppressedScreens, $result->getSuppressedScreens());
}

/**
* @test
* @covers ::build
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getSuppressedScreens
*/
public function suppressedScreensShouldBeNullWhenNotSet()
{
$result = (new SdkConfigBuilder())->build();

$this->assertNull($result->getSuppressedScreens());
}

/**
* @test
* @covers \Yoti\DocScan\Session\Create\SdkConfig::jsonSerialize
*/
public function shouldSerializeSuppressedScreensToJson()
{
$suppressedScreens = ['screen1', 'screen2'];

$result = (new SdkConfigBuilder())
->withSuppressedScreens($suppressedScreens)
->build();

$expected = [
'suppressed_screens' => $suppressedScreens
];

$this->assertJsonStringEqualsJsonString(json_encode($expected), json_encode($result));
}

/**
* @test
* @covers \Yoti\DocScan\Session\Create\SdkConfig::jsonSerialize
*/
public function shouldNotSerializeSuppressedScreensWhenEmpty()
{
$result = (new SdkConfigBuilder())
->withSuppressedScreens([])
->build();

// Empty arrays should still be serialized (different from null)
$json = json_encode($result);
$decoded = json_decode($json, true);

$this->assertArrayHasKey('suppressed_screens', $decoded);
$this->assertEquals([], $decoded['suppressed_screens']);
}
}