作者 lackoxygen

add part api

... ... @@ -7,6 +7,7 @@ use Lackoxygen\TiktokOpen\Base\Event\Fail;
use Lackoxygen\TiktokOpen\Base\Event\Request;
use Lackoxygen\TiktokOpen\Base\Event\Response;
use Lackoxygen\TiktokOpen\Base\ServiceManager;
use Lackoxygen\TiktokOpen\Base\Signer\SignerInterface;
use Lackoxygen\TiktokOpen\Base\Traits\BaseClient;
use Lackoxygen\TiktokOpen\Wap\Listener;
use GuzzleHttp\RequestOptions;
... ... @@ -20,10 +21,13 @@ class Client extends ServiceManager
private bool $withSession;
private SignerInterface $signer;
public function __construct(
Application $app, $requestOption = '', $withSession = false
)
{
Application $app,
$requestOption = '',
$withSession = false
) {
parent::__construct($app);
$this->listen();
... ... @@ -43,43 +47,34 @@ class Client extends ServiceManager
public function asForm(): Client
{
return new Client(
$this->app,
RequestOptions::FORM_PARAMS,
$this->withSession
);
return new Client($this->app, RequestOptions::FORM_PARAMS, $this->withSession);
}
public function asJson(): Client
{
return new Client(
$this->app,
RequestOptions::JSON,
$this->withSession
);
return new Client($this->app, RequestOptions::JSON, $this->withSession);
}
public function asMultipart(): Client
{
return new Client(
$this->app,
RequestOptions::MULTIPART,
$this->withSession
);
return new Client($this->app, RequestOptions::MULTIPART, $this->withSession);
}
public function withSession(): Client
{
return new Client(
$this->app,
$this->requestOption,
true
);
return new Client($this->app, $this->requestOption, true);
}
public function signVia(SignerInterface $signer): Client
{
$this->signer = $signer;
return $this;
}
public function refresh()
{
$this->requestOption = '';
$this->withSession = false;
$this->withSession = false;
}
}
... ...
<?php
namespace Lackoxygen\TiktokOpen\Base\Signer;
use Lackoxygen\TiktokOpen\Base\Client\Request;
class LifeSigner implements SignerInterface
{
protected Request $request;
public function setRequest(Request $request)
{
$this->request = $request;
}
public function make()
{
}
}
\ No newline at end of file
... ...
<?php
namespace Lackoxygen\TiktokOpen\Base\Signer;
use Lackoxygen\TiktokOpen\Base\Client\Request;
interface SignerInterface
{
public function setRequest(Request $request);
public function make();
}
\ No newline at end of file
... ...
<?php
namespace Lackoxygen\TiktokOpen\Wap\Life;
use Lackoxygen\TiktokOpen\Base\ServiceManager;
use Lackoxygen\TiktokOpen\Base\Signer\LifeSigner;
class Coupon extends ServiceManager
{
/**
* 验券准备
*
* @param string $encryptedData
* @param string $code
*
* @return mixed
*/
public function prepare(string $encryptedData = '', string $code = '')
{
return $this->app['client']->signVia(new LifeSigner())
->asForm()
->post('/goodlife/v1/fulfilment/certificate/prepare/',
['encrypted_data' => $encryptedData, 'code' => $code]);
}
/**
* 验券
*
* @param array $body
*
* @return mixed
*/
public function verify(array $body = [])
{
return $this->app['client']->signVia(new LifeSigner())
->asForm()
->post('/goodlife/v1/fulfilment/certificate/verify/', $body);
}
/**
* 撤销核销
*
* @link https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/life-service-open-ability/life.capacity/life.capacity.fulfilment/certificate.verify
*
* @param array $body
*
* @return mixed
*/
public function cancel(array $body = [])
{
return $this->app['client']->signVia(new LifeSigner())
->asForm()
->post('/goodlife/v1/fulfilment/certificate/cancel/', $body);
}
/**
* 券状态查询
*
* @param string $encryptedCode
*
* @return mixed
*/
public function get(string $encryptedCode)
{
return $this->app['client']->signVia(new LifeSigner())
->asForm()
->get('/goodlife/v1/fulfilment/certificate/get/', ['encrypted_code' => $encryptedCode]);
}
/**
* 券状态批量查询
*
* @param string $encryptedCode
* @param string $orderId
*
* @return mixed
*/
public function query(string $encryptedCode = '', string $orderId = '')
{
return $this->app['client']->signVia(new LifeSigner())
->asForm()
->get('/goodlife/v1/fulfilment/certificate/query/',
['encrypted_code' => $encryptedCode, 'order_id' => $orderId]);
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ namespace Lackoxygen\TiktokOpen\Wap;
use Lackoxygen\TiktokOpen\Base\AbstractProvider;
use Lackoxygen\TiktokOpen\Base\Client\Client;
use Lackoxygen\TiktokOpen\Wap\{Data\Data, Js\Js, OAuth\OAuth, User\User, Video\Video};
use Lackoxygen\TiktokOpen\Wap\{Data\Data, Js\Js, Life\Coupon, OAuth\OAuth, User\User, Video\Video};
/**
* @method OAuth oauth()
... ... @@ -24,7 +24,8 @@ class WapProvider extends AbstractProvider
'user' => User::class,
'video' => Video::class,
'data' => Data::class,
'session' => Session::class
'session' => Session::class,
'lifeCoupon' => Coupon::class
];
public function __construct(string $alias)
... ...