Order::createRefund()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Codexshaper\WooCommerce\Models;
4
5
use Codexshaper\WooCommerce\Facades\Query;
6
use Codexshaper\WooCommerce\Traits\QueryBuilderTrait;
7
8
class Order extends BaseModel
9
{
10
    use QueryBuilderTrait;
11
12
    protected $endpoint = 'orders';
13
14
    /**
15
     * Retrieve all notes.
16
     *
17
     * @param int   $order_id
18
     * @param array $options
19
     *
20
     * @return array
21
     */
22
    protected function notes($order_id, $options = [])
23
    {
24
        return Query::init()
25
            ->setEndpoint("orders/{$order_id}/notes")
26
            ->all($options);
27
    }
28
29
    /**
30
     * Retreive a note.
31
     *
32
     * @param int   $order_id
33
     * @param int   $note_id
34
     * @param array $options
35
     *
36
     * @return object
37
     */
38
    protected function note($order_id, $note_id, $options = [])
39
    {
40
        return Query::init()
41
            ->setEndpoint("orders/{$order_id}/notes")
42
            ->find($note_id, $options);
43
    }
44
45
    /**
46
     * Create a note.
47
     *
48
     * @param int   $order_id
49
     * @param array $data
50
     *
51
     * @return object
52
     */
53
    protected function createNote($order_id, $data = [])
54
    {
55
        return Query::init()
56
            ->setEndpoint("orders/{$order_id}/notes")
57
            ->create($data);
58
    }
59
60
    /**
61
     * Delete a note.
62
     *
63
     * @param int   $order_id
64
     * @param int   $note_id
65
     * @param array $options
66
     *
67
     * @return object
68
     */
69
    protected function deleteNote($order_id, $note_id, $options = [])
70
    {
71
        return Query::init()
72
            ->setEndpoint("orders/{$order_id}/notes")
73
            ->delete($note_id, $options);
74
    }
75
76
    /**
77
     * Retrieve all refunds.
78
     *
79
     * @param int   $order_id
80
     * @param array $options
81
     *
82
     * @return array
83
     */
84
    protected function refunds($order_id, $options = [])
85
    {
86
        return Query::init()
87
            ->setEndpoint("orders/{$order_id}/refunds")
88
            ->all($options);
89
    }
90
91
    /**
92
     * Retrieve a refund.
93
     *
94
     * @param int   $order_id
95
     * @param int   $refund_id
96
     * @param array $options
97
     *
98
     * @return object
99
     */
100
    protected function refund($order_id, $refund_id, $options = [])
101
    {
102
        return Query::init()
103
            ->setEndpoint("orders/{$order_id}/refunds")
104
            ->find($refund_id, $options);
105
    }
106
107
    /**
108
     * Create refund.
109
     *
110
     * @param int   $order_id
111
     * @param array $data
112
     *
113
     * @return object
114
     */
115
    protected function createRefund($order_id, $data = [])
116
    {
117
        return Query::init()
118
            ->setEndpoint("orders/{$order_id}/refunds")
119
            ->create($data);
120
    }
121
122
    /**
123
     * Delete refund.
124
     *
125
     * @param int   $order_id
126
     * @param int   $refund_id
127
     * @param array $options
128
     *
129
     * @return object
130
     */
131
    protected function deleteRefund($order_id, $refund_id, $options = [])
132
    {
133
        return Query::init()
134
            ->setEndpoint("orders/{$order_id}/refunds")
135
            ->delete($refund_id, $options);
136
    }
137
}
138