2017 © Pedro Peláez
 

library api-client

The API client of the Factorio Item Browser.

image

factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  • Sunday, July 22, 2018
  • by BluePsyduck
  • Repository
  • 1 Watchers
  • 0 Stars
  • 114 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 87 % Grown

The README.md

Factorio Item Browser, (*1)

API Client Library

GitHub release (latest SemVer) GitHub build Codecov, (*2)

This library implements a PHP client to the data API of the Factorio Item Browser to access its data., (*3)

The documentation of the API can be found at https://docs.factorio-item-browser.com/api, (*4)

Usage

The client is set up to be used within a Laminas project. Using it in another context requires an additional setup which is not covered in this README., (*5)

To use the client, add the FactorioItemBrowser\Api\Client\ConfigProvider to the config aggregator of your project., (*6)

Configuration

The client requires the following configuration to be present in your project:, (*7)

<?php

use FactorioItemBrowser\Api\Client\Constant\ConfigKey;

return [
    ConfigKey::MAIN => [
        // The URL to the API server, including a trailing slash.
        ConfigKey::BASE_URI => 'https://api.factorio-item-browser.com/',
        // The Api-Key to access the API.
        ConfigKey::API_KEY => 'foo',
        // The timeout in seconds to use for the requests.
        ConfigKey::TIMEOUT => 10,
    ],
];

Example

The usage of the actual client is best described with an example., (*8)

<?php 

use FactorioItemBrowser\Api\Client\ClientInterface;
use FactorioItemBrowser\Api\Client\Request\Item\ItemRandomRequest;
use FactorioItemBrowser\Api\Client\Request\Mod\ModListRequest;
use FactorioItemBrowser\Api\Client\Response\Item\ItemRandomResponse;
use FactorioItemBrowser\Api\Client\Response\Mod\ModListResponse;
/* @var \Psr\Container\ContainerInterface $container */

// Fetch the API client from the container. This will use the config to initialize it.
/* @var ClientInterface $client */
$client = $container->get(ClientInterface::class);

// Create an instance of the request class you want to call, and set its parameters.
$randomItemRequest = new ItemRandomRequest();
$randomItemRequest->combinationId = '2f4a45fa-a509-a9d1-aae6-ffcf984a7a76';
$randomItemRequest->locale = 'de';
$randomItemRequest->numberOfResults = 10;
$randomItemRequest->numberOfRecipesPerResult = 3;

// Send the request to the API server.
// This call is non-blocking, returning a Promise. For further details about promises, read the documentation of
// the Guzzle HTTP client.
$randomItemPromise = $client->sendRequest($randomItemRequest); // Non-blocking

// Lets send a second request.
$modListRequest = new ModListRequest();
$modListRequest->combinationId = '2f4a45fa-a509-a9d1-aae6-ffcf984a7a76';
$modListRequest->locale = 'de';
$modListPromise = $client->sendRequest($modListRequest); // Non-blocking

// To actually process the response, you have to wait on the promises to be fulfilled.
/* @var  ItemRandomResponse $randomItemsResponse */
$randomItemsResponse = $randomItemPromise->wait(); // Blocking 
/* @var ModListResponse $modListResponse */
$modListResponse = $modListPromise->wait(); // Blocking

// Do something with the received data.
var_dump($randomItemsResponse->items);
var_dump($modListResponse->mods);

The Versions

22/07 2018

dev-master

9999999-dev https://github.com/factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Avatar BluePsyduck

api client bluepsyduck factorio item browser fib

22/07 2018

dev-feature/phpstan

dev-feature/phpstan https://github.com/factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Avatar BluePsyduck

api client bluepsyduck factorio item browser fib

21/07 2018

1.1.0

1.1.0.0 https://github.com/factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Avatar BluePsyduck

api client bluepsyduck factorio item browser fib

29/05 2018

dev-feature/machines

dev-feature/machines https://github.com/factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Avatar BluePsyduck

api client bluepsyduck factorio item browser fib

17/05 2018

dev-develop

dev-develop https://github.com/factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Avatar BluePsyduck

api client bluepsyduck factorio item browser fib

14/04 2018

1.0.1

1.0.1.0 https://github.com/factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Avatar BluePsyduck

api client bluepsyduck factorio item browser fib

05/04 2018

1.0.0

1.0.0.0 https://github.com/factorio-item-browser/api-client

The API client of the Factorio Item Browser.

  Sources   Download

GPL-3.0-or-later

The Requires

 

The Development Requires

by Avatar BluePsyduck

api client bluepsyduck factorio item browser fib