Skip to content

Commit 0419636

Browse files
authored
Merge pull request #10 from factorio-item-browser/feature/list-endpoints
feature/list-endpoints
2 parents cbc0f5d + 68b3b9d commit 0419636

23 files changed

+1117
-0
lines changed

CHANGELOG.md

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

3+
## 3.1.0 - 2020-05-02
4+
5+
### Added
6+
7+
- New `/item/list` and `recipe/list` requests.
8+
39
## 3.0.0 - 2020-04-15
410

511
### Added

config/api-client.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
Endpoint\Generic\GenericDetailsEndpoint::class,
2424
Endpoint\Generic\GenericIconEndpoint::class,
2525
Endpoint\Item\ItemIngredientEndpoint::class,
26+
Endpoint\Item\ItemListEndpoint::class,
2627
Endpoint\Item\ItemProductEndpoint::class,
2728
Endpoint\Item\ItemRandomEndpoint::class,
2829
Endpoint\Mod\ModListEndpoint::class,
2930
Endpoint\Recipe\RecipeDetailsEndpoint::class,
31+
Endpoint\Recipe\RecipeListEndpoint::class,
3032
Endpoint\Recipe\RecipeMachinesEndpoint::class,
3133
Endpoint\Search\SearchQueryEndpoint::class,
3234
],

