Skip to content

Commit

Permalink
Merge pull request #21 from saasus-platform/feature/apilog-api
Browse files Browse the repository at this point in the history
Add client for APILog API
  • Loading branch information
YasuhiroTakahashi authored Dec 20, 2023
2 parents 5ab2329 + c0c25ef commit dc81afc
Show file tree
Hide file tree
Showing 31 changed files with 964 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Route::middleware(\AntiPatternInc\Saasus\Laravel\Middleware\Auth::class)->group(

ユーザーからフィードバックを収集したり、回答するプラットフォームの作成に利用します。

- [ApiLog](./generated/ApiLog/README.md)

SaaSus Platformで提供しているAPIを実行した際のログ履歴の確認に利用します。

---

## ユースケースサンプル
Expand Down
4 changes: 4 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Route::middleware(\AntiPatternInc\Saasus\Laravel\Middleware\Auth::class)->group(

It is used to create a responsive platform for handling user feedback.

- [ApiLog](./generated/ApiLog/README.md)

It is used to check the log history when executing the API provided by SaaSus Platform.

---

## Use Case Sample
Expand Down
22 changes: 22 additions & 0 deletions generated/ApiLog/Authentication/BearerAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Authentication;

class BearerAuthentication implements \Jane\Component\OpenApiRuntime\Client\AuthenticationPlugin
{
private $token;
public function __construct(string $token)
{
$this->{'token'} = $token;
}
public function authentication(\Psr\Http\Message\RequestInterface $request) : \Psr\Http\Message\RequestInterface
{
$header = sprintf('Bearer %s', $this->{'token'});
$request = $request->withHeader('Authorization', $header);
return $request;
}
public function getScope() : string
{
return 'Bearer';
}
}
62 changes: 62 additions & 0 deletions generated/ApiLog/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog;

class Client extends \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\Client
{
/**
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
* @throws \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\GetLogsInternalServerErrorException
*
* @return null|\AntiPatternInc\Saasus\Sdk\ApiLog\Model\ApiLogs|\Psr\Http\Message\ResponseInterface
*/
public function getLogs(string $fetch = self::FETCH_OBJECT)
{
return $this->executeEndpoint(new \AntiPatternInc\Saasus\Sdk\ApiLog\Endpoint\GetLogs(), $fetch);
}
/**
* 指定したIDのAPI実行のログ登録を取得します。
*
* @param string $apiLogId APIログID(API Log ID)
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
* @throws \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\GetLogInternalServerErrorException
*
* @return null|\Psr\Http\Message\ResponseInterface
*/
public function getLog(string $apiLogId, string $fetch = self::FETCH_OBJECT)
{
return $this->executeEndpoint(new \AntiPatternInc\Saasus\Sdk\ApiLog\Endpoint\GetLog($apiLogId), $fetch);
}
/**
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
* @throws \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\ReturnInternalServerErrorInternalServerErrorException
*
* @return null|\Psr\Http\Message\ResponseInterface
*/
public function returnInternalServerError(string $fetch = self::FETCH_OBJECT)
{
return $this->executeEndpoint(new \AntiPatternInc\Saasus\Sdk\ApiLog\Endpoint\ReturnInternalServerError(), $fetch);
}
public static function create($httpClient = null, array $additionalPlugins = array(), array $additionalNormalizers = array())
{
if (null === $httpClient) {
$httpClient = \Http\Discovery\Psr18ClientDiscovery::find();
$plugins = array();
$uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://api.saasus.io/v1/apilog');
$plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri);
$plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri);
if (count($additionalPlugins) > 0) {
$plugins = array_merge($plugins, $additionalPlugins);
}
$httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins);
}
$requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory();
$streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory();
$normalizers = array(new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \AntiPatternInc\Saasus\Sdk\ApiLog\Normalizer\JaneObjectNormalizer());
if (count($additionalNormalizers) > 0) {
$normalizers = array_merge($normalizers, $additionalNormalizers);
}
$serializer = new \Symfony\Component\Serializer\Serializer($normalizers, array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode(array('json_decode_associative' => true)))));
return new static($httpClient, $requestFactory, $serializer, $streamFactory);
}
}
54 changes: 54 additions & 0 deletions generated/ApiLog/Endpoint/GetLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Endpoint;

