FulfillmentRequest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Rest\Request;
  6. use Temando\Shipping\Rest\Request\Type\FulfillmentRequestTypeInterface;
  7. /**
  8. * Temando API Create/Update Fulfillment Operation Parameters
  9. *
  10. * @package Temando\Shipping\Rest
  11. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  12. * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
  13. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  14. * @link http://www.temando.com/
  15. */
  16. class FulfillmentRequest implements FulfillmentRequestInterface
  17. {
  18. /**
  19. * @var FulfillmentRequestTypeInterface
  20. */
  21. private $fulfillment;
  22. /**
  23. * OrderRequest constructor.
  24. *
  25. * @param FulfillmentRequestTypeInterface $fulfillment
  26. */
  27. public function __construct(FulfillmentRequestTypeInterface $fulfillment)
  28. {
  29. $this->fulfillment = $fulfillment;
  30. }
  31. /**
  32. * @return string[]
  33. */
  34. public function getPathParams()
  35. {
  36. if (!$this->fulfillment->getId()) {
  37. return [];
  38. }
  39. return [
  40. $this->fulfillment->getId(),
  41. ];
  42. }
  43. /**
  44. * @return string
  45. */
  46. public function getRequestBody()
  47. {
  48. return json_encode($this->fulfillment, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
  49. }
  50. }