<?php
namespace Services\ConfigurationBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Services\PaymentBundle\Entity\PaymentTypes;
/**
* PSP Log. Table where every call to a PSP is logged.
*
* @ORM\Table(name="log_psp", indexes={@ORM\Index(name="siteNameConfig", columns={"site"}), @ORM\Index(name="user_email", columns={"email"})})
* @ORM\Entity(repositoryClass="Services\ConfigurationBundle\Repository\PspLogsRepository")
*/
class PspLogs implements JsonSerializable
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", options={"unsigned"=true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="site", type="string", length=80, nullable=true)
*/
private $site;
/**
* @var string
*
* @ORM\Column(name="psp_name", type="string")
*/
private $pspName;
/**
* @var string
*
* @ORM\Column(name="email", type="string", nullable=true)
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="request_url", type="text")
*/
private $requestUrl;
/**
* @var string
*
* @ORM\Column(name="request", type="text")
*/
private $request;
/**
* @var string
*
* @ORM\Column(name="response", type="text", nullable=true)
*/
private $response;
/**
* @var string
*
* @ORM\Column(name="method", type="string", nullable=true)
*/
private $method;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", options={"default":"CURRENT_TIMESTAMP"})
*/
private $createdAt;
/**
* @var int
*
* @ORM\Column(name="paymentTypes_id", type="integer", nullable=true)
*/
private $paymentTypesId;
/**
* Summary of __construct
* @param string $site
* @param PaymentTypes $psp
* @param string $email
* @param string|null $requestUrl
* @param string|null $request
* @param string $response
* @param string $method
*/
public function __construct(
?string $site = '',
PaymentTypes $psp = null,
string $email = '',
?string $requestUrl = '',
?string $request = '',
string $response = '',
string $method = 'POST'
) {
$this->site = $site;
$this->pspName = $psp ? $psp->getNameConfig() : '';
$this->email = $email;
$this->requestUrl = $requestUrl ?? '';
$this->request = $request ?? '';
$this->response = $response;
$this->method = $method;
$this->createdAt = new \DateTime('now');
$this->paymentTypesId = $psp ? $psp->getId() : null;
}
/**
* Get the value of id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set the value of id
*
* @param integer $id
*
* @return self
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get the value of site
*
* @return string
*/
public function getSite()
{
return $this->site;
}
/**
* Set the value of site
*
* @param string $site
*
* @return self
*/
public function setSite(string $site)
{
$this->site = $site;
return $this;
}
/**
* Get the value of pspName
*
* @return string
*/
public function getPspName()
{
return $this->pspName;
}
/**
* Set the value of pspName
*
* @param string $pspName
*
* @return self
*/
public function setPspName(string $pspName)
{
$this->pspName = $pspName;
return $this;
}
/**
* Get the value of email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set the value of email
*
* @param string $email
*
* @return self
*/
public function setEmail(string $email)
{
$this->email = $email;
return $this;
}
/**
* Get the value of requestUrl
*
* @return string
*/
public function getRequestUrl()
{
return $this->requestUrl;
}
/**
* Set the value of requestUrl
*
* @param string $requestUrl
*
* @return self
*/
public function setRequestUrl(string $requestUrl)
{
$this->requestUrl = $requestUrl;
return $this;
}
/**
* Get the value of request
*
* @return string
*/
public function getRequest()
{
return $this->request;
}
/**
* Set the value of request
*
* @param string $request
*
* @return self
*/
public function setRequest(string $request)
{
$this->request = $request;
return $this;
}
/**
* Get the value of response
*
* @return string
*/
public function getResponse()
{
return $this->response;
}
/**
* Set the value of response
*
* @param string $response
*
* @return self
*/
public function setResponse(string $response)
{
$this->response = $response;
return $this;
}
/**
* Get the value of method
*
* @return string
*/
public function getMethod()
{
return $this->method;
}
/**
* Set the value of method
*
* @param string $method
*
* @return self
*/
public function setMethod(string $method)
{
$this->method = $method;
return $this;
}
/**
* Get the value of createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set the value of createdAt
*
* @param \DateTime $createdAt
*
* @return self
*/
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get the value of paymentTypesId
*
* @return int
*/
public function getPaymentTypesId(): int
{
return $this->paymentTypesId;
}
/**
* Set the value of paymentTypesId
*
* @param integer $id
*
* @return self
*/
public function setPaymentTypesId(int $id): self
{
$this->paymentTypesId = $id;
return $this;
}
/**
* Specify data which should be serialized to JSON
* @return array
*/
public function jsonSerialize()
{
return [
$this->createdAt,
$this->site,
$this->pspName,
$this->email,
$this->requestUrl,
$this->request ? json_decode($this->request) : '',
$this->response ? json_decode($this->response) : '',
$this->method,
$this->paymentTypesId
];
}
}