Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
slvler committed Dec 3, 2024
1 parent b90352d commit 5844b4d
Show file tree
Hide file tree
Showing 27 changed files with 362 additions and 271 deletions.
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
# Live Score Service

[![tests](https://github.com/slvler/livescore-service/actions/workflows/Tests.yml/badge.svg)](https://github.com/slvler/livescore-service/actions/workflows/Tests.yml)
[![Latest Stable Version](https://poser.pugx.org/slvler/livescore-service/v)](https://packagist.org/packages/slvler/livescore-service)
[![Latest Unstable Version](https://poser.pugx.org/slvler/livescore-service/v/unstable)](https://packagist.org/packages/slvler/livescore-service)
[![Latest Stable Version](https://img.shields.io/packagist/v/slvler/livescore-service.svg)](https://packagist.org/packages/slvler/livescore-service)
[![Total Downloads](https://poser.pugx.org/slvler/livescore-service/downloads)](https://packagist.org/packages/slvler/livescore-service)
[![License](https://poser.pugx.org/slvler/livescore-service/license)](https://packagist.org/packages/slvler/livescore-service)

Live Score Client for api-football.com

Welcome to Api-Football! You can use our API to access all API endpoints, which can get information about Football Leagues & Cups.

## Installation
## Requirements
- PHP 8.1
- Laravel 9.x | 10.x

## Installation
To install this package tou can use composer:

```bash
composer require slvler/livescore-service
```
## Usage

## Usage
- First, you should extract the config/livescore.php file to the config folder.

```php
php artisan vendor:publish --tag=livescore
```

- API key to be obtained from api-football.com address should be declared. This is your private API key, specific to this API.

```php
'livescore' => [
'base_url' => 'v3.football.api-sports.io',
Expand All @@ -38,7 +36,7 @@ php artisan vendor:publish --tag=livescore

### Example
```php
use slvler\LiveScoreService\LiveScoreClient;
use Slvler\LiveScoreService\LiveScoreClient;

$client = new LiveScoreClient();
```
Expand Down Expand Up @@ -370,16 +368,16 @@ $client->odds()->getOddsBets();
```

### Testing

```bash
composer test
```

## Credits

- [slvler](https://github.com/slvler)

## License

The MIT License (MIT). Please see [License File](https://github.com/slvler/btcturk-api/blob/main/LICENSE) for more information.

## Contributing
You're very welcome to contribute.
Please see [CONTRIBUTING](https://github.com/slvler/phone-validation/blob/main/CONTRIBUTING.md) for details.
45 changes: 30 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,58 @@
{
"name": "slvler/livescore-service",
"license": "MIT",
"description": "live score service API for api-football.com",
"type": "package",
"license": "MIT",
"keywords": [
"livescore",
"laravel",
"php"
],
"authors": [
{
"name": "slvler",
"email": "slvler@proton.me"
}
],
"homepage": "https://github.com/slvler/livescore-service",
"require": {
"php": "^8.1",
"guzzlehttp/guzzle": "^7.2",
"illuminate/support": "^9.0|^10.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.6",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.5.8",
"laravel/pint": "^1.18"
},
"autoload": {
"psr-4": {
"slvler\\LiveScoreService\\": "src/"
"Slvler\\LiveScoreService\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"slvler\\LiveScoreService\\Tests\\": "tests/"
"Slvler\\LiveScoreService\\Tests\\": "tests/"
}
},
"require": {},
"require-dev": {
"orchestra/testbench": "^6.18.0",
"phpunit/phpunit": "^9.5",
"guzzlehttp/guzzle": "^7.0.1"
},
"scripts": {
"test": "vendor/bin/phpunit tests"
},
"extra": {
"laravel": {
"providers": [
"slvler\\LiveScoreService\\LiveScoreServiceProvider"
"Slvler\\LiveScoreService\\LiveScoreServiceProvider"
],
"aliases": {
"LiveScore": "slvler\\LiveScoreService\\Facades\\LiveScore"
"LiveScore": "Slvler\\LiveScoreService\\Facades\\LiveScore"
}
}
},
"scripts": {
"test": "vendor/bin/phpunit tests --colors=always",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
"pint": "vendor/bin/pint",
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"minimum-stability": "stable",
"prefer-stable": true
}
15 changes: 7 additions & 8 deletions src/Api/Api.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

declare(strict_types=1);

namespace slvler\LiveScoreService\Api;
namespace Slvler\LiveScoreService\Api;

use slvler\LiveScoreService\LiveScoreClient;
use slvler\LiveScoreService\Message\ResponseTransformer;
use Exception;
use Slvler\LiveScoreService\LiveScoreClient;
use Slvler\LiveScoreService\Message\ResponseTransformer;

class Api
{
Expand All @@ -18,12 +18,11 @@ public function __construct(LiveScoreClient $client)
$this->client = $client;
}

public function get(string $uri, array $option = [])
public function get(string $uri, array $option = [])
{
$response = $this->client->getHttpClient()->request("GET", $uri , $option);
$response = $this->client->getHttpClient()->request('GET', $uri, $option);
$this->transformer = new ResponseTransformer($response);

return $this->transformer->toArray();
}


}
9 changes: 6 additions & 3 deletions src/Api/Coachs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace slvler\LiveScoreService\Api;
declare(strict_types=1);

namespace Slvler\LiveScoreService\Api;

class Coachs extends Api
{
Expand All @@ -10,12 +12,13 @@ public function getCoachs(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/coachs', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}
}
9 changes: 6 additions & 3 deletions src/Api/Countries.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<?php

namespace slvler\LiveScoreService\Api;
declare(strict_types=1);

namespace Slvler\LiveScoreService\Api;

class Countries extends Api
{
use Setting;

public function getAll(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/countries', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}
}
40 changes: 24 additions & 16 deletions src/Api/Fixtures.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace slvler\LiveScoreService\Api;
declare(strict_types=1);

namespace Slvler\LiveScoreService\Api;

class Fixtures extends Api
{
Expand All @@ -10,91 +12,97 @@ public function getRounds(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/fixtures/rounds', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}

public function getFixtures(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/fixtures', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}

public function getHeadToHead(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/fixtures/headtohead', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}

public function getStatistics(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/fixtures/statistics', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}

public function getEvents(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/fixtures/events', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}

public function getLineups(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/fixtures/lineups', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}

public function getPlayersStatistics(array $params = []): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/fixtures/players', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers,
'query' => $params
'query' => $params,
]);
}

}
8 changes: 5 additions & 3 deletions src/Api/General.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace slvler\LiveScoreService\Api;
declare(strict_types=1);

namespace Slvler\LiveScoreService\Api;

class General extends Api
{
Expand All @@ -10,12 +12,12 @@ public function getStatus(): array
{
$headers = [
'x-rapidapi-host' => Setting::getBaseUrl(),
"x-rapidapi-key" => Setting::getApiKey()
'x-rapidapi-key' => Setting::getApiKey(),
];

return $this->get('/status', [
'base_uri' => 'https://v3.football.api-sports.io',
'headers' => $headers
'headers' => $headers,
]);
}
}
Loading

0 comments on commit 5844b4d

Please sign in to comment.