class GetLog extends \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\BaseEndpoint implements \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\Endpoint
{
protected $api_log_id;
/**
* 指定したIDのAPI実行のログ登録を取得します。
*
* @param string $apiLogId APIログID(API Log ID)
*/
public function __construct(string $apiLogId)
{
$this->api_log_id = $apiLogId;
}
use \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\EndpointTrait;
public function getMethod() : string
{
return 'GET';
}
public function getUri() : string
{
return str_replace(array('{api_log_id}'), array($this->api_log_id), '/logs/{api_log_id}');
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
{
return array(array(), null);
}
public function getExtraHeaders() : array
{
return array('Accept' => array('application/json'));
}
/**
* {@inheritdoc}
*
* @throws \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\GetLogInternalServerErrorException
*
* @return null
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
return json_decode($body);
}
if (is_null($contentType) === false && (500 === $status && mb_strpos($contentType, 'application/json') !== false)) {
throw new \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\GetLogInternalServerErrorException($serializer->deserialize($body, 'AntiPatternInc\\Saasus\\Sdk\\ApiLog\\Model\\Error', 'json'));
}
}
public function getAuthenticationScopes() : array
{
return array('Bearer');
}
}
44 changes: 44 additions & 0 deletions generated/ApiLog/Endpoint/GetLogs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Endpoint;

class GetLogs extends \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\BaseEndpoint implements \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\Endpoint
{
use \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\EndpointTrait;
public function getMethod() : string
{
return 'GET';
}
public function getUri() : string
{
return '/logs';
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
{
return array(array(), null);
}
public function getExtraHeaders() : array
{
return array('Accept' => array('application/json'));
}
/**
* {@inheritdoc}
*
* @throws \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\GetLogsInternalServerErrorException
*
* @return null|\AntiPatternInc\Saasus\Sdk\ApiLog\Model\ApiLogs
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) {
return $serializer->deserialize($body, 'AntiPatternInc\\Saasus\\Sdk\\ApiLog\\Model\\ApiLogs', 'json');
}
if (is_null($contentType) === false && (500 === $status && mb_strpos($contentType, 'application/json') !== false)) {
throw new \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\GetLogsInternalServerErrorException($serializer->deserialize($body, 'AntiPatternInc\\Saasus\\Sdk\\ApiLog\\Model\\Error', 'json'));
}
}
public function getAuthenticationScopes() : array
{
return array('Bearer');
}
}
41 changes: 41 additions & 0 deletions generated/ApiLog/Endpoint/ReturnInternalServerError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Endpoint;

class ReturnInternalServerError extends \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\BaseEndpoint implements \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\Endpoint
{
use \AntiPatternInc\Saasus\Sdk\ApiLog\Runtime\Client\EndpointTrait;
public function getMethod() : string
{
return 'GET';
}
public function getUri() : string
{
return '/errors/internal-server-error';
}
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
{
return array(array(), null);
}
public function getExtraHeaders() : array
{
return array('Accept' => array('application/json'));
}
/**
* {@inheritdoc}
*
* @throws \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\ReturnInternalServerErrorInternalServerErrorException
*
* @return null
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
{
if (is_null($contentType) === false && (500 === $status && mb_strpos($contentType, 'application/json') !== false)) {
throw new \AntiPatternInc\Saasus\Sdk\ApiLog\Exception\ReturnInternalServerErrorInternalServerErrorException($serializer->deserialize($body, 'AntiPatternInc\\Saasus\\Sdk\\ApiLog\\Model\\Error', 'json'));
}
}
public function getAuthenticationScopes() : array
{
return array('Bearer');
}
}
7 changes: 7 additions & 0 deletions generated/ApiLog/Exception/ApiException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Exception;

interface ApiException extends \Throwable
{
}
7 changes: 7 additions & 0 deletions generated/ApiLog/Exception/ClientException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Exception;

interface ClientException extends ApiException
{
}
20 changes: 20 additions & 0 deletions generated/ApiLog/Exception/GetLogInternalServerErrorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Exception;

class GetLogInternalServerErrorException extends InternalServerErrorException
{
/**
* @var \AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error
*/
private $error;
public function __construct(\AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error $error)
{
parent::__construct('Internal Server Error');
$this->error = $error;
}
public function getError() : \AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error
{
return $this->error;
}
}
20 changes: 20 additions & 0 deletions generated/ApiLog/Exception/GetLogsInternalServerErrorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Exception;

class GetLogsInternalServerErrorException extends InternalServerErrorException
{
/**
* @var \AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error
*/
private $error;
public function __construct(\AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error $error)
{
parent::__construct('Internal Server Error');
$this->error = $error;
}
public function getError() : \AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error
{
return $this->error;
}
}
11 changes: 11 additions & 0 deletions generated/ApiLog/Exception/InternalServerErrorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Exception;

class InternalServerErrorException extends \RuntimeException implements ServerException
{
public function __construct(string $message)
{
parent::__construct($message, 500);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Exception;

class ReturnInternalServerErrorInternalServerErrorException extends InternalServerErrorException
{
/**
* @var \AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error
*/
private $error;
public function __construct(\AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error $error)
{
parent::__construct('Internal Server Error');
$this->error = $error;
}
public function getError() : \AntiPatternInc\Saasus\Sdk\ApiLog\Model\Error
{
return $this->error;
}
}
7 changes: 7 additions & 0 deletions generated/ApiLog/Exception/ServerException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace AntiPatternInc\Saasus\Sdk\ApiLog\Exception;

interface ServerException extends ApiException
{
}
Loading

0 comments on commit dc81afc

Please sign in to comment.