CouponGenerationSpec.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * Data Model implementing the Address interface
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\SalesRule\Model\Data;
  9. /**
  10. * Class CouponGenerationSpec
  11. *
  12. * @codeCoverageIgnore
  13. */
  14. class CouponGenerationSpec extends \Magento\Framework\Api\AbstractExtensibleObject implements
  15. \Magento\SalesRule\Api\Data\CouponGenerationSpecInterface
  16. {
  17. const KEY_RULE_ID = 'rule_id';
  18. const KEY_FORMAT = 'format';
  19. const KEY_LENGTH = 'length';
  20. const KEY_QUANTITY = 'quantity';
  21. const KEY_PREFIX = 'prefix';
  22. const KEY_SUFFIX = 'suffix';
  23. const KEY_DELIMITER_AT_EVERY = 'dash';
  24. const KEY_DELIMITER = 'delimiter';
  25. /**
  26. * Get the id of the rule associated with the coupon
  27. *
  28. * @return int
  29. */
  30. public function getRuleId()
  31. {
  32. return $this->_get(self::KEY_RULE_ID);
  33. }
  34. /**
  35. * Set rule id
  36. *
  37. * @param int $ruleId
  38. * @return $this
  39. */
  40. public function setRuleId($ruleId)
  41. {
  42. return $this->setData(self::KEY_RULE_ID, $ruleId);
  43. }
  44. /**
  45. * Get format of generated coupon code
  46. *
  47. * @return string
  48. */
  49. public function getFormat()
  50. {
  51. return $this->_get(self::KEY_FORMAT);
  52. }
  53. /**
  54. * Set format for generated coupon code
  55. *
  56. * @param string $format
  57. * @return $this
  58. */
  59. public function setFormat($format)
  60. {
  61. return $this->setData(self::KEY_FORMAT, $format);
  62. }
  63. /**
  64. * Number of coupons to generate
  65. *
  66. * @return int
  67. */
  68. public function getQuantity()
  69. {
  70. return $this->_get(self::KEY_QUANTITY);
  71. }
  72. /**
  73. * Set number of coupons to generate
  74. *
  75. * @param int $quantity
  76. * @return $this
  77. */
  78. public function setQuantity($quantity)
  79. {
  80. return $this->setData(self::KEY_QUANTITY, $quantity);
  81. }
  82. /**
  83. * Get length of coupon code
  84. *
  85. * @return int
  86. */
  87. public function getLength()
  88. {
  89. return $this->_get(self::KEY_LENGTH);
  90. }
  91. /**
  92. * Set length of coupon code
  93. *
  94. * @param int $length
  95. * @return $this
  96. */
  97. public function setLength($length)
  98. {
  99. return $this->setData(self::KEY_LENGTH, $length);
  100. }
  101. /**
  102. * Get the prefix
  103. *
  104. * @return string|null
  105. */
  106. public function getPrefix()
  107. {
  108. return $this->_get(self::KEY_PREFIX);
  109. }
  110. /**
  111. * Set the prefix
  112. *
  113. * @param string $prefix
  114. * @return $this
  115. */
  116. public function setPrefix($prefix)
  117. {
  118. return $this->setData(self::KEY_PREFIX, $prefix);
  119. }
  120. /**
  121. * Get the suffix
  122. *
  123. * @return string|null
  124. */
  125. public function getSuffix()
  126. {
  127. return $this->_get(self::KEY_SUFFIX);
  128. }
  129. /**
  130. * Set the suffix
  131. *
  132. * @param string $suffix
  133. * @return $this
  134. */
  135. public function setSuffix($suffix)
  136. {
  137. return $this->setData(self::KEY_SUFFIX, $suffix);
  138. }
  139. /**
  140. * Get the spacing where the delimiter should exist
  141. *
  142. * @return int|null
  143. */
  144. public function getDelimiterAtEvery()
  145. {
  146. return $this->_get(self::KEY_DELIMITER_AT_EVERY);
  147. }
  148. /**
  149. * Set the spacing where the delimiter should exist
  150. *
  151. * @param int $delimiterAtEvery
  152. * @return $this
  153. */
  154. public function setDelimiterAtEvery($delimiterAtEvery)
  155. {
  156. return $this->setData(self::KEY_DELIMITER_AT_EVERY, $delimiterAtEvery);
  157. }
  158. /**
  159. * Get the delimiter
  160. *
  161. * @return string|null
  162. */
  163. public function getDelimiter()
  164. {
  165. return $this->_get(self::KEY_DELIMITER);
  166. }
  167. /**
  168. * Set the delimiter
  169. *
  170. * @param string $delimiter
  171. * @return $this
  172. */
  173. public function setDelimiter($delimiter)
  174. {
  175. return $this->setData(self::KEY_DELIMITER, $delimiter);
  176. }
  177. /**
  178. * Retrieve existing extension attributes object or create a new one.
  179. *
  180. * @return \Magento\SalesRule\Api\Data\CouponGenerationSpecExtensionInterface|null
  181. */
  182. public function getExtensionAttributes()
  183. {
  184. return $this->_getExtensionAttributes();
  185. }
  186. /**
  187. * Set an extension attributes object.
  188. *
  189. * @param \Magento\SalesRule\Api\Data\CouponGenerationSpecExtensionInterface $extensionAttributes
  190. * @return $this
  191. */
  192. public function setExtensionAttributes(
  193. \Magento\SalesRule\Api\Data\CouponGenerationSpecExtensionInterface $extensionAttributes
  194. ) {
  195. return $this->_setExtensionAttributes($extensionAttributes);
  196. }
  197. }