Consent::status()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace TarfinLabs\Iys;
4
5
class Consent
6
{
7
    protected $endpoint;
8
    protected $config;
9
10
    public function __construct()
11
    {
12
        $this->config = config('laravel-iys');
13
        $this->endpoint = "/sps/{$this->config['iys_code']}/brands/{$this->config['brand_code']}/consents";
14
    }
15
16
    /**
17
     * Alıcıdan alınmış izinleri tekil olarak İYS'ye yükler.
18
     *
19
     * Doc: https://dev.iys.org.tr/api-metotlar/izin-yonetimi/tekil-izin-ekleme/
20
     *
21
     * @param array $params
22
     * @return array|mixed
23
     */
24
    public function create(array $params)
25
    {
26
        return app(Client::class)->postJson($this->endpoint, $params);
27
    }
28
29
    /**
30
     * Alıcıdan alınmış izinleri yığın olarak İYS'ye yükler.
31
     *
32
     * Doc: https://dev.iys.org.tr/api-metotlar/izin-yonetimi/asenkron-coklu-izin-ekleme/
33
     *
34
     * @param array $params
35
     * @return array|mixed
36
     */
37
    public function createMany(array $params)
38
    {
39
        return app(Client::class)->postJson($this->endpoint . '/request', $params);
40
    }
41
42
    /**
43
     * Hizmet sağlayıcıların İYS'de kayıtlı olan izinlerini tekil olarak listelemelerini sağlar.
44
     *
45
     * Doc: https://dev.iys.org.tr/api-metotlar/izin-yonetimi/tekil-izin-durumu-sorgulama/
46
     *
47
     * @param array $params
48
     * @return array|mixed
49
     */
50
    public function status(array $params)
51
    {
52
        return app(Client::class)->postJson($this->endpoint . '/status', $params);
53
    }
54
55
    /**
56
     * Asenkron çoklu izin ekleme işlemi sonunda dönen işlem sorgulama bilgisiyle
57
     * izin kayıt isteklerinin sonuçlarını sorgular.
58
     *
59
     * Doc: https://dev.iys.org.tr/api-metotlar/izin-yonetimi/coklu-izin-ekleme-istegi-sorgulama/
60
     *
61
     * @param string $requestId
62
     * @return array|mixed
63
     */
64
    public function statuses(string $requestId)
65
    {
66
        return app(Client::class)->getJson($this->endpoint . '/request/' . $requestId);
67
    }
68
69
    /**
70
     * Tekil iznin mevcut bayi izin erişimlerine, yeni bayilerin izin erişimini ekler.
71
     *
72
     * Doc: https://dev.iys.org.tr/api-metotlar/bayi-izin-yonetimi/bayi-izin-erisimi-ekleme/
73
     *
74
     * @param array $params
75
     * @return array|mixed
76
     */
77
    public function giveAccess(array $params)
78
    {
79
        return app(Client::class)->postJson($this->endpoint . '/retailers/access', $params);
80
    }
81
82
    /**
83
     * Birden fazla bayiye birden fazla izin için erişim verilmesini sağlar.
84
     *
85
     * Doc: https://dev.iys.org.tr/api-metotlar/bayi-izin-yonetimi/bayi-izin-erisimi-verme/
86
     *
87
     * @param array $params
88
     * @return array|mixed
89
     */
90
    public function giveManyAccess(array $params)
91
    {
92
        return app(Client::class)->putJson($this->endpoint . '/retailers/access', $params);
93
    }
94
95
    /**
96
     * Tekil iznin hangi bayilerle ilişkili olduğunu sorgular.
97
     *
98
     * Doc: https://dev.iys.org.tr/api-metotlar/bayi-izin-yonetimi/bayi-erisimi-sorgulama/
99
     *
100
     * @param array $params
101
     * @param int|null $offset
102
     * @param int|null $limit
103
     * @return array|mixed
104
     */
105
    public function accessList(array $params, int $offset = null, int $limit = null)
106
    {
107
        $query = '';
108
109
        if ($offset && $limit) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $offset of type null|integer is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
Bug Best Practice introduced by
The expression $limit of type null|integer is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
110
            $query = '?' . http_build_query([
111
                    'offset' => $offset,
112
                    'limit' => $limit,
113
                ]);
114
        }
115
116
        return app(Client::class)->postJson($this->endpoint . '/retailers/access/list' . $query, $params);
117
    }
118
119
    /**
120
     * Birden fazla bayinin birden fazla izin için erişimini siler.
121
     *
122
     * Doc: https://dev.iys.org.tr/api-metotlar/bayi-izin-yonetimi/coklu-bayi-erisimi-silme/
123
     *
124
     * @param array $params
125
     * @return array|mixed
126
     */
127
    public function deleteAccess(array $params)
128
    {
129
        return app(Client::class)->postJson($this->endpoint . '/retailer/access/remove', $params);
130
    }
131
132
    /**
133
     * Tüm bayilerin birden fazla izin için erişimini siler.
134
     *
135
     * Doc: https://dev.iys.org.tr/api-metotlar/bayi-izin-yonetimi/tum-bayilerin-izin-erisimlerini-silme/
136
     *
137
     * @param array $params
138
     * @return array|mixed
139
     */
140
    public function deleteAllAccess(array $params)
141
    {
142
        return app(Client::class)->postJson($this->endpoint . '/retailer/access/remove/all', $params);
143
    }
144
}
145