-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoint for updating order status (#47)
* Create UpdateOrderRequestBody * Create UpdateOrderRequestBodyNormalizer * Add updateOrder to DealsResource * Register UpdateOrderRequestBodyNormalizer
- Loading branch information
1 parent
f49d66f
commit a03bfa2
Showing
4 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
php/src/Snagshout/Promote/Model/UpdateOrderRequestBody.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2016-2022, Snagshout <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* This file is part of the Merchant package | ||
*/ | ||
|
||
namespace Snagshout\Promote\Model; | ||
|
||
class UpdateOrderRequestBody | ||
{ | ||
/** | ||
* `status` of the order. | ||
* | ||
* @var string | ||
*/ | ||
protected $status; | ||
/** | ||
* Get `status` of the order. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getStatus() : ?string | ||
{ | ||
return $this->status; | ||
} | ||
/** | ||
* Set `status` of the order. | ||
* | ||
* @param string|null $status | ||
* | ||
* @return self | ||
*/ | ||
public function setStatus(?string $status) : self | ||
{ | ||
$this->status = $status; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
php/src/Snagshout/Promote/Normalizer/UpdateOrderRequestBodyNormalizer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2016-2022, Snagshout <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* This file is part of the Merchant package | ||
*/ | ||
|
||
namespace Snagshout\Promote\Normalizer; | ||
|
||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer; | ||
|
||
class UpdateOrderRequestBodyNormalizer extends SerializerAwareNormalizer implements DenormalizerInterface, NormalizerInterface | ||
{ | ||
public function supportsDenormalization($data, $type, $format = null) | ||
{ | ||
if ($type !== 'Snagshout\\Promote\\Model\\UpdateOrderRequestBody') { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
public function supportsNormalization($data, $format = null) | ||
{ | ||
if ($data instanceof \Snagshout\Promote\Model\UpdateOrderRequestBody) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
public function denormalize($data, $class, $format = null, array $context = []) | ||
{ | ||
$object = new \Snagshout\Promote\Model\UpdateOrderRequestBody(); | ||
if (property_exists($data, 'status')) { | ||
$object->setStatus($data->{'status'}); | ||
} | ||
|
||
return $object; | ||
} | ||
public function normalize($object, $format = null, array $context = []) | ||
{ | ||
$data = new \stdClass(); | ||
if (null !== $object->getStatus()) { | ||
$data->{'status'} = $object->getStatus(); | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters