Skip to content

Commit

Permalink
update 1.16.2 - fix HTTP responses
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-dahir committed Jul 2, 2018
1 parent cdfc9cf commit 4476586
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Changelog

### 1.16.1 stable - July 3, 17
### 1.16.2 stable - July 3, 17
- Bug fix [#163](/../../issues/163)
- Fix HTTP responses

### 1.16.0 stable - June 28, 17
- Switch over to Guzzle for fetching file/status
Expand Down
2 changes: 1 addition & 1 deletion examples/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$time_start = microtime(true);

// $jikan->Manga(1, [CHARACTERS]);
$jikan->Manga(1, [CHARACTERS]);
$jikan->Anime(3);
// $jikan->Seasonal();

$time_end = microtime(true);
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The word _Jikan_ literally translates to _Time_ in Japanese (**時間**). And th
1. `composer require jikan-me/jikan`
2. [Documentation](https://jikan.moe/docs)

## Jikan REST API [![REST PHP](https://img.shields.io/badge/JikanPHP-1.15.15-blue.svg?style=flat)](https://jikan.moe)
## Jikan REST API [![REST PHP](https://img.shields.io/badge/JikanPHP-1.16.2-blue.svg?style=flat)](https://jikan.moe)
If you don't want to handle PHP, you're in luck! Jikan has it's own RESTful API service (CORS enabled + JSON response) hosted by [Hibiki](https://github.com/assintates)

- **[REST DOCUMENTATION](https://jikan.docs.apiary.io)**
Expand Down Expand Up @@ -78,8 +78,9 @@ Contributions to Jikan by making wrappers in programming languages of your choic
- [PThreads](https://github.com/krakjoe/pthreads) (Multi-threaded) Support (CLI ONLY!)

## Changelog
### 1.16.1 stable - July 3, 17
### 1.16.2 stable - July 3, 17
- Bug fix [#163](/../../issues/163)
- Fix HTTP responses

**[Read More](https://github.com/jikan-me/jikan/tree/master/changelog.md)**

Expand Down
4 changes: 3 additions & 1 deletion src/Jikan.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class Jikan
*/
public function __construct(ClientInterface $client = null)
{
self::$guzzle = $client ?? new Client();
self::$guzzle = $client ?? new Client([
'http_errors' => false
]);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Lib/Parser/TemplateParse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Jikan\Helper\Utils as Util;
use Jikan\Jikan;
use \GuzzleHttp\Exception\BadResponseException;

/**
* Class TemplateParse
Expand Down Expand Up @@ -45,13 +46,17 @@ public function loadFile()
if (is_null($this->filePath)) {
throw new \Exception('File path is null');
}

$response = Jikan::$guzzle->get($this->filePath);

if ($response->getStatusCode() === 429) {
throw new \Exception('MyAnimeList Rate Limit reached');
}
if ($response->getStatusCode() !== 200) {
throw new \Exception('File does not exist');
}

$this->setStatus($response->getStatusCode());
$this->file = (string)$response->getBody();
$this->file = explode(PHP_EOL, $this->file);
array_walk($this->file, Util::class.'::trim'); // bystanders begone!
Expand Down

0 comments on commit 4476586

Please sign in to comment.