config/dependencies.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
Endpoint\Generic\GenericDetailsEndpoint::class => InvokableFactory::class,
2828
Endpoint\Generic\GenericIconEndpoint::class => InvokableFactory::class,
2929
Endpoint\Item\ItemIngredientEndpoint::class => InvokableFactory::class,
30+
Endpoint\Item\ItemListEndpoint::class => InvokableFactory::class,
3031
Endpoint\Item\ItemProductEndpoint::class => InvokableFactory::class,
3132
Endpoint\Item\ItemRandomEndpoint::class => InvokableFactory::class,
3233
Endpoint\Mod\ModListEndpoint::class => InvokableFactory::class,
3334
Endpoint\Recipe\RecipeDetailsEndpoint::class => InvokableFactory::class,
35+
Endpoint\Recipe\RecipeListEndpoint::class => InvokableFactory::class,
3436
Endpoint\Recipe\RecipeMachinesEndpoint::class => InvokableFactory::class,
3537
Endpoint\Search\SearchQueryEndpoint::class => InvokableFactory::class,
3638

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FactorioItemBrowser\Api\Client\Request\Item\ItemListRequest:
2+
access_type: public_method
3+
exclusion_policy: all
4+
properties:
5+
numberOfResults:
6+
type: integer
7+
indexOfFirstResult:
8+
type: integer
9+
numberOfRecipesPerResult:
10+
type: integer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FactorioItemBrowser\Api\Client\Request\Recipe\RecipeListRequest:
2+
access_type: public_method
3+
exclusion_policy: all
4+
properties:
5+
numberOfResults:
6+
type: integer
7+
indexOfFirstResult:
8+
type: integer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FactorioItemBrowser\Api\Client\Response\Item\ItemListResponse:
2+
access_type: public_method
3+
exclusion_policy: all
4+
properties:
5+
items:
6+
type: array<FactorioItemBrowser\Api\Client\Entity\GenericEntityWithRecipes>
7+
totalNumberOfResults:
8+
type: integer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FactorioItemBrowser\Api\Client\Response\Recipe\RecipeListResponse:
2+
access_type: public_method
3+
exclusion_policy: all
4+
properties:
5+
recipes:
6+
type: array<FactorioItemBrowser\Api\Client\Entity\RecipeWithExpensiveVersion>
7+
totalNumberOfResults:
8+
type: integer
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace FactorioItemBrowser\Api\Client\Endpoint\Item;
6+
7+
use FactorioItemBrowser\Api\Client\Endpoint\EndpointInterface;
8+
use FactorioItemBrowser\Api\Client\Request\Item\ItemListRequest;
9+
use FactorioItemBrowser\Api\Client\Response\Item\ItemListResponse;
10+
11+
/**
12+
* The endpoint of the item list request.
13+
*
14+
* @author BluePsyduck <bluepsyduck@gmx.com>
15+
* @license http://opensource.org/licenses/GPL-3.0 GPL v3
16+
*/
17+
class ItemListEndpoint implements EndpointInterface
18+
{
19+
/**
20+
* Returns the request class supported by the endpoint.
21+
* @return string
22+
*/
23+
public function getSupportedRequestClass(): string
24+
{
25+
return ItemListRequest::class;
26+
}
27+
28+
/**
29+
* Returns whether or not this endpoint requires an authorization token.
30+
* @return bool
31+
*/
32+
public function requiresAuthorizationToken(): bool
33+
{
34+
return true;
35+
}
36+
37+
/**
38+
* Returns the request path of the endpoint.
39+
* @return string
40+
*/
41+
public function getRequestPath(): string
42+
{
43+
return 'item/list';
44+
}
45+
46+
/**
47+
* Creates the response of the endpoint.
48+
* @return string
49+
*/
50+
public function getResponseClass(): string
51+
{
52+
return ItemListResponse::class;
53+
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace FactorioItemBrowser\Api\Client\Endpoint\Recipe;
6+
7+
use FactorioItemBrowser\Api\Client\Endpoint\EndpointInterface;
8+
use FactorioItemBrowser\Api\Client\Request\Recipe\RecipeListRequest;
9+
use FactorioItemBrowser\Api\Client\Response\Recipe\RecipeListResponse;
10+
11+
/**
12+
* The endpoint of the recipe list request.
13+
*
14+
* @author BluePsyduck <bluepsyduck@gmx.com>
15+
* @license http://opensource.org/licenses/GPL-3.0 GPL v3
16+
*/
17+
class RecipeListEndpoint implements EndpointInterface
18+
{
19+
/**
20+
* Returns the request class supported by the endpoint.
21+
* @return string
22+
*/
23+
public function getSupportedRequestClass(): string
24+
{
25+
return RecipeListRequest::class;
26+
}
27+
28+
/**
29+
* Returns whether or not this endpoint requires an authorization token.
30+
* @return bool
31+
*/
32+
public function requiresAuthorizationToken(): bool
33+
{
34+
return true;
35+
}
36+
37+
/**
38+
* Returns the request path of the endpoint.
39+
* @return string
40+
*/
41+
public function getRequestPath(): string
42+
{
43+
return 'recipe/list';
44+
}
45+
46+
/**
47+
* Creates the response of the endpoint.
48+
* @return string
49+
*/
50+
public function getResponseClass(): string
51+
{
52+
return RecipeListResponse::class;
53+
}
54+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace FactorioItemBrowser\Api\Client\Request\Item;
6+
7+
use FactorioItemBrowser\Api\Client\Request\RequestInterface;
8+
9+
/**
10+
* The request of the item list.
11+
*
12+
* @author BluePsyduck <bluepsyduck@gmx.com>
13+
* @license http://opensource.org/licenses/GPL-3.0 GPL v3
14+
*/
15+
class ItemListRequest implements RequestInterface
16+
{
17+
/**
18+
* The number of results to return.
19+
* @var int
20+
*/
21+
protected $numberOfResults = 10;
22+
23+
/**
24+
* The 0-based index of the first result to return.
25+
* @var int
26+
*/
27+
protected $indexOfFirstResult = 0;
28+
29+
/**
30+
* The number of recipes to return for each result.
31+
* @var int
32+
*/
33+
protected $numberOfRecipesPerResult = 3;
34+
35+
/**
36+
* Sets the number of results to return.
37+
* @param int $numberOfResults
38+
* @return $this
39+
*/
40+
public function setNumberOfResults(int $numberOfResults): self
41+
{
42+
$this->numberOfResults = $numberOfResults;
43+
return $this;
44+
}
45+
46+
/**
47+
* Returns the number of results to return.
48+
* @return int
49+
*/
50+
public function getNumberOfResults(): int
51+
{
52+
return $this->numberOfResults;
53+
}
54+
55+
/**
56+
* Sets the 0-based index of the first result to return.
57+
* @param int $indexOfFirstResult
58+
* @return $this
59+
*/
60+
public function setIndexOfFirstResult(int $indexOfFirstResult): self
61+
{
62+
$this->indexOfFirstResult = $indexOfFirstResult;
63+
return $this;
64+
}
65+
66+
/**
67+
* Returns the 0-based index of the first result to return.
68+
* @return int
69+
*/
70+
public function getIndexOfFirstResult(): int
71+
{
72+
return $this->indexOfFirstResult;
73+
}
74+
75+
/**
76+
* Sets the number of recipes to return for each result.
77+
* @param int $numberOfRecipesPerResult
78+
* @return $this
79+
*/
80+
public function setNumberOfRecipesPerResult(int $numberOfRecipesPerResult): self
81+
{
82+
$this->numberOfRecipesPerResult = $numberOfRecipesPerResult;
83+
return $this;
84+
}
85+
86+
/**
87+
* Returns the the number of recipes to return for each result.
88+
* @return int
89+
*/
90+
public function getNumberOfRecipesPerResult(): int
91+
{
92+
return $this->numberOfRecipesPerResult;
93+
}
94+
}

0 commit comments

Comments
 (0)