Skip to content

Commit e90b5ed

Browse files
authored
Merge pull request #75 from Teakowa/master
Add Item test and documentation
2 parents c7652d5 + 89863c3 commit e90b5ed

5 files changed

Lines changed: 356 additions & 1 deletion

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Each service from the Steam API has its own methods you can use.
5353
- [User Stats](#user-stats)
5454
- [App](#app)
5555
- [Package](#package)
56+
- [Item](#item)
5657
- [Group](#group)
5758

5859
### Global
@@ -347,6 +348,27 @@ l | string | The l is the language parameter, you can get the appropriate langua
347348

348349
> Example Output: [packageDetails](./examples/package/packageDetails.txt)
349350
351+
### Item
352+
This method will get user inventory for item.
353+
354+
```php
355+
Steam::item()
356+
```
357+
358+
#### GetPlayerItems
359+
This gets all the item for a user inventory.
360+
361+
##### Arguments
362+
363+
Name | Type | Description | Required | Default
364+
-----|------|-------------|----------|---------
365+
appId| int | The appid of the game you want for | Yes |
366+
steamid | int | The steamid of the Steam user you want for | Yes |
367+
368+
⚠️ **Now known to supports**:`440`, `570`, `620`, `730`, `205790`, `221540`, `238460`
369+
370+
> Example Output: [GetPlayerItems](./examples/item/GetPlayerItems.txt)
371+
350372
### Group
351373
This service is used to get details on a Steam group.
352374

examples/item/GetPlayerItems.txt

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
Array
2+
(
3+
[numberOfBackpackSlots] => 50
4+
[items] => NukaCode\Database\Collection Object
5+
(
6+
[items:protected] => Array
7+
(
8+
[0] => Syntax\SteamApi\Containers\Item Object
9+
(
10+
[id] => 5787837042
11+
[originalId] => 5787837042
12+
[defIndex] => 166
13+
[level] => 5
14+
[quality] => 6
15+
[quantity] => 1
16+
[inventory] => 0
17+
[origin] => 0
18+
[flags] => Array
19+
(
20+
[trade] =>
21+
[craft] => 1
22+
)
23+
24+
[containedItem] =>
25+
[style] =>
26+
[attributes] => Array
27+
(
28+
[0] => stdClass Object
29+
(
30+
[defindex] => 143
31+
[value] => 1406566784
32+
[float_value] => 1842591301632
33+
)
34+
35+
[1] => stdClass Object
36+
(
37+
[defindex] => 746
38+
[value] => 1065353216
39+
[float_value] => 1
40+
)
41+
42+
[2] => stdClass Object
43+
(
44+
[defindex] => 292
45+
[value] => 1115684864
46+
[float_value] => 64
47+
)
48+
49+
[3] => stdClass Object
50+
(
51+
[defindex] => 388
52+
[value] => 1115684864
53+
[float_value] => 64
54+
)
55+
56+
[4] => stdClass Object
57+
(
58+
[defindex] => 153
59+
[value] => 1065353216
60+
[float_value] => 1
61+
)
62+
63+
)
64+
65+
[custom] => Array
66+
(
67+
[name] =>
68+
[description] =>
69+
)
70+
71+
)
72+
73+
[1] => Syntax\SteamApi\Containers\Item Object
74+
(
75+
[id] => 5787837069
76+
[originalId] => 5787837069
77+
[defIndex] => 877
78+
[level] => 1
79+
[quality] => 1
80+
[quantity] => 1
81+
[inventory] => 3221225480
82+
[origin] => 13
83+
[flags] => Array
84+
(
85+
[trade] => 1
86+
[craft] => 1
87+
)
88+
89+
[containedItem] =>
90+
[style] =>
91+
[attributes] => Array
92+
(
93+
[0] => stdClass Object
94+
(
95+
[defindex] => 746
96+
[value] => 1065353216
97+
[float_value] => 1
98+
)
99+
100+
[1] => stdClass Object
101+
(
102+
[defindex] => 292
103+
[value] => 1115684864
104+
[float_value] => 64
105+
)
106+
107+
[2] => stdClass Object
108+
(
109+
[defindex] => 388
110+
[value] => 1115684864
111+
[float_value] => 64
112+
)
113+
114+
)
115+
116+
[custom] => Array
117+
(
118+
[name] =>
119+
[description] =>
120+
)
121+
122+
)
123+
124+
[2] => Syntax\SteamApi\Containers\Item Object
125+
(
126+
[id] => 5787837070
127+
[originalId] => 5787837070
128+
[defIndex] => 878
129+
[level] => 1
130+
[quality] => 1
131+
[quantity] => 1
132+
[inventory] => 3221225480
133+
[origin] => 13
134+
[flags] => Array
135+
(
136+
[trade] => 1
137+
[craft] => 1
138+
)
139+
140+
[containedItem] =>
141+
[style] => 0
142+
[attributes] => Array
143+
(
144+
[0] => stdClass Object
145+
(
146+
[defindex] => 746
147+
[value] => 1065353216
148+
[float_value] => 1
149+
)
150+
151+
[1] => stdClass Object
152+
(
153+
[defindex] => 292
154+
[value] => 1115684864
155+
[float_value] => 64
156+
)
157+
158+
[2] => stdClass Object
159+
(
160+
[defindex] => 388
161+
[value] => 1115684864
162+
[float_value] => 64
163+
)
164+
165+
)
166+
167+
[custom] => Array
168+
(
169+
[name] =>
170+
[description] =>
171+
)
172+
173+
)
174+
175+
[3] => Syntax\SteamApi\Containers\Item Object
176+
(
177+
[id] => 5787837071
178+
[originalId] => 5787837071
179+
[defIndex] => 879
180+
[level] => 1
181+
[quality] => 1
182+
[quantity] => 1
183+
[inventory] => 3221225480
184+
[origin] => 13
185+
[flags] => Array
186+
(
187+
[trade] => 1
188+
[craft] => 1
189+
)
190+
191+
[containedItem] =>
192+
[style] => 0
193+
[attributes] => Array
194+
(
195+
[0] => stdClass Object
196+
(
197+
[defindex] => 746
198+
[value] => 1065353216
199+
[float_value] => 1
200+
)
201+
202+
[1] => stdClass Object
203+
(
204+
[defindex] => 292
205+
[value] => 1115684864
206+
[float_value] => 64
207+
)
208+
209+
[2] => stdClass Object
210+
(
211+
[defindex] => 388
212+
[value] => 1115684864
213+
[float_value] => 64
214+
)
215+
216+
)
217+
218+
[custom] => Array
219+
(
220+
[name] =>
221+
[description] =>
222+
)
223+
224+
)
225+
226+
[4] => Syntax\SteamApi\Containers\Item Object
227+
(
228+
[id] => 5787837154
229+
[originalId] => 5787837154
230+
[defIndex] => 5867
231+
[level] => 1
232+
[quality] => 6
233+
[quantity] => 1
234+
[inventory] => 3221225473
235+
[origin] => 0
236+
[flags] => Array
237+
(
238+
[trade] => 1
239+
[craft] => 1
240+
)
241+
242+
[containedItem] =>
243+
[style] => 0
244+
[attributes] => Array
245+
(
246+
[0] => stdClass Object
247+
(
248+
[defindex] => 2046
249+
[value] => 1065353216
250+
[float_value] => 1
251+
)
252+
253+
[1] => stdClass Object
254+
(
255+
[defindex] => 187
256+
[value] => 1121189888
257+
[float_value] => 106
258+
)
259+
260+
[2] => stdClass Object
261+
(
262+
[defindex] => 744
263+
[value] => 1
264+
[float_value] => 1.4012984643248E-45
265+
)
266+
267+
[3] => stdClass Object
268+
(
269+
[defindex] => 528
270+
[value] => 1169641472
271+
[float_value] => 5866
272+
)
273+
274+
[4] => stdClass Object
275+
(
276+
[defindex] => 731
277+
[value] => 1065353216
278+
[float_value] => 1
279+
)
280+
281+
[5] => stdClass Object
282+
(
283+
[defindex] => 815
284+
[value] => 1
285+
[float_value] => 1.4012984643248E-45
286+
)
287+
288+
)
289+
290+
[custom] => Array
291+
(
292+
[name] =>
293+
[description] =>
294+
)
295+
296+
)
297+
298+
)
299+
300+
)
301+
302+
)
303+

src/Syntax/SteamApi/Steam/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function GetPlayerItems($appId, $steamId)
4040
$items = $this->convertToObjects($client->result->items);
4141

4242
// Return a full inventory
43-
return new Inventory($client->result->num_backpack_slots, $items);
43+
return (array) new Inventory($client->result->num_backpack_slots, $items);
4444
}
4545

4646
protected function convertToObjects($items)

tests/BaseTester.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class BaseTester extends TestCase {
1717

1818
protected $packageId = 32848;
1919

20+
protected $itemid = 440;
21+
2022
protected $groupId = 103582791429521412;
2123

2224
protected $groupName = 'Valve';
@@ -160,6 +162,15 @@ private function checkNestedPackageProperties($package)
160162
$this->assertObjectHasAttributes($attributes, $package->platforms);
161163
}
162164

165+
/**
166+
* @param $item
167+
*/
168+
private function checkItemProperties($item)
169+
{
170+
$attributes = ['id', 'originalId', 'level', 'quality', 'quantity'];
171+
$this->assertObjectHasAttributes($attributes, $item->item);
172+
}
173+
163174
/**
164175
* @param $group
165176
*/

tests/ItemTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
require_once 'BaseTester.php';
4+
5+
/** @group Item */
6+
class ItemTest extends BaseTester
7+
{
8+
/** @test */
9+
public function it_gets_items_for_an_by_user_id()
10+
{
11+
$items = $this->steamClient->item()->GetPlayerItems($this->itemid, $this->id64);
12+
13+
$this->assertCount(1, $items);
14+
15+
$item = $items->first();
16+
17+
$this->checkItemProperties($item);
18+
}
19+
}

0 commit comments

Comments
 (0)