BuilderInterface.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * This file is part of the Klarna Core 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\Core\Api;
  11. use Magento\Store\Api\Data\StoreInterface;
  12. /**
  13. * Base class to generate API configuration
  14. */
  15. interface BuilderInterface
  16. {
  17. const GENERATE_TYPE_CREATE = 'create';
  18. const GENERATE_TYPE_UPDATE = 'update';
  19. const GENERATE_TYPE_PLACE = 'place';
  20. const GENERATE_TYPE_CLIENT_UPDATE = 'client_update';
  21. /**
  22. * Generate order body
  23. *
  24. * @param string $type
  25. * @return $this
  26. * @throws \Klarna\Core\Exception
  27. */
  28. public function generateRequest($type = self::GENERATE_TYPE_CREATE);
  29. /**
  30. * Collect order lines
  31. *
  32. * @param StoreInterface $store
  33. * @return $this
  34. */
  35. public function collectOrderLines(StoreInterface $store);
  36. /**
  37. * Get totals collector model
  38. *
  39. * @return OrderLineInterface
  40. */
  41. public function getOrderLinesCollector();
  42. /**
  43. * Get the object used to generate request
  44. *
  45. * @return \Magento\Sales\Model\AbstractModel|\Magento\Quote\Model\Quote
  46. */
  47. public function getObject();
  48. /**
  49. * Set the object used to generate request
  50. *
  51. * @param \Magento\Sales\Model\AbstractModel|\Magento\Quote\Api\Data\CartInterface $object
  52. *
  53. * @return $this
  54. */
  55. public function setObject($object);
  56. /**
  57. * Get request
  58. *
  59. * @return array
  60. */
  61. public function getRequest();
  62. /**
  63. * Set generated request
  64. *
  65. * @param array $request
  66. * @param string $type
  67. *
  68. * @return $this
  69. */
  70. public function setRequest(array $request, $type = self::GENERATE_TYPE_CREATE);
  71. /**
  72. * Get order lines as array
  73. *
  74. * @param StoreInterface $store
  75. * @param bool $orderItemsOnly
  76. *
  77. * @return array
  78. */
  79. public function getOrderLines(StoreInterface $store, $orderItemsOnly = false);
  80. /**
  81. * Add an order line
  82. *
  83. * @param array $orderLine
  84. *
  85. * @return $this
  86. */
  87. public function addOrderLine(array $orderLine);
  88. /**
  89. * Remove all order lines
  90. *
  91. * @return $this
  92. */
  93. public function resetOrderLines();
  94. /**
  95. * @param $items
  96. * @return $this
  97. */
  98. public function setItems($items);
  99. /**
  100. * @return array
  101. */
  102. public function getItems();
  103. }