Skip to content

Add new tokens field #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2021
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
35 changes: 35 additions & 0 deletions migrations/Version20211207210507.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20211207210507 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE tokens ADD initial_launch_date DATE DEFAULT NULL, ADD series_number INT DEFAULT NULL, ADD construction_year DATE DEFAULT NULL, ADD construction_type VARCHAR(50) DEFAULT NULL, ADD roof_type VARCHAR(50) DEFAULT NULL, ADD asset_parking VARCHAR(50) DEFAULT NULL, ADD foundation VARCHAR(50) DEFAULT NULL, ADD heating VARCHAR(50) DEFAULT NULL, ADD cooling VARCHAR(50) DEFAULT NULL, ADD token_id_rules INT DEFAULT NULL, ADD rent_calculation_type VARCHAR(20) DEFAULT NULL');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE tokens DROP initial_launch_date, DROP series_number, DROP construction_year, DROP construction_type, DROP roof_type, DROP asset_parking, DROP foundation, DROP heating, DROP cooling, DROP token_id_rules, DROP rent_calculation_type');
}
}
225 changes: 212 additions & 13 deletions src/Entity/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,61 @@ class Token
*/
private $originSecondaryMarketplaces = [];

/**
* @ORM\Column(type="date", nullable=true)
*/
private $initialLaunchDate;

/**
* @ORM\Column(type="integer", nullable=true)
*/
private $seriesNumber;

/**
* @ORM\Column(type="date", nullable=true)
*/
private $constructionYear;

/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $constructionType;

/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $roofType;

/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $assetParking;

/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $foundation;

/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $heating;

/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $cooling;

/**
* @ORM\Column(type="integer", nullable=true)
*/
private $tokenIdRules;

/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $rentCalculationType;

public function getId(): ?int
{
return $this->id;
Expand Down Expand Up @@ -912,6 +967,150 @@ public function setRentStartDate(?\DateTimeInterface $rentStartDate): self
return $this;
}

public function getOriginSecondaryMarketplaces(): ?array
{
return $this->originSecondaryMarketplaces;
}

public function setOriginSecondaryMarketplaces(?array $originSecondaryMarketplaces): self
{
$this->originSecondaryMarketplaces = $originSecondaryMarketplaces;

return $this;
}

public function getInitialLaunchDate(): ?\DateTimeInterface
{
return $this->initialLaunchDate;
}

public function setInitialLaunchDate(?\DateTimeInterface $initialLaunchDate): self
{
$this->initialLaunchDate = $initialLaunchDate;

return $this;
}

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

public function setSeriesNumber(?int $seriesNumber): self
{
$this->seriesNumber = $seriesNumber;

return $this;
}

public function getConstructionYear(): ?\DateTimeInterface
{
return $this->constructionYear;
}

public function setConstructionYear(?\DateTimeInterface $constructionYear): self
{
$this->constructionYear = $constructionYear;

return $this;
}

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

public function setConstructionType(?string $constructionType): self
{
$this->constructionType = $constructionType;

return $this;
}

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

public function setRoofType(?string $roofType): self
{
$this->roofType = $roofType;

return $this;
}

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

public function setAssetParking(?string $assetParking): self
{
$this->assetParking = $assetParking;

return $this;
}

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

public function setFoundation(?string $foundation): self
{
$this->foundation = $foundation;

return $this;
}

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

public function setHeating(?string $heating): self
{
$this->heating = $heating;

return $this;
}

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

public function setCooling(?string $cooling): self
{
$this->cooling = $cooling;

return $this;
}

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

public function setTokenIdRules(?int $tokenIdRules): self
{
$this->tokenIdRules = $tokenIdRules;

return $this;
}

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

public function setRentCalculationType(?string $rentCalculationType): self
{
$this->rentCalculationType = $rentCalculationType;

return $this;
}

public function __toArray(array $credentials): array
{
if ($credentials['isAuth']) {
Expand Down Expand Up @@ -965,7 +1164,19 @@ public function __toArray(array $credentials): array
'renovationReserve' => $this->renovationReserve,
'propertyMaintenanceMonthly' => $this->propertyMaintenanceMonthly,
'rentStartDate' => $this->rentStartDate,
'lastUpdate' => $this->lastUpdate
'lastUpdate' => $this->lastUpdate,
'originSecondaryMarketplaces' => $this->originSecondaryMarketplaces,
'initialLaunchDate' => $this->initialLaunchDate,
'seriesNumber' => $this->seriesNumber,
'constructionYear' => $this->constructionYear,
'constructionType' => $this->constructionType,
'roofType' => $this->roofType,
'assetParking' => $this->assetParking,
'foundation' => $this->foundation,
'heating' => $this->heating,
'cooling' => $this->cooling,
'tokenIdRules' => $this->tokenIdRules,
'rentCalculationType' => $this->rentCalculationType
];
} else {
$response = [
Expand All @@ -988,16 +1199,4 @@ public function __toArray(array $credentials): array

return $response;
}

public function getOriginSecondaryMarketplaces(): ?array
{
return $this->originSecondaryMarketplaces;
}

public function setOriginSecondaryMarketplaces(?array $originSecondaryMarketplaces): self
{
$this->originSecondaryMarketplaces = $originSecondaryMarketplaces;

return $this;
}
}
12 changes: 12 additions & 0 deletions src/Service/TokenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,18 @@ private function tokenMapping(array $dataJson, ?Token $token = null): Token
? new DateTime($dataJson['rentStartDate'])
: null);
$token->setInitialMaintenanceReserve($dataJson['initialMaintenanceReserve'] ?: null);
$token->setInitialLaunchDate($dataJson['initialLaunchDate']);
$token->setSeriesNumber($dataJson['seriesNumber']);
$token->setConstructionYear($dataJson['constructionYear']);
$token->setConstructionType($dataJson['constructionType']);
$token->setRoofType($dataJson['roofType']);
$token->setAssetParking($dataJson['assetParking']);
$token->setFoundation($dataJson['foundation']);
$token->setHeating($dataJson['heating']);
$token->setCooling($dataJson['cooling']);
$token->setTokenIdRules($dataJson['tokenIdRules']);
$token->setRentCalculationType($dataJson['rentCalculationType']);

$token->setLastUpdate(new DateTime());

return $token;
Expand Down