Skip to content

Commit c182e38

Browse files
committed
Add v1.15.0
1 parent d0ef11b commit c182e38

File tree

22 files changed

+767
-95
lines changed

22 files changed

+767
-95
lines changed

‎CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## v1.15.0 - 2022-04-28
4+
### Features
5+
- Add compatibility with PHP 8
6+
- Add API CU01
7+
- Add excluded_from_shipment to OR28
8+
- Add issuing user to IV01
9+
- Add amout transferred to operator to IV01
10+
- Add Uruguayan bank account
11+
- Add Colombian bank account
12+
- Add customer_directly_pays_seller field to OR01, OR11 and Q07
13+
- Add shipping deadline to S04, PR02, OF22, OF21, SH01 and SH02
14+
- Add last sender details in M11 API
15+
- Add tax_calculation_rule, included_in_commission and operator_withheld field to OR75
16+
- Add shipped date to Mirakl shipment
17+
- Add last_updated_from and last_updated_to to ST11
18+
- Add tax rate to TL02
19+
- Deprecate LeadtimeToShip in OR01, OR11 and Q07
20+
321
## v1.14.0 - 2021-12-23
422
### Features
523
- Add product feeds APIs (PF01, PF02, PF03 and PF11)

‎composer.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "mirakl/sdk-php-shop",
33
"description": "Mirakl provides a PHP SDK that wraps the Mirakl REST APIs in a lightweight library. This enables you to develop a fast, flexible and custom integration for your existing e-commerce solution.",
44
"type": "library",
5-
"version": "1.14.0",
5+
"version": "1.15.0",
66
"license": "proprietary",
77
"authors": [
88
{
@@ -12,10 +12,17 @@
1212
],
1313
"autoload": {
1414
"psr-4": {
15-
"Mirakl\\": "src/Mirakl/",
16-
"Mirakl\\Tests\\": "tests/Mirakl/"
15+
"Mirakl\\": "src/Mirakl/"
1716
},
18-
"files": ["src/Mirakl/functions.php"]
17+
"files": [
18+
"src/Mirakl/functions.php",
19+
"src/Mirakl/autoload.php"
20+
]
21+
},
22+
"autoload-dev": {
23+
"psr-4": {
24+
"Mirakl\\Tests\\": "tests/Mirakl/"
25+
}
1926
},
2027
"require": {
2128
"php": ">=7.2.0",
@@ -24,8 +31,7 @@
2431
"guzzlehttp/psr7": "~1.7 || ~2.0"
2532
},
2633
"require-dev": {
27-
"phpunit/phpunit": "~5.0",
28-
"php-parallel-lint/php-parallel-lint": "*",
29-
"php-parallel-lint/php-console-highlighter": "*"
34+
"phpunit/phpunit": "~9.0",
35+
"php-parallel-lint/php-parallel-lint": "^1.3"
3036
}
3137
}
Lines changed: 327 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
<?php
2+
namespace Mirakl\Core\Domain\Collection;
3+
4+
use Mirakl\Core\Domain\ArrayableInterface;
5+
6+
class MiraklCollection implements ArrayableInterface, \ArrayAccess, \IteratorAggregate, \Countable
7+
{
8+
/**
9+
* Collection items
10+
*
11+
* @var array
12+
*/
13+
protected $items = [];
14+
15+
/**
16+
* @var string|null
17+
*/
18+
protected $itemClass;
19+
20+
/**
21+
* @var int
22+
*/
23+
protected $totalCount;
24+
25+
/**
26+
* @param array $items
27+
* @param int|null $totalCount
28+
*/
29+
public function __construct(array $items = [], $totalCount = null)
30+
{
31+
$this->setItems($items);
32+
if (null !== $totalCount) {
33+
$this->setTotalCount($totalCount);
34+
}
35+
}
36+
37+
/**
38+
* @param mixed $item
39+
* @return $this
40+
*/
41+
public function add($item)
42+
{
43+
$this->items[] = !is_object($item) ? $this->newItem($item) : $item;
44+
45+
return $this;
46+
}
47+
48+
/**
49+
* @return int
50+
*/
51+
public function count()
52+
{
53+
return count($this->items);
54+
}
55+
56+
/**
57+
* @param array $items
58+
* @param int|null $totalCount
59+
* @return $this
60+
*/
61+
public static function create(array $items = [], $totalCount = null)
62+
{
63+
return new static($items, $totalCount);
64+
}
65+
66+
/**
67+
* @return mixed
68+
*/
69+
public function current()
70+
{
71+
return current($this->items);
72+
}
73+
74+
/**
75+
* Useful method for requests returning collections
76+
*
77+
* @param string|null $key
78+
* @return \Mirakl\Core\Response\Decorator\MiraklCollection
79+
*/
80+
public static function decorator($key = null)
81+
{
82+
return new \Mirakl\Core\Response\Decorator\MiraklCollection(static::class, $key);
83+
}
84+
85+
/**
86+
* @param mixed $offset
87+
* @return bool
88+
*/
89+
public function exists($offset)
90+
{
91+
return $this->offsetExists($offset);
92+
}
93+
94+
/**
95+
* @return mixed
96+
*/
97+
public function first()
98+
{
99+
return reset($this->items);
100+
}
101+
102+
/**
103+
* @param $offset
104+
* @return mixed
105+
*/
106+
public function get($offset)
107+
{
108+
return $this->offsetGet($offset);
109+
}
110+
111+
/**
112+
* @inheritdoc
113+
*/
114+
public function getEmptyValue()
115+
{
116+
return [];
117+
}
118+
119+
/**
120+
* @return array
121+
*/
122+
public function getItems()
123+
{
124+
return $this->items;
125+
}
126+
127+
/**
128+
* @return int
129+
*/
130+
public function getTotalCount()
131+
{
132+
return $this->totalCount;
133+
}
134+
135+
/**
136+
* @return \ArrayIterator
137+
*/
138+
public function getIterator()
139+
{
140+
return new \ArrayIterator($this->items);
141+
}
142+
143+
/**
144+
* @inheritdoc
145+
*/
146+
public function isEmpty()
147+
{
148+
return empty($this->items);
149+
}
150+
151+
/**
152+
* @return mixed
153+
*/
154+
public function last()
155+
{
156+
return end($this->items);
157+
}
158+
159+
/**
160+
* @return mixed
161+
*/
162+
public function next()
163+
{
164+
return next($this->items);
165+
}
166+
167+
/**
168+
* @param array $item
169+
* @return array|object
170+
*/
171+
public function newItem(array $item)
172+
{
173+
return strlen($this->itemClass) ? new $this->itemClass($item) : $item;
174+
}
175+
176+
/**
177+
* @param mixed $offset
178+
* @return bool
179+
*/
180+
public function offsetExists($offset)
181+
{
182+
return isset($this->items[$offset]);
183+
}
184+
185+
/**
186+
* @param mixed $offset
187+
* @return mixed
188+
*/
189+
public function offsetGet($offset)
190+
{
191+
return isset($this->items[$offset]) ? $this->items[$offset] : null;
192+
}
193+
194+
/**
195+
* @param mixed $key
196+
* @param mixed $value
197+
* @return $this
198+
*/
199+
public function offsetSet($key, $value)
200+
{
201+
$this->items[$key] = $value;
202+
203+
return $this;
204+
}
205+
206+
/**
207+
* @param mixed $offset
208+
* @return $this
209+
*/
210+
public function offsetUnset($offset)
211+
{
212+
if (isset($this->items[$offset])) {
213+
unset($this->items[$offset]);
214+
}
215+
216+
return $this;
217+
}
218+
219+
/**
220+
* @return mixed
221+
*/
222+
public function prev()
223+
{
224+
return prev($this->items);
225+
}
226+
227+
/**
228+
* @param mixed $offset
229+
* @return $this
230+
*/
231+
public function remove($offset)
232+
{
233+
return $this->offsetUnset($offset);
234+
}
235+
236+
/**
237+
* @return $this
238+
*/
239+
public function reset()
240+
{
241+
$this->items = [];
242+
243+
return $this;
244+
}
245+
246+
/**
247+
* @param mixed $key
248+
* @param mixed $value
249+
* @return $this
250+
*/
251+
public function set($key, $value)
252+
{
253+
return $this->offsetSet($key, $value);
254+
}
255+
256+
/**
257+
* @param string $class
258+
* @return $this
259+
*/
260+
public function setItemClass($class)
261+
{
262+
$this->itemClass = $class;
263+
264+
return $this;
265+
}
266+
267+
/**
268+
* @param array $items
269+
* @return $this
270+
*/
271+
public function setItems(array $items)
272+
{
273+
if ($this->itemClass) {
274+
array_walk($items, function(&$item) {
275+
if (is_array($item)) {
276+
$item = $this->newItem($item);
277+
}
278+
});
279+
}
280+
281+
$this->items = $items;
282+
283+
return $this;
284+
}
285+
286+
/**
287+
* @param int $totalCount
288+
* @return $this
289+
*/
290+
public function setTotalCount($totalCount)
291+
{
292+
$this->totalCount = $totalCount;
293+
294+
return $this;
295+
}
296+
297+
/**
298+
* @return array
299+
*/
300+
public function toArray()
301+
{
302+
$result = [];
303+
foreach ($this as $item) {
304+
if (is_object($item) && $item instanceof ArrayableInterface) {
305+
$item = $item->toArray();
306+
}
307+
$result[] = $item;
308+
}
309+
310+
return $result;
311+
}
312+
313+
/**
314+
* @param string $method
315+
* @param array $args
316+
* @return array
317+
*/
318+
public function walk($method, array $args = [])
319+
{
320+
$result = [];
321+
foreach ($this as $item) {
322+
$result[] = call_user_func_array([$item, $method], $args);
323+
}
324+
325+
return $result;
326+
}
327+
}

0 commit comments

Comments
 (0)