src/Document/Dsp.php line 384

Open in your IDE?
  1. <?php
  2. namespace App\Document;
  3. use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  4. use JsonSerializable;
  5. /**
  6. * @MongoDB\Document(collection="dsp")
  7. * @MongoDB\UniqueIndex(keys={"gitId"="asc"})
  8. */
  9. class Dsp implements JsonSerializable, SyncDocument
  10. {
  11. const GIT_FIELDS = [
  12. 'open_market',
  13. 'openmarket',
  14. 'private_auction',
  15. 'status',
  16. 'default_bidfloor',
  17. 'currency',
  18. 'bypass_validation',
  19. 'seat_settings',
  20. 'data_exchange',
  21. 'quota',
  22. 'targeting'
  23. ];
  24. const GIT_ID = 'gitId';
  25. /**
  26. * @MongoDB\Id
  27. */
  28. protected $_id;
  29. /**
  30. * @var string
  31. * @MongoDB\Field(type="string")
  32. */
  33. protected $gitId;
  34. /**
  35. * @var bool
  36. * @MongoDB\Field(type="bool", nullable=true, name="open_market")
  37. */
  38. private $openMarket;
  39. /**
  40. * @var array
  41. * @MongoDB\Field(type="hash", nullable=true, name="open_market_config")
  42. */
  43. private $openMarketConfig;
  44. /**
  45. * @var bool
  46. * @MongoDB\Field(type="bool", nullable=true, name="private_auction")
  47. */
  48. private $privateAuction;
  49. /**
  50. * @var string
  51. * @MongoDB\Field(type="string")
  52. */
  53. protected $status;
  54. /**
  55. * @var string
  56. * @MongoDB\Field(type="string", name="default_bidfloor")
  57. */
  58. protected $defaultBidFloor;
  59. /**
  60. * @var string
  61. * @MongoDB\Field(type="string")
  62. */
  63. protected $currency;
  64. /**
  65. * @var bool
  66. * @MongoDB\Field(type="bool", name="bypass_violation")
  67. */
  68. private $bypassValidation;
  69. /**
  70. * @var array
  71. * @MongoDB\Field(type="hash")
  72. */
  73. private $quota;
  74. /**
  75. * @var array
  76. * @MongoDB\Field(type="hash", name="seat_settings")
  77. */
  78. private $seatSettings;
  79. /**
  80. * @var array
  81. * @MongoDB\Field(type="hash", name="data_exchange")
  82. */
  83. private $dataExchange;
  84. /**
  85. * @var array
  86. * @MongoDB\Field(type="hash")
  87. */
  88. private $targeting;
  89. /**
  90. * @var array
  91. * @MongoDB\Field(type="hash", name="default_bid_params", nullable=true)
  92. */
  93. private $defaultBidParams;
  94. /**
  95. * @var array
  96. * @MongoDB\Field(type="hash", name="seat_mapping_data", nullable=true)
  97. */
  98. private $seatMapping;
  99. /**
  100. * @return mixed
  101. */
  102. public function getId()
  103. {
  104. return $this->_id;
  105. }
  106. /**
  107. * @return mixed
  108. */
  109. public function getGitId()
  110. {
  111. return $this->gitId;
  112. }
  113. /**
  114. * @param string $id
  115. * @return Inventory
  116. */
  117. public function setGitId(string $id)
  118. {
  119. $this->gitId = $id;
  120. return $this;
  121. }
  122. /**
  123. * @return bool
  124. */
  125. public function isOpenMarket(): ?bool
  126. {
  127. return $this->openMarket;
  128. }
  129. /**
  130. * @param bool $openMarket
  131. * @return Dsp
  132. */
  133. public function setOpenMarket(bool $openMarket = null): Dsp
  134. {
  135. $this->openMarket = $openMarket;
  136. return $this;
  137. }
  138. /**
  139. * @return bool
  140. */
  141. public function isPrivateAuction(): ?bool
  142. {
  143. return $this->privateAuction;
  144. }
  145. /**
  146. * @return array
  147. */
  148. public function getOpenMarketConfig(): array
  149. {
  150. return $this->openMarketConfig;
  151. }
  152. /**
  153. * @param array $openMarketConfig
  154. * @return Dsp
  155. */
  156. public function setOpenMarketConfig(array $openMarketConfig): Dsp
  157. {
  158. $this->openMarketConfig = $openMarketConfig;
  159. return $this;
  160. }
  161. /**
  162. * @param bool $privateAuction
  163. * @return Dsp
  164. */
  165. public function setPrivateAuction(bool $privateAuction = null): Dsp
  166. {
  167. $this->privateAuction = $privateAuction;
  168. return $this;
  169. }
  170. /**
  171. * @return string
  172. */
  173. public function getStatus(): string
  174. {
  175. return $this->status;
  176. }
  177. /**
  178. * @param string $status
  179. * @return Dsp
  180. */
  181. public function setStatus(string $status): Dsp
  182. {
  183. $this->status = $status;
  184. return $this;
  185. }
  186. /**
  187. * @return string
  188. */
  189. public function getDefaultBidFloor(): string
  190. {
  191. return $this->defaultBidFloor;
  192. }
  193. /**
  194. * @param string $defaultBidFloor
  195. * @return Dsp
  196. */
  197. public function setDefaultBidFloor(string $defaultBidFloor): Dsp
  198. {
  199. $this->defaultBidFloor = $defaultBidFloor;
  200. return $this;
  201. }
  202. /**
  203. * @return string
  204. */
  205. public function getCurrency(): string
  206. {
  207. return $this->currency;
  208. }
  209. /**
  210. * @param string $currency
  211. * @return Dsp
  212. */
  213. public function setCurrency(string $currency): Dsp
  214. {
  215. $this->currency = $currency;
  216. return $this;
  217. }
  218. /**
  219. * @return bool
  220. */
  221. public function isBypassValidation(): ?bool
  222. {
  223. return $this->bypassValidation;
  224. }
  225. /**
  226. * @param bool $bypassViolation
  227. * @return Dsp
  228. */
  229. public function setBypassValidation(bool $bypassValidation): Dsp
  230. {
  231. $this->bypassValidation = $bypassValidation;
  232. return $this;
  233. }
  234. /**
  235. * @return array
  236. */
  237. public function getQuota(): array
  238. {
  239. return $this->quota;
  240. }
  241. /**
  242. * @param array $quota
  243. * @return Dsp
  244. */
  245. public function setQuota(array $quota): Dsp
  246. {
  247. $this->quota = $quota;
  248. return $this;
  249. }
  250. /**
  251. * @return array
  252. */
  253. public function getSeatSettings(): array
  254. {
  255. return $this->seatSettings;
  256. }
  257. /**
  258. * @param array $seatSettings
  259. * @return Dsp
  260. */
  261. public function setSeatSettings(array $seatSettings): Dsp
  262. {
  263. $this->seatSettings = $seatSettings;
  264. return $this;
  265. }
  266. /**
  267. * @return array
  268. */
  269. public function getDataExchange(): array
  270. {
  271. return $this->dataExchange;
  272. }
  273. /**
  274. * @param array $dataExchange
  275. * @return Dsp
  276. */
  277. public function setDataExchange(array $dataExchange): Dsp
  278. {
  279. $this->dataExchange = $dataExchange;
  280. return $this;
  281. }
  282. /**
  283. * @return array
  284. */
  285. public function getTargeting(): array
  286. {
  287. return $this->targeting;
  288. }
  289. /**
  290. * @param array $targeting
  291. * @return Dsp
  292. */
  293. public function setTargeting(array $targeting): Dsp
  294. {
  295. $this->targeting = $targeting;
  296. return $this;
  297. }
  298. /**
  299. * @return array
  300. */
  301. public function getDefaultBidParams(): array
  302. {
  303. return $this->defaultBidParams;
  304. }
  305. /**
  306. * @param array $defaultBidParams
  307. * @return Dsp
  308. */
  309. public function setDefaultBidParams(array $defaultBidParams): Dsp
  310. {
  311. $this->defaultBidParams = $defaultBidParams;
  312. return $this;
  313. }
  314. /**
  315. * @return array
  316. */
  317. public function getSeatMapping(): array
  318. {
  319. return $this->seatMapping;
  320. }
  321. /**
  322. * @param array $seatMapping
  323. * @return Dsp
  324. */
  325. public function setSeatMapping(array $seatMapping): Dsp
  326. {
  327. $this->seatMapping = $seatMapping;
  328. return $this;
  329. }
  330. public function jsonSerialize()
  331. {
  332. return [
  333. 'id' => $this->getId(),
  334. 'gitId' => $this->getGitId(),
  335. 'open_market' => $this->isOpenMarket(),
  336. 'openmarket' => $this->getOpenMarketConfig(),
  337. 'private_auction' => $this->isPrivateAuction(),
  338. 'status' => $this->getStatus(),
  339. 'default_bidfloor' => $this->getDefaultBidFloor(),
  340. 'currency' => $this->getCurrency(),
  341. 'bypass_validation' => $this->isBypassValidation(),
  342. 'seat_settings' => $this->getSeatSettings(),
  343. 'data_exchange' => $this->getDataExchange(),
  344. 'quota' => $this->getQuota(),
  345. 'targeting' => $this->getTargeting(),
  346. 'default_bid_params' => $this->getDefaultBidParams(),
  347. 'seat_mapping_data' => $this->getSeatMapping(),
  348. ];
  349. }
  350. public function validateMutation(Mutation $m) {
  351. return $m->getOldValue()['open_market'] === $this->isOpenMarket() &&
  352. $m->getOldValue()['openmarket'] === $this->getOpenMarketConfig() &&
  353. $m->getOldValue()['private_auction'] === $this->isPrivateAuction() &&
  354. $m->getOldValue()['status'] === $this->getStatus() &&
  355. $m->getOldValue()['default_bidfloor'] === $this->getDefaultBidFloor() &&
  356. $m->getOldValue()['currency'] === $this->getCurrency() &&
  357. $m->getOldValue()['bypass_validation'] === $this->isBypassValidation() &&
  358. $m->getOldValue()['seat_settings'] === $this->getSeatSettings() &&
  359. $m->getOldValue()['data_exchange'] === $this->getDataExchange() &&
  360. $m->getOldValue()['quota'] === $this->getQuota() &&
  361. $m->getOldValue()['targeting'] === $this->getTargeting();
  362. }
  363. public function gitSerialize()
  364. {
  365. return [
  366. 'open_market' => $this->isOpenMarket(),
  367. 'openmarket' => $this->getOpenMarketConfig(),
  368. 'private_auction' => $this->isPrivateAuction(),
  369. 'status' => $this->getStatus(),
  370. 'default_bidfloor' => $this->getDefaultBidFloor(),
  371. 'currency' => $this->getCurrency(),
  372. 'bypass_validation' => $this->isBypassValidation(),
  373. 'seat_settings' => $this->getSeatSettings(),
  374. 'data_exchange' => $this->getDataExchange(),
  375. 'quota' => $this->getQuota(),
  376. 'targeting' => $this->getTargeting(),
  377. ];
  378. }
  379. public function gitUnserialize(array $gitData): Dsp
  380. {
  381. return $this->setOpenMarket(isset($gitData['open_market']) ? $gitData['open_market'] : null)
  382. ->setOpenMarketConfig($gitData['openmarket'])
  383. ->setPrivateAuction(isset($gitData['private_auction']) ? $gitData['private_auction'] : null)
  384. ->setStatus($gitData['status'])
  385. ->setDefaultBidFloor($gitData['default_bidfloor'])
  386. ->setCurrency($gitData['currency'])
  387. ->setBypassValidation($gitData['bypass_validation'])
  388. ->setSeatSettings($gitData['seat_settings'])
  389. ->setDataExchange($gitData['data_exchange'])
  390. ->setQuota($gitData['quota'])
  391. ->setTargeting(isset($gitData['targeting']) ?$gitData['targeting'] : [])
  392. ->setDefaultBidParams(isset($gitData['default_bid_params']) ?$gitData['default_bid_params'] : [])
  393. ->setSeatMapping(isset($gitData['seat_mapping_data']) ?$gitData['seat_mapping_data'] : []);
  394. }
  395. }