Payments::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Uon\Endpoints;
4
5
use Uon\Client;
6
7
/**
8
 * Class Payments
9
 *
10
 * @package Uon\Endpoint
11
 */
12
class Payments extends Client
13
{
14
    /**
15
     * Create new payment
16
     *
17
     * @link https://api.u-on.ru/{key}/payment/create.{_format}
18
     *
19
     * @param array $parameters List of parameters
20
     *
21
     * @return null|object|\Uon\Interfaces\ClientInterface
22
     */
23
    public function create(array $parameters)
24
    {
25
        // Set HTTP params
26
        $this->type     = 'post';
27
        $this->endpoint = 'payment/create';
28
        $this->params   = $parameters;
29
30
        return $this->done();
31
    }
32
33
    /**
34
     * Get full list of payments in dates range
35
     *
36
     * @link https://api.u-on.ru/{key}/payment/list/{date_from}/{date_to}.{_format}
37
     *
38
     * @param string $dateFrom Start of dates range
39
     * @param string $dateTo   End of dates range
40
     * @param int    $page     Number of page, 1 by default
41
     *
42
     * @return null|object|\Uon\Interfaces\ClientInterface
43
     */
44
    public function all(string $dateFrom, string $dateTo, $page = 1)
45
    {
46
        // Set HTTP params
47
        $this->type     = 'get';
48
        $this->endpoint = 'payment/list/' . $dateFrom . '/' . $dateTo . '/' . $page;
49
50
        return $this->done();
51
    }
52
53
    /**
54
     * Get list of all payment views
55
     *
56
     * @link https://api.u-on.ru/{key}/payment_form.{_format}
57
     *
58
     * @return null|object|\Uon\Interfaces\ClientInterface
59
     */
60
    public function allForms()
61
    {
62
        // Set HTTP params
63
        $this->type     = 'get';
64
        $this->endpoint = 'payment_form';
65
66
        return $this->done();
67
    }
68
69
    /**
70
     * Get list of all other payment types
71
     *
72
     * @link https://api.u-on.ru/{key}/payment_other_type.{_format}
73
     *
74
     * @return null|object|\Uon\Interfaces\ClientInterface
75
     */
76
    public function allOtherTypes()
77
    {
78
        // Set HTTP params
79
        $this->type     = 'get';
80
        $this->endpoint = 'payment_other_type';
81
82
        return $this->done();
83
    }
84
85
    /**
86
     * Get a single payment
87
     *
88
     * @link https://api.u-on.ru/{key}/payment/{id}.{_format}
89
     *
90
     * @param int $id Unique payment ID
91
     *
92
     * @return null|object|\Uon\Interfaces\ClientInterface
93
     */
94
    public function get(int $id)
95
    {
96
        // Set HTTP params
97
        $this->type     = 'get';
98
        $this->endpoint = 'payment/' . $id;
99
100
        return $this->done();
101
    }
102
103
    /**
104
     * Update selected payment by id
105
     *
106
     * @link https://api.u-on.ru/{key}/payment/update/{id}.{_format}
107
     *
108
     * @param int   $id         Unique payment ID
109
     * @param array $parameters List of parameters
110
     *
111
     * @return null|object|\Uon\Interfaces\ClientInterface
112
     */
113
    public function update(int $id, array $parameters)
114
    {
115
        // Set HTTP params
116
        $this->type     = 'post';
117
        $this->endpoint = 'payment/update/' . $id;
118
        $this->params   = $parameters;
119
120
        return $this->done();
121
    }
122
123
    /**
124
     * Delete selected payment from database
125
     *
126
     * @link https://api.u-on.ru/{key}/payment/delete/{id}.{_format}
127
     *
128
     * @param int $id Unique payment ID
129
     *
130
     * @return null|object|\Uon\Interfaces\ClientInterface
131
     */
132
    public function delete(int $id)
133
    {
134
        // Set HTTP params
135
        $this->type     = 'post';
136
        $this->endpoint = 'payment/delete/' . $id;
137
138
        return $this->done();
139
    }
140
}
141