Authorize.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Lackoxygen\TiktokShop\Passage;
use Illuminate\Support\Arr;
class Authorize extends Passage
{
/**
* @param string $code
* @param string $grantType {authorization_self, authorization_code}
* @param bool $sandbox
* @return ResultSet
*/
public function token(string $code, string $grantType = 'authorization_code', bool $sandbox = false)
{
$params = ['code' => $code, 'grant_type' => $grantType];
if ($sandbox) {
if ($grantType === 'authorization_self') {
if ($code == '4463798') {
Arr::set($params, 'test_shop', 1);
} else {
Arr::set($params, 'shop_id', $code);
}
}
}
$this->builder->service('token.create');
$this->builder
->method('GET')
->path('/token/create')
->service('token.create')
->params($params);
}
/**
* @param string $refreshToken
* @param string $grantType
* @return ResultSet
*/
public function refresh(string $refreshToken, string $grantType = 'refresh_token')
{
$this->builder
->method('POST')
->service('token.refresh')
->params(['refresh_token' => $refreshToken, 'grant_type' => $grantType]);
}
}