Skip to content

Commit

Permalink
T1745 - Generate (#6)
Browse files Browse the repository at this point in the history
* Generate

* Comment

* Update comment

* Update comment

* Put refresh back
  • Loading branch information
Jleagle authored May 25, 2021
1 parent 78d7a0e commit 8b3efea
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .jane-openapi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'openapi-file' => 'https://api.chargehive.com/swagger.json',
//'openapi-file' => 'http://localhost:9051/swagger.json', // To use locally
'namespace' => 'ChargeHive\\Php\\Sdk\\Generated',
'directory' => __DIR__ . '/generated',
];
13 changes: 13 additions & 0 deletions generated/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,19 @@ public function methodRefresh(string $token, \ChargeHive\Php\Sdk\Generated\Model
{
return $this->executePsr7Endpoint(new \ChargeHive\Php\Sdk\Generated\Endpoint\MethodRefresh($token, $body), $fetch);
}
/**
*
*
* @param string $token
* @param \ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendRequest $body
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
*
* @return null|\ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendResponse|\ChargeHive\Php\Sdk\Generated\Model\RuntimeError|\Psr\Http\Message\ResponseInterface
*/
public function methodSuspend(string $token, \ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendRequest $body, string $fetch = self::FETCH_OBJECT)
{
return $this->executePsr7Endpoint(new \ChargeHive\Php\Sdk\Generated\Endpoint\MethodSuspend($token, $body), $fetch);
}
/**
*
*
Expand Down
49 changes: 49 additions & 0 deletions generated/Endpoint/MethodSuspend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace ChargeHive\Php\Sdk\Generated\Endpoint;

class MethodSuspend extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7HttplugEndpoint
{
protected $token;
/**
*
*
* @param string $token
* @param \ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendRequest $body
*/
public function __construct(string $token, \ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendRequest $body)
{
$this->token = $token;
$this->body = $body;
}
use \Jane\OpenApiRuntime\Client\Psr7HttplugEndpointTrait;
public function getMethod() : string
{
return 'POST';
}
public function getUri() : string
{
return str_replace(array('{token}'), array($this->token), '/v1/method/{token}/suspend');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null) : array
{
return $this->getSerializedBody($serializer);
}
public function getExtraHeaders() : array
{
return array('Accept' => array('application/json'));
}
/**
* {@inheritdoc}
*
*
* @return null|\ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendResponse|\ChargeHive\Php\Sdk\Generated\Model\RuntimeError
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
if (200 === $status) {
return $serializer->deserialize($body, 'ChargeHive\\Php\\Sdk\\Generated\\Model\\ChargehiveMethodSuspendResponse', 'json');
}
return $serializer->deserialize($body, 'ChargeHive\\Php\\Sdk\\Generated\\Model\\RuntimeError', 'json');
}
}
38 changes: 38 additions & 0 deletions generated/Model/ChargehiveMethodSuspendRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace ChargeHive\Php\Sdk\Generated\Model;

class ChargehiveMethodSuspendRequest implements \JsonSerializable
{
/**
*
*
* @var string
*/
protected $token;
/**
*
*
* @return string
*/
public function getToken()
{
return $this->token;
}
/**
*
*
* @param string $token
*
* @return self
*/
public function setToken(string $token)
{
$this->token = $token;
return $this;
}
public function jsonSerialize()
{
return ['token' => $this->token];
}
}
38 changes: 38 additions & 0 deletions generated/Model/ChargehiveMethodSuspendResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace ChargeHive\Php\Sdk\Generated\Model;

class ChargehiveMethodSuspendResponse implements \JsonSerializable
{
/**
*
*
* @var bool
*/
protected $success;
/**
*
*
* @return bool
*/
public function getSuccess()
{
return $this->success;
}
/**
*
*
* @param bool $success
*
* @return self
*/
public function setSuccess(bool $success)
{
$this->success = $success;
return $this;
}
public function jsonSerialize()
{
return ['success' => $this->success];
}
}
44 changes: 44 additions & 0 deletions generated/Normalizer/ChargehiveMethodSuspendRequestNormalizer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace ChargeHive\Php\Sdk\Generated\Normalizer;

use Jane\JsonSchemaRuntime\Reference;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class ChargehiveMethodSuspendRequestNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use DenormalizerAwareTrait;
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
{
return $type === 'ChargeHive\\Php\\Sdk\\Generated\\Model\\ChargehiveMethodSuspendRequest';
}
public function supportsNormalization($data, $format = null)
{
return get_class($data) === 'ChargeHive\\Php\\Sdk\\Generated\\Model\\ChargehiveMethodSuspendRequest';
}
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
}
$object = new \ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendRequest();
if (property_exists($data, 'token')) {
$object->setToken($data->{'token'});
}
return $object;
}
public function normalize($object, $format = null, array $context = array())
{
$data = new \stdClass();
if (null !== $object->getToken()) {
$data->{'token'} = $object->getToken();
}
return $data;
}
}
44 changes: 44 additions & 0 deletions generated/Normalizer/ChargehiveMethodSuspendResponseNormalizer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace ChargeHive\Php\Sdk\Generated\Normalizer;

use Jane\JsonSchemaRuntime\Reference;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class ChargehiveMethodSuspendResponseNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use DenormalizerAwareTrait;
use NormalizerAwareTrait;
public function supportsDenormalization($data, $type, $format = null)
{
return $type === 'ChargeHive\\Php\\Sdk\\Generated\\Model\\ChargehiveMethodSuspendResponse';
}
public function supportsNormalization($data, $format = null)
{
return get_class($data) === 'ChargeHive\\Php\\Sdk\\Generated\\Model\\ChargehiveMethodSuspendResponse';
}
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!is_object($data)) {
throw new InvalidArgumentException();
}
$object = new \ChargeHive\Php\Sdk\Generated\Model\ChargehiveMethodSuspendResponse();
if (property_exists($data, 'success')) {
$object->setSuccess($data->{'success'});
}
return $object;
}
public function normalize($object, $format = null, array $context = array())
{
$data = new \stdClass();
if (null !== $object->getSuccess()) {
$data->{'success'} = $object->getSuccess();
}
return $data;
}
}
2 changes: 2 additions & 0 deletions generated/Normalizer/NormalizerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static function create()
$normalizers[] = new ChargehiveConnectionValidateResponseNormalizer();
$normalizers[] = new ChargehiveMethodRefreshRequestNormalizer();
$normalizers[] = new ChargehiveMethodRefreshResponseNormalizer();
$normalizers[] = new ChargehiveMethodSuspendRequestNormalizer();
$normalizers[] = new ChargehiveMethodSuspendResponseNormalizer();
$normalizers[] = new ChargehiveMethodTokenizeRequestNormalizer();
$normalizers[] = new ChargehiveMethodTokenizeResponseNormalizer();
$normalizers[] = new ChargehiveMethodUnlockRequestNormalizer();
Expand Down

0 comments on commit 8b3efea

Please sign in to comment.