Completed
Push — master ( 02535a...59a557 )
by Onur
01:11
created

ProductStock::getProductStockByProductId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Onurkacmaz\LaravelN11\Models;
4
5
use Onurkacmaz\LaravelN11\Exceptions\N11Exception;
6
use Onurkacmaz\LaravelN11\Service;
7
use SoapClient;
8
9
class ProductStock extends Service
10
{
11
12
    /**
13
     * @var SoapClient|null
14
     */
15
    private $_client;
16
17
    /**
18
     * @var string
19
     */
20
    private $endPoint = "/ProductStockService.wsdl";
21
22
    /**
23
     * Category constructor
24
     * endPoint set edildi.
25
     * @throws N11Exception|\SoapFault
26
     */
27
    public function __construct()
28
    {
29
        parent::__construct();
30
        $this->_client = $this->setEndPoint($this->endPoint);
31
    }
32
33
    /**
34
     * @param int $productId
35
     * @return mixed
36
     * @description Sistemde kayıtlı olan ürünün N11 ürün ID si ile ürün stok bilgilerini getiren metottur.
37
     * Cevap içinde stok durumunun “version” bilgisi de vardır, ürün stoklarında değişme olduysa bu versiyon bilgisi artacaktır,
38
     * Çağrı yapan taraf versiyon bilgisini kontrol ederek N11 e verilen stok bilgilerinde değişim olup olmadığını anlayabilir.
39
     */
40
    public function getProductStockByProductId(int $productId)
41
    {
42
        $this->_parameters["product"]["id"] = $productId;
43
        return $this->_client->GetProductStockByProductId($this->_parameters);
44
    }
45
46
    /**
47
     * @param string $productSellerCode
48
     * @return mixed
49
     * @description Sistemde kayıtlı olan ürünün N11 ürün ID si ile ürün stok bilgilerini getiren metottur.
50
     * Cevap içinde stok durumunun “version” bilgisi de vardır, ürün stoklarında değişme olduysa bu versiyon bilgisi artacaktır,
51
     * Çağrı yapan taraf versiyon bilgisini kontrol ederek N11 e verilen stok bilgilerinde değişim olup olmadığını anlayabilir.
52
     */
53
    public function getProductStockBySellerCode(string $productSellerCode)
54
    {
55
        $this->_parameters["productSellerCode"] = $productSellerCode;
56
        return $this->_client->GetProductStockBySellerCode($this->_parameters);
57
    }
58
59
    /**
60
     * @param int $productId
61
     * @param string $attrName
62
     * @param string $attrValue
63
     * @param int $quantity
64
     * @param int $version
65
     * @return mixed
66
     * @description Ürün stok seçenek bilgilerini kullanarak kayıtlı ürünün stok bilgilerini güncellemek için kullanılır.
67
     * Ürün n11 ID si ve stok seçenek bilgileri girilerek güncelleme işlemi yapılır.
68
     * Bir ürüne ait stok bilgilerine, ProductStockService içindeki GetProductStockByProductId veya GetProductStockBySellerCode metotları ile ulaşılabilir.
69
     * Bir ürün için tüm stok bilgilerini güncelleme işlemi gerçekleştirilebilir.
70
     * N11 tarafında değişen stok miktarlarını ezmemek için, “version” bilgisi verilmesi durumunda ilgili ürün stok bilgisinin N11 de versiyonu ile karşılaştırma yapılır, stok versiyon numaraları uyumsuz ise işlem gerçekleştirilmez.
71
     */
72 View Code Duplication
    public function updateStockByStockAttributes(int $productId, string $attrName, string $attrValue, int $quantity, int $version = 0) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
        $this->_parameters["product"] = [
74
            "Id" => $productId,
75
            "stockItems" => [
76
                "stockItem" => [
77
                    "attributes" => [
78
                        "attribute" => [
79
                            "name" => $attrName,
80
                            "value" => $attrValue,
81
                            "quantity" => $quantity,
82
                            "version" => $version,
83
                        ]
84
                    ]
85
                ]
86
            ]
87
        ];
88
        return $this->_client->DeleteAndUpdateStockByStockAttributes($this->_parameters);
89
    }
90
91
    /**
92
     * @param int $stockItemId
93
     * @param int $quantity
94
     * @param int $version
95
     * @return mixed
96
     * @description n11 ürün stok ID si kullanarak kayıtlı ürünün stok bilgilerini güncellemek için kullanılır.
97
     * n11 ürün stok ID si ve miktar bilgileri girilerek güncelleme işlemi yapılır.
98
     * Bir ürüne ait n11 ürün stok ID sine, ProductStockService içindeki GetProductStockByProductId veya GetProductStockBySellerCode metotları ile ulaşılabilir.
99
     * N11 tarafında değişen stok miktarlarını ezmemek için, “version” bilgisi verilmesi durumunda ilgili ürün stok bilgisinin N11 de versiyonu ile karşılaştırma yapılır, stok versiyon numaraları uyumsuz ise işlem gerçekleştirilmez.
100
     */
101
    public function updateStockByStockId(int $stockItemId, int $quantity, int $version = 0) {
102
        $this->_parameters["stockItems"] = [
103
            "stockItem" => [
104
                "id" => $stockItemId,
105
                "quantity" => $quantity,
106
                "version" => $version,
107
            ]
108
        ];
109
        return $this->_client->UpdateStockByStockId($this->_parameters);
110
    }
111
112
    /**
113
     * @param string $stockSellerCode
114
     * @param int $quantity
115
     * @param int $version
116
     * @return mixed
117
     * @description Mağaza ürün stok kodu kullanarak kayıtlı ürünün stok bilgilerini güncellemek için kullanılır.
118
     * Mağaza ürün stok kodu ve miktar bilgileri girilerek güncelleme işlemi yapılır.
119
     * N11 tarafında değişen stok miktarlarını ezmemek için, “version” bilgisi verilmesi durumunda ilgili ürün stok bilgisinin N11 de versiyonu ile karşılaştırma yapılır, stok versiyon numaraları uyumsuz ise işlem gerçekleştirilmez.
120
     */
121 View Code Duplication
    public function updateStockByStockSellerCode(string $stockSellerCode, int $quantity, int $version = 0) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
122
        $this->_parameters["stockItems"] = [
123
            "stockItem" => [
124
                "sellerStockCode" => $stockSellerCode,
125
                "quantity" => $quantity,
126
                "version" => $version,
127
            ]
128
        ];
129
        return $this->_client->UpdateStockByStockSellerCode($this->_parameters);
130
    }
131
132
    /**
133
     * @param string $attrName
134
     * @param string $attrValue
135
     * @param int $quantityToIncrease
136
     * @param int $version
137
     * @return mixed
138
     * @description Bir ürünün stok seçenek bilgilerini kullanarak stok miktarını arttırmak için kullanılır.
139
     * N11 tarafında değişen stok miktarlarını ezmemek için, “version” bilgisi verilmesi durumunda ilgili ürün stok bilgisinin N11 de versiyonu ile karşılaştırma yapılır, stok versiyon numaraları uyumsuz ise işlem gerçekleştirilmez.
140
     */
141 View Code Duplication
    public function increaseStockByStockAttributes(string $attrName, string $attrValue, int $quantityToIncrease, int $version = 0) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
142
        $this->_parameters["product"] = [
143
            "stockItems" => [
144
                "stockItem" => [
145
                    "attributes" => [
146
                        "attribute" => [
147
                            "name" => $attrName,
148
                            "value" => $attrValue,
149
                        ]
150
                    ],
151
                    "quantityToIncrease" => $quantityToIncrease,
152
                    "version" => $version
153
                ]
154
            ]
155
        ];
156
        return $this->_client->IncreaseStockByStockAttributes($this->_parameters);
157
    }
158
159
    /**
160
     * @param int $stockItemId
161
     * @param int $quantityToIncrease
162
     * @return mixed
163
     * @description Bir ürünün n11 ürün stok ID bilgisini kullanarak stok miktarını arttırmak için kullanılır.
164
     * Bir ürüne ait n11 ürün stok ID sine, ProductStockService içindeki GetProductStockByProductId veya GetProductStockBySellerCode metotları ile ulaşılabilir.
165
     * N11 tarafında değişen stok miktarlarını ezmemek için, “version” bilgisi verilmesi durumunda ilgili ürün stok bilgisinin N11 de versiyonu ile karşılaştırma yapılır, stok versiyon numaraları uyumsuz ise işlem gerçekleştirilmez.
166
     */
167 View Code Duplication
    public function increaseStockByStockId(int $stockItemId, int $quantityToIncrease) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
168
        $this->_parameters["stockItems"] = [
169
            "stockItem" => [
170
                "id" => $stockItemId,
171
                "quantityToIncrease" => $quantityToIncrease
172
            ]
173
        ];
174
        return $this->_client->IncreaseStockByStockId($this->_parameters);
175
    }
176
177
    /**
178
     * @param string $sellerStockCode
179
     * @param int $quantityToIncrease
180
     * @return mixed
181
     * @description Bir ürünün mağaza stok kodu kullanarak stok miktarını arttırmak için kullanılır.
182
     * N11 tarafında değişen stok miktarlarını ezmemek için, “version” bilgisi verilmesi durumunda ilgili ürün stok bilgisinin N11 de versiyonu ile karşılaştırma yapılır, stok versiyon numaraları uyumsuz ise işlem gerçekleştirilmez.
183
     */
184 View Code Duplication
    public function increaseStockByStockSellerCode(string $sellerStockCode, int $quantityToIncrease) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
185
        $this->_parameters["stockItems"] = [
186
            "stockItem" => [
187
                "sellerStockCode" => $sellerStockCode,
188
                "quantityToIncrease" => $quantityToIncrease
189
            ]
190
        ];
191
        return $this->_client->IncreaseStockByStockSellerCode($this->_parameters);
192
    }
193
194
}
195