Options.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <?php
  2. /**
  3. * This file is part of the Klarna KP module
  4. *
  5. * (c) Klarna Bank AB (publ)
  6. *
  7. * For the full copyright and license information, please view the NOTICE
  8. * and LICENSE files that were distributed with this source code.
  9. */
  10. namespace Klarna\Kp\Model\Api\Request;
  11. use Klarna\Kp\Api\Data\OptionsInterface;
  12. /**
  13. * Class Options
  14. *
  15. * @package Klarna\Kp\Model\Api\Request
  16. * @SuppressWarnings(PHPMD.TooManyFields)
  17. */
  18. class Options implements OptionsInterface
  19. {
  20. use \Klarna\Kp\Model\Api\Export;
  21. /**
  22. * @var string
  23. */
  24. private $color_button;
  25. /**
  26. * @var string
  27. */
  28. private $color_button_text;
  29. /**
  30. * @var string
  31. */
  32. private $color_checkbox;
  33. /**
  34. * @var string
  35. */
  36. private $color_checkbox_checkmark;
  37. /**
  38. * @var string
  39. */
  40. private $color_header;
  41. /**
  42. * @var string
  43. */
  44. private $color_link;
  45. /**
  46. * @var string
  47. */
  48. private $color_border;
  49. /**
  50. * @var string
  51. */
  52. private $color_border_selected;
  53. /**
  54. * @var string
  55. */
  56. private $color_text;
  57. /**
  58. * @var string
  59. */
  60. private $radius_border;
  61. /**
  62. * @var string
  63. */
  64. private $allow_separate_shipping_address;
  65. /**
  66. * @var string
  67. */
  68. private $phone_mandatory;
  69. /**
  70. * @var string
  71. */
  72. private $date_of_birth_mandatory;
  73. /**
  74. * @var string
  75. */
  76. private $require_validate_callback_success;
  77. /**
  78. * @var string
  79. */
  80. private $title_mandatory;
  81. /**
  82. * @var string
  83. */
  84. private $payment_review;
  85. /**
  86. * @var string
  87. */
  88. private $color_text_secondary;
  89. /**
  90. * @var string
  91. */
  92. private $color_details;
  93. /**
  94. * Constructor.
  95. *
  96. * @param array $data
  97. */
  98. public function __construct($data = [])
  99. {
  100. foreach ($data as $key => $value) {
  101. if (property_exists($this, $key)) {
  102. $this->$key = $value;
  103. $this->addExport($key);
  104. }
  105. }
  106. }
  107. /**
  108. * Make sure property has been added to export list
  109. *
  110. * @param string $key
  111. */
  112. private function addExport($key)
  113. {
  114. if (!in_array($key, $this->exports, true)) {
  115. $this->exports[] = $key;
  116. }
  117. }
  118. /**
  119. * Allow separate shipping address from billing address
  120. *
  121. * @param string $allow_separate_shipping_address
  122. */
  123. public function setAllowSeparateShippingAddress($allow_separate_shipping_address)
  124. {
  125. $this->allow_separate_shipping_address = $allow_separate_shipping_address;
  126. $this->addExport('allow_separate_shipping_address');
  127. }
  128. /**
  129. * Require phone number
  130. *
  131. * @param string $phone_mandatory
  132. */
  133. public function setPhoneMandatory($phone_mandatory)
  134. {
  135. $this->phone_mandatory = $phone_mandatory;
  136. $this->addExport('phone_mandatory');
  137. }
  138. /**
  139. * Require DOB
  140. *
  141. * @param string $date_of_birth_mandatory
  142. */
  143. public function setDateOfBirthMandatory($date_of_birth_mandatory)
  144. {
  145. $this->date_of_birth_mandatory = $date_of_birth_mandatory;
  146. $this->addExport('date_of_birth_mandatory');
  147. }
  148. /**
  149. * Require that the validate callback is successful
  150. *
  151. * @param string $require_validate_callback_success
  152. */
  153. public function setRequireValidateCallbackSuccess($require_validate_callback_success)
  154. {
  155. $this->require_validate_callback_success = $require_validate_callback_success;
  156. $this->addExport('require_validate_callback_success');
  157. }
  158. /**
  159. * Make title (Mr, Mrs, Ms, etc..) required
  160. *
  161. * @param string $title_mandatory
  162. */
  163. public function setTitleMandatory($title_mandatory)
  164. {
  165. $this->title_mandatory = $title_mandatory;
  166. $this->addExport('title_mandatory');
  167. }
  168. /**
  169. * @param string $payment_review
  170. */
  171. public function setPaymentReview($payment_review)
  172. {
  173. $this->payment_review = $payment_review;
  174. $this->addExport('payment_review');
  175. }
  176. /**
  177. * CSS hex color, e.g. "#C0FFEE"
  178. *
  179. * @param string $color_text_secondary
  180. */
  181. public function setColorTextSecondary($color_text_secondary)
  182. {
  183. $this->color_text_secondary = $color_text_secondary;
  184. $this->addExport('color_text_secondary');
  185. }
  186. /**
  187. * CSS hex color, e.g. "#C0FFEE"
  188. *
  189. * @param string $color_details
  190. */
  191. public function setColorDetails($color_details)
  192. {
  193. $this->color_details = $color_details;
  194. $this->addExport('color_details');
  195. }
  196. /**
  197. * CSS hex color, e.g. "#C0FFEE"
  198. *
  199. * @param string $colorCode
  200. */
  201. public function setColorText($colorCode)
  202. {
  203. $this->color_text = $colorCode;
  204. $this->addExport('color_text');
  205. }
  206. /**
  207. * CSS hex color, e.g. "#C0FFEE"
  208. *
  209. * @param string $colorCode
  210. */
  211. public function setColorCheckbox($colorCode)
  212. {
  213. $this->color_checkbox = $colorCode;
  214. $this->addExport('color_checkbox');
  215. }
  216. /**
  217. * CSS hex color, e.g. "#C0FFEE"
  218. *
  219. * @param string $colorCode
  220. */
  221. public function setColorCheckboxCheckmark($colorCode)
  222. {
  223. $this->color_checkbox_checkmark = $colorCode;
  224. $this->addExport('color_checkbox_checkmark');
  225. }
  226. /**
  227. * CSS hex color, e.g. "#C0FFEE"
  228. *
  229. * @param string $colorCode
  230. */
  231. public function setColorButton($colorCode)
  232. {
  233. $this->color_button = $colorCode;
  234. $this->addExport('color_button');
  235. }
  236. /**
  237. * CSS hex color, e.g. "#C0FFEE"
  238. *
  239. * @param string $colorCode
  240. */
  241. public function setColorBorder($colorCode)
  242. {
  243. $this->color_border = $colorCode;
  244. $this->addExport('color_border');
  245. }
  246. /**
  247. * Radius size, e.g. "5px"
  248. *
  249. * @param string $radiusBorder
  250. */
  251. public function setRadiusBorder($radiusBorder)
  252. {
  253. $this->radius_border = $radiusBorder;
  254. $this->addExport('radius_border');
  255. }
  256. /**
  257. * CSS hex color, e.g. "#C0FFEE"
  258. *
  259. * @param string $colorCode
  260. */
  261. public function setColorHeader($colorCode)
  262. {
  263. $this->color_header = $colorCode;
  264. $this->addExport('color_header');
  265. }
  266. /**
  267. * CSS hex color, e.g. "#C0FFEE"
  268. *
  269. * @param string $colorCode
  270. */
  271. public function setColorBorderSelected($colorCode)
  272. {
  273. $this->color_border_selected = $colorCode;
  274. $this->addExport('color_border_selected');
  275. }
  276. /**
  277. * CSS hex color, e.g. "#C0FFEE"
  278. *
  279. * @param string $colorCode
  280. */
  281. public function setColorButtonText($colorCode)
  282. {
  283. $this->color_button_text = $colorCode;
  284. $this->addExport('color_button_text');
  285. }
  286. /**
  287. * CSS hex color, e.g. "#C0FFEE"
  288. *
  289. * @param string $colorCode
  290. */
  291. public function setColorLink($colorCode)
  292. {
  293. $this->color_link = $colorCode;
  294. $this->addExport('color_link');
  295. }
  296. }