Completed
Push — master ( 6d9ae5...9656aa )
by
18:43 queued 08:49
created

Dispute::refresh()   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\Dispute as Domain;
16
use PhpMob\Omise\Domain\Pagination;
17
18
/**
19
 * @author Saranyu <[email protected]>
20
 *
21
 * @see https://www.omise.co/disputes-api
22
 */
23
final class Dispute extends Api
24
{
25
    /**
26
     * @param array $parameters
27
     *
28
     * @return Pagination
29
     */
30
    public function all(array $parameters = [])
31
    {
32
        return $this->doRequest('GET', '/disputes', $parameters);
33
    }
34
35
    /**
36
     * @param array $parameters
37
     *
38
     * @return Pagination
39
     */
40
    public function opens(array $parameters = [])
41
    {
42
        return $this->doRequest('GET', '/disputes/open', $parameters);
43
    }
44
45
    /**
46
     * @param array $parameters
47
     *
48
     * @return Pagination
49
     */
50
    public function pendings(array $parameters = [])
51
    {
52
        return $this->doRequest('GET', '/disputes/pending', $parameters);
53
    }
54
55
    /**
56
     * @param array $parameters
57
     *
58
     * @return Pagination
59
     */
60
    public function closeds(array $parameters = [])
61
    {
62
        return $this->doRequest('GET', '/disputes/closed', $parameters);
63
    }
64
65
    /**
66
     * @param string $id
67
     *
68
     * @return Domain
69
     */
70
    public function find($id)
71
    {
72
        self::assertNotEmpty($id);
73
74
        return $this->doRequest('GET', '/disputes/'.$id);
75
    }
76
77
    /**
78
     * @param Domain $dispute
79
     */
80
    public function refresh(Domain $dispute)
81
    {
82
        $dispute->updateStore($this->find($dispute->id)->toArray());
83
    }
84
85
    /**
86
     * @param Domain $dispute
87
     */
88
    public function update(Domain $dispute)
89
    {
90
        self::assertNotEmpty($dispute->id);
91
92
        $dispute->updateStore($this->doRequest('PATCH', '/disputes/'.$dispute->id, $dispute->getUpdateData())->toArray());
93
    }
94
}
95