Skip to content

Commit

Permalink
[TASK] Add source parameter for getLatest()
Browse files Browse the repository at this point in the history
This also adds an overview of all methods and their parameters to the readme.
  • Loading branch information
o-ba committed Mar 25, 2020
1 parent 1779d29 commit c130583
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ Create a instance of the API wrapper first:
$covidApi = new \Bo\CovidPHP\CovidApi();
```

__Available methods__
| __Methods__ | __Parameters__ | __Description__ |
| ----------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| ``getSources()`` | | Get all available sources. |
| ``getLatest()`` | ``string $source`` | Get the latest data summarized. |
| ``getAllLocations()`` | ``bool $includeTimelines`` (optional)<br>``string $source`` (optional) | Get all available locations. |
| ``findByCountryCode()`` | ``string $countryCode``<br>``bool $includeTimelines`` (optional)<br>``string $source`` (optional) | Get country specific data based on the country code. |
| ``findByLocation()`` | ``int $locationId``<br>``bool $includeTimelines`` (optional)<br>``string $source`` (optional) | Get location specific data based on the location id. |

**Further information**
- Setting ``$includeTimelines`` adds timeline data to the response
- Setting ``$source`` let's you specify which source the data should be fetched from (default: ``jhu``)

### Examples

Get all available sources:
Expand Down Expand Up @@ -63,9 +76,6 @@ $covidApi->findByLocation(11);
```

## Note
- Setting ``$includeTimelines`` adds timeline data to the response
- Setting ``$source`` let's you specify which source the data should be fetched from (default: ``jhu``)
- The mentioned parameters are available for all methods except ``CovidApi::getSources()`` and ``CovidApi::getLatest()``
- All responses will be decoded and returned as ``array``

## License
Expand Down
4 changes: 2 additions & 2 deletions src/CovidApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function getSources(): array
return $this->sources;
}

public function getLatest(): array
public function getLatest(string $source = ''): array
{
return $this->request('latest');
return $this->request('latest', $this->getQueryParameters(false, $source));
}

public function getAllLocations(bool $includeTimelines = false, string $source = ''): array
Expand Down

0 comments on commit c130583

Please sign in to comment.