Skip to content
Merged
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
10 changes: 7 additions & 3 deletions Tests/Feature/Checkout/Mock/CheckoutShowMockClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
class CheckoutShowMockClient extends ClientMock
{
public const BASIC_CHECKOUT = [
'created_at' => '2019-01-16T00:00:00.000000Z',
'deleted_at' => '2019-01-16T00:00:00.000000Z',
'has_redirects' => false,
'id' => 1,
'is_active' => true,
'is_blueprint' => false,
'is_expired' => false,
'name' => 'lorem-ipsum-test',
'pixel' => null,
'preview_url' => 'https://example.com/preview-url',
'primary_color' => '#ff0000',
'return_url' => 'https://example.com/return-url',
'secondary_color' => '#00ff00',
'slug' => 'lorem-ipsum-test',
'url' => 'https://example.com/url',
'created_at' => '2019-01-16T00:00:00.000000Z',
'split_test_id' => null,
'updated_at' => '2019-01-16T00:00:00.000000Z',
'deleted_at' => '2019-01-16T00:00:00.000000Z',
'url' => 'https://example.com/url',
];
public const BASIC_PRODUCT = [
'created_at' => '2019-01-16T00:00:00.000000Z',
Expand Down
4 changes: 4 additions & 0 deletions Tests/Feature/Checkout/ShowCheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ public function it_should_return_basic_order(): void
$checkout = $service->find(1);

static::assertSame(1, $checkout->id());
static::assertFalse($checkout->hasRedirects());
static::assertTrue($checkout->isActive());
static::assertFalse($checkout->isBlueprint());
static::assertFalse($checkout->isExpired());
static::assertSame('lorem-ipsum-test', $checkout->name());
static::assertNull($checkout->pixel());
static::assertSame('https://example.com/preview-url', $checkout->previewUrl());
static::assertSame('#ff0000', $checkout->primaryColor());
static::assertSame('https://example.com/return-url', $checkout->returnUrl());
static::assertSame('#00ff00', $checkout->secondaryColor());
static::assertSame('lorem-ipsum-test', $checkout->slug());
static::assertNull($checkout->splitTestId());
static::assertSame('https://example.com/url', $checkout->url());
static::assertSame('2019-01-16 00:00:00', $checkout->createdAt()->format('Y-m-d H:i:s'));
static::assertSame('2019-01-16 00:00:00', $checkout->updatedAt()->format('Y-m-d H:i:s'));
Expand Down
18 changes: 15 additions & 3 deletions src/Director/BodyTo/BodyToCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,33 @@ public static function build(array $data): Checkout
->setIsExpired($data['is_expired'])
->setName($data['name'])
->setPreviewUrl($data['preview_url'])
->setPrimaryColor($data['primary_color'])
->setPrimaryColor($data['primary_color'] ?? null)
->setReturnUrl($data['return_url'])
->setSecondaryColor($data['secondary_color'])
->setSecondaryColor($data['secondary_color'] ?? null)
->setSlug($data['slug'])
->setUrl($data['url'])
->setHasRedirects($data['has_redirects'])
->setIsBlueprint($data['is_blueprint'])
->setCreatedAt(self::date($data, 'created_at'))
->setUpdatedAt($data['updated_at'] ? self::date($data, 'updated_at') : null)
->setDeletedAt($data['deleted_at'] ? self::date($data, 'deleted_at') : null);

if (array_key_exists('pixel', $data)) {
$checkout->setPixel($data['pixel']);
}

if (array_key_exists('split_test_id', $data)) {
$checkout->setSplitTestId($data['split_test_id']);
}

// Handle optional product relation (for backward compatibility with tests)
if (isset($data['product'])) {
$checkout->setProduct(BodyToProduct::build($data['product']));
}

// Handle optional product pricing relation (for backward compatibility with tests)
if (isset($data['productPricing'])) {
$checkout->setProductPricing(BodyToProductPricing::build($data['pricing']));
$checkout->setProductPricing(BodyToProductPricing::build($data['productPricing']));
}

return $checkout;
Expand Down
58 changes: 55 additions & 3 deletions src/Entity/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ class Checkout extends AbstractEntity

protected bool $allowEmptyRelations;
protected int $id;
protected bool $hasRedirects;
protected bool $isActive;
protected bool $isBlueprint;
protected bool $isExpired;
protected string $name;
protected ?string $pixel;
protected string $previewUrl;
protected string $primaryColor;
protected ?string $primaryColor;
protected Product $product;
protected ProductPricing $productPricing;
protected ?string $returnUrl;
protected ?string $secondaryColor;
protected ?int $splitTestId;
protected string $slug;
protected string $url;
protected DateTimeImmutable $createdAt;
Expand All @@ -39,6 +43,18 @@ public function id(): int
return $this->id;
}

public function hasRedirects(): bool
{
return $this->hasRedirects;
}

public function setHasRedirects(bool $hasRedirects): self
{
$this->hasRedirects = $hasRedirects;

return $this;
}

public function isActive(): bool
{
return $this->isActive;
Expand All @@ -51,6 +67,18 @@ public function setIsActive(bool $isActive): self
return $this;
}

public function isBlueprint(): bool
{
return $this->isBlueprint;
}

public function setIsBlueprint(bool $isBlueprint): self
{
$this->isBlueprint = $isBlueprint;

return $this;
}

public function isExpired(): bool
{
return $this->isExpired;
Expand Down Expand Up @@ -87,12 +115,12 @@ public function setPreviewUrl(string $previewUrl): self
return $this;
}

public function primaryColor(): string
public function primaryColor(): ?string
{
return $this->primaryColor;
}

public function setPrimaryColor(string $primaryColor): self
public function setPrimaryColor(?string $primaryColor): self
{
$this->primaryColor = $primaryColor;

Expand Down Expand Up @@ -134,6 +162,18 @@ public function productPricing(): ProductPricing
return $this->productPricing;
}

public function pixel(): ?string
{
return $this->pixel;
}

public function setPixel(?string $pixel): self
{
$this->pixel = $pixel;

return $this;
}

public function returnUrl(): ?string
{
return $this->returnUrl;
Expand Down Expand Up @@ -170,6 +210,18 @@ public function setSlug(string $slug): self
return $this;
}

public function splitTestId(): ?int
{
return $this->splitTestId;
}

public function setSplitTestId(?int $splitTestId): self
{
$this->splitTestId = $splitTestId;

return $this;
}

public function url(): string
{
return $this->url;
Expand Down
60 changes: 60 additions & 0 deletions src/Entity/CheckoutInternal.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,64 @@ public function setDeletedAt(?DateTimeImmutable $deletedAt): self

return $this;
}

/**
* @internal
*/
public function setHasRedirects(bool $hasRedirects): self
{
$this->hasRedirects = $hasRedirects;

return $this;
}

/**
* @internal
*/
public function setIsBlueprint(bool $isBlueprint): self
{
$this->isBlueprint = $isBlueprint;

return $this;
}

/**
* @internal
*/
public function setPixel(?string $pixel): self
{
$this->pixel = $pixel;

return $this;
}

/**
* @internal
*/
public function setPrimaryColor(?string $primaryColor): self
{
$this->primaryColor = $primaryColor;

return $this;
}

/**
* @internal
*/
public function setSecondaryColor(?string $secondaryColor): self
{
$this->secondaryColor = $secondaryColor;

return $this;
}

/**
* @internal
*/
public function setSplitTestId(?int $splitTestId): self
{
$this->splitTestId = $splitTestId;

return $this;
}
}