Passed
Push — master ( 537d5b...b60ede )
by Andrey
03:11
created

CommonGeneral::createApiKey()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Daaner\NovaPoshta\Models;
4
5
use Daaner\NovaPoshta\NovaPoshta;
6
use Daaner\NovaPoshta\Traits\Limit;
7
8
class CommonGeneral extends NovaPoshta
9
{
10
    use Limit;
11
12
    protected $model = 'CommonGeneral';
13
    protected $calledMethod;
14
    protected $methodProperties = null;
15
16
    /**
17
     * Список ошибок.
18
     * Работает без авторизации.
19
     *
20
     * @see https://developers.novaposhta.ua/view/model/a55b2c64-8512-11ec-8ced-005056b2dbe1/method/a6bce5a1-8512-11ec-8ced-005056b2dbe1 Список ошибок
21
     * @since 2022-11-03
22
     *
23
     * @return array
24
     */
25
    public function getMessageCodeText(): array
26
    {
27
        $this->calledMethod = 'getMessageCodeText';
28
29
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, false);
30
    }
31
32
    /**
33
     * Продление даты действия API ключа.
34
     *
35
     * @since 2022-11-03
36
     *
37
     * @param  string  $ApiKey  API ключ
38
     * @param  int|null  $month  Кол-во месяцев продления
39
     * @return array
40
     */
41
    public function prolongateKey(string $ApiKey, ?int $month = 12): array
42
    {
43
        $this->calledMethod = 'prolongateApiKey';
44
45
        $this->methodProperties['ApiKey'] = $ApiKey;
46
        $this->methodProperties['prolongateMounthCount'] = $month;
47
48
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
49
    }
50
51
    /**
52
     * Получение списка API ключей.
53
     *
54
     * @since 2022-11-03
55
     *
56
     * @return array
57
     */
58
    public function getApiKeysList(): array
59
    {
60
        $this->calledMethod = 'getApiKeysList';
61
62
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
63
    }
64
65
    /**
66
     * Получение доверенных устройств.
67
     *
68
     * @since 2022-11-03
69
     *
70
     * @return array
71
     */
72
    public function getTrustedDevicesList(): array
73
    {
74
        $this->calledMethod = 'getTrustedDevicesList';
75
76
        $this->getLimit();
77
        $this->getPage();
78
79
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
80
    }
81
82
    /**
83
     * Удаление доверенного устройства со списка.
84
     *
85
     * @since 2022-11-03
86
     *
87
     * @param  string  $Ref  Ref устройства
88
     * @return array
89
     */
90
    public function deleteTrustedDevice(string $Ref): array
91
    {
92
        $this->calledMethod = 'deleteTrustedDevice';
93
94
        $this->methodProperties['Ref'] = $Ref;
95
96
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
97
    }
98
99
    /**
100
     * Создание API ключа.
101
     *
102
     * @since 2022-11-07 НЕ ДОКУМЕНТИРОВАНО
103
     *
104
     * @param string|null $MarketplacePartnerToken
105
     * @return array
106
     */
107
    public function createApiKey(?string $MarketplacePartnerToken = null): array
108
    {
109
        $this->calledMethod = 'createApiKey';
110
111
        if ($MarketplacePartnerToken) {
112
            $this->methodProperties['MarketplacePartnerToken'] = $MarketplacePartnerToken;
113
        }
114
115
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
116
    }
117
118
    /**
119
     * Удаление API ключа.
120
     *
121
     * @since 2022-11-07 НЕ ДОКУМЕНТИРОВАНО
122
     *
123
     * @param string $ApiKey
124
     * @return array
125
     */
126
    public function deleteApiKey(string $ApiKey): array
127
    {
128
        $this->calledMethod = 'deleteApiKey';
129
130
        $this->methodProperties['ApiKey'] = $ApiKey;
131
132
        return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties, true);
133
    }
134
}
135