Skip to content

Commit 335b8b4

Browse files
committed
ürün modülünde iyileştirmeler yapıldı.
1 parent 2f60843 commit 335b8b4

File tree

3 files changed

+198
-0
lines changed

3 files changed

+198
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php namespace SistemApi\Model\Ayar\Urun;
2+
3+
use SistemApi\Model\Ayar\Base\ListeAyar;
4+
5+
class OzellikGrupListeAyar extends ListeAyar
6+
{
7+
/**
8+
* @var int
9+
*/
10+
private $kategoriIds;
11+
12+
/**
13+
* @return array
14+
*/
15+
public function toArray()
16+
{
17+
return array_merge(parent::toArray(), [
18+
'kategoriIds' => $this->kategoriIds
19+
]);
20+
}
21+
22+
/**
23+
* @return OzellikGrupListeAyar
24+
*/
25+
public function setOrderByAdi()
26+
{
27+
return $this->setOrderBy('adi');
28+
}
29+
30+
/**
31+
* @param int $kategoriId
32+
* @return $this
33+
*/
34+
public function addKategoriId($kategoriId)
35+
{
36+
$this->kategoriIds[] = $kategoriId;
37+
return $this;
38+
}
39+
40+
/**
41+
* @param int $kategoriIds
42+
* @return OzellikGrupListeAyar
43+
*/
44+
public function setKategoriIds($kategoriIds)
45+
{
46+
$this->kategoriIds = $kategoriIds;
47+
return $this;
48+
}
49+
50+
/**
51+
* @return int
52+
*/
53+
public function getKategoriIds()
54+
{
55+
return $this->kategoriIds;
56+
}
57+
}

src/SistemApi/Model/Ayar/UrunListeAyar.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,116 @@
44

55
class UrunListeAyar extends ListeAyar
66
{
7+
/**
8+
* @var array
9+
*/
10+
private $kategoriIds = [];
11+
12+
/**
13+
* @var array
14+
*/
15+
private $ozellikGrupIds = [];
16+
17+
/**
18+
* @var array
19+
*/
20+
private $ozellikIds = [];
21+
22+
/**
23+
* @return array
24+
*/
25+
public function toArray()
26+
{
27+
return array_merge(parent::toArray(), [
28+
'kategoriIds' => $this->kategoriIds,
29+
'ozellikGrupIds' => $this->ozellikGrupIds,
30+
'ozellikIds' => $this->ozellikIds
31+
]);
32+
}
33+
34+
/**
35+
* @param int $kategoriId
36+
* @return $this
37+
*/
38+
public function addKategoriId($kategoriId)
39+
{
40+
$this->kategoriIds[] = $kategoriId;
41+
return $this;
42+
}
43+
44+
/**
45+
* @param array $kategoriIds
46+
* @return UrunListeAyar
47+
*/
48+
public function setKategoriIds($kategoriIds)
49+
{
50+
$this->kategoriIds = $kategoriIds;
51+
return $this;
52+
}
53+
54+
/**
55+
* @return array
56+
*/
57+
public function getKategoriIds()
58+
{
59+
return $this->kategoriIds;
60+
}
61+
62+
/**
63+
* @param int $ozellikGrupId
64+
* @return $this
65+
*/
66+
public function addOzellikGrupId($ozellikGrupId)
67+
{
68+
$this->ozellikGrupIds[] = $ozellikGrupId;
69+
return $this;
70+
}
71+
72+
/**
73+
* @param array $ozellikGrupIds
74+
* @return UrunListeAyar
75+
*/
76+
public function setOzellikGrupIds($ozellikGrupIds)
77+
{
78+
$this->ozellikGrupIds = $ozellikGrupIds;
79+
return $this;
80+
}
81+
82+
/**
83+
* @return array
84+
*/
85+
public function getOzellikGrupIds()
86+
{
87+
return $this->ozellikGrupIds;
88+
}
89+
90+
/**
91+
* @param int $ozellikId
92+
* @return $this
93+
*/
94+
public function addOzellikId($ozellikId)
95+
{
96+
$this->ozellikIds[] = $ozellikId;
97+
return $this;
98+
}
99+
100+
/**
101+
* @param array $ozellikIds
102+
* @return UrunListeAyar
103+
*/
104+
public function setOzellikIds($ozellikIds)
105+
{
106+
$this->ozellikIds = $ozellikIds;
107+
return $this;
108+
}
109+
110+
/**
111+
* @return array
112+
*/
113+
public function getOzellikIds()
114+
{
115+
return $this->ozellikIds;
116+
}
117+
7118

8119
}

src/SistemApi/Service/UrunService.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use SistemApi\Exception\NotFoundException;
55
use SistemApi\Exception\UnauthorizedException;
66
use SistemApi\Exception\UnknownException;
7+
use SistemApi\Model\Ayar\Urun\OzellikGrupListeAyar;
78
use SistemApi\Model\Ayar\UrunKategoriListeAyar;
89
use SistemApi\Model\Ayar\UrunListeAyar;
910
use SistemApi\Model\Response\UrunKategoriPagedResponse;
@@ -194,6 +195,8 @@ public function guncelleKategori($id, $data)
194195
}
195196

196197
/**
198+
* @deprecated use listeOzellikGrup
199+
*
197200
* @return UrunKategori[]
198201
*
199202
* @throws UnauthorizedException
@@ -219,6 +222,33 @@ public function getListeOzellikGrup()
219222
throw new UnknownException($response);
220223
}
221224

225+
/**
226+
* @param OzellikGrupListeAyar $ayar
227+
* @return UrunKategori[]
228+
*
229+
* @throws UnauthorizedException
230+
* @throws UnknownException
231+
*/
232+
public function listeOzellikGrup(OzellikGrupListeAyar $ayar = null)
233+
{
234+
// response alalım
235+
$response = $this->api->get('/urun/ozellik-grup/liste', is_null($ayar) ? [] : $ayar->toArray());
236+
237+
// durum koduna göre işlem yapalım
238+
switch ($response->code) {
239+
240+
case 200:
241+
242+
return array_map(function($item) {
243+
return new UrunOzellikGrup($item);
244+
}, $response->body);
245+
246+
case 401: throw new UnauthorizedException($response->body->mesaj);
247+
}
248+
249+
throw new UnknownException($response);
250+
}
251+
222252
/**
223253
* @param int $id
224254
* @return UrunKategori

0 commit comments

Comments
 (0)