Completed
Push — master ( 8e0025...04518a )
by
05:55
created

Token::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the PhpMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhpMob\Omise\Api;
13
14
use PhpMob\Omise\Api;
15
use PhpMob\Omise\Domain\Token as Domain;
16
17
/**
18
 * @author Ishmael Doss <[email protected]>
19
 *
20
 * @see https://www.omise.co/tokens-api
21
 */
22
final class Token extends Api
23
{
24
    /**
25
     * @var bool
26
     */
27
    protected $isSensitive = true;
28
29
    /**
30
     * @param string $id
31
     *
32
     * @return Domain
33
     */
34
    public function find($id)
35
    {
36
        self::assertNotEmpty($id);
37
38
        return $this->doRequest('GET', '/tokens/'.$id);
39
    }
40
41
    /**
42
     * @param Domain $token
43
     */
44
    public function refresh(Domain $token)
45
    {
46
        $token->updateStore($this->find($token->id)->toArray());
47
    }
48
49
    /**
50
     * @param Domain $token
51
     */
52
    public function create(Domain $token)
53
    {
54
        $token->updateStore($this->doRequest('POST', '/tokens', $token->getCreateData())->toArray());
55
    }
56
}
57