Skip to content

V2: Uses the new TiteLive APIs #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
07662bc
WIP: First working version of TiteLive Client using the new API
PatrickePatate Nov 14, 2024
ed23de7
Fix styling
PatrickePatate Nov 14, 2024
354f532
Fix tests and improve retro-compatibility
PatrickePatate Nov 14, 2024
7d29f28
Merge branch 'v2' of github.com:code16/laravel-titelive-client into v2
PatrickePatate Nov 14, 2024
fc11a1f
Fix styling
PatrickePatate Nov 14, 2024
6099892
Fix a bug while fetching specific book data
PatrickePatate Nov 14, 2024
6706f93
Fix styling
PatrickePatate Nov 14, 2024
be68ea9
Return EAN in TiteliveBookNotFoundException
PatrickePatate Nov 15, 2024
2b6e04c
Merge branch 'v2' of github.com:code16/laravel-titelive-client into v2
PatrickePatate Nov 15, 2024
4ee9fd4
Fix styling
PatrickePatate Nov 15, 2024
1eae97e
Fixes bug on refreshBooks
PatrickePatate Nov 18, 2024
87fbbbe
Merge branch 'v2' of github.com:code16/laravel-titelive-client into v2
PatrickePatate Nov 18, 2024
9ad4b39
Fix styling
PatrickePatate Nov 18, 2024
650ad01
Fix
PatrickePatate Dec 6, 2024
decb1b1
Merge branch 'v2' of github.com:code16/laravel-titelive-client into v2
PatrickePatate Dec 6, 2024
11c031c
Fix styling
PatrickePatate Dec 6, 2024
cd44938
Fix unsupported supports
PatrickePatate Dec 6, 2024
12d5716
Merge branch 'v2' of github.com:code16/laravel-titelive-client into v2
PatrickePatate Dec 6, 2024
201723c
Fix fixture
PatrickePatate Dec 6, 2024
f37f155
Allow custom visual placeholder
aguingand Dec 13, 2024
650d8a5
fix fallback as static method
aguingand Dec 13, 2024
9f3c9d3
Autocomplete book attributes
aguingand Dec 13, 2024
6d8c967
Allow to override Book class
aguingand Dec 13, 2024
d7f7147
Fix styling
aguingand Dec 13, 2024
8ab68c4
Update IDE helper
aguingand Dec 13, 2024
2e9447e
Random visual in factory
Jan 2, 2025
afb374d
Report auth errors only if they occur after reauth
PatrickePatate Jan 17, 2025
2832739
Fix ListBooks count bug
PatrickePatate Jan 23, 2025
0a9bd29
Revert because TL are fuck**g idiots
PatrickePatate Jan 23, 2025
2c9d930
Fix errors being sent to sentry while reconnecting
PatrickePatate Jan 24, 2025
f1f7ad7
Add CodeSupport filtering when calling api
PatrickePatate Jan 31, 2025
f3103b0
Fix styling
PatrickePatate Jan 31, 2025
15ee421
Handle multiple category codes per categories
PatrickePatate Feb 28, 2025
a430ee2
Merge branch 'v2' of github.com:code16/laravel-titelive-client into v2
PatrickePatate Feb 28, 2025
4facb87
Handle configurable TL code_support
dvlpp Apr 17, 2025
db050e8
Update phpdoc
aguingand Apr 23, 2025
f3710be
Setup pint workflow
aguingand Apr 23, 2025
e1ab286
Enhance depencies compatibility w/ Laravel 12
PatrickePatate Apr 24, 2025
0c68670
Enhance CI
PatrickePatate Apr 24, 2025
94bd271
Handle cache in FindBook
PatrickePatate May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/fix-php-code-style-issues.yml

This file was deleted.

35 changes: 20 additions & 15 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,35 @@ name: run-tests

on:
push:
branches: [main]
branches: [main, v2]
pull_request:
branches: [main]
branches: [main, v2]

jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.2]
laravel: [10.*]
stability: [prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
carbon: ^2.63

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
- php: 8.3
env:
LARAVEL: 11.*
TESTBENCH: 9.*
- php: 8.4
env:
LARAVEL: 11.*
TESTBENCH: 9.*
- php: 8.4
env:
LARAVEL: 12.*
TESTBENCH: 10.*
env: ${{ matrix.env }}
name: P${{ matrix.php }} - L${{ matrix.env.LARAVEL }} - TB${{ matrix.env.TESTBENCH }}

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -41,8 +46,8 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
composer require "laravel/framework:${LARAVEL}" "orchestra/testbench:${TESTBENCH}" --no-interaction --no-update
composer update --prefer-stable --prefer-dist --no-interaction

- name: List Installed Dependencies
run: composer show -D
Expand Down
31 changes: 31 additions & 0 deletions _ide_helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/** @noinspection all */

namespace Code16\LaravelTiteliveClient\Models {

use Carbon\Carbon;
use Code16\LaravelTiteliveClient\Enum\BookAvailability;
use Illuminate\Database\Eloquent\Model;

/**
* @property string id
* @property string title
* @property string[] authors
* @property string|null translator
* @property string description
* @property int weight
* @property int page_count
* @property string[] category_codes
* @property string|null readership
* @property string editor
* @property int price
* @property Carbon|null published_date
* @property string support
* @property string[] visuals
* @property BookAvailability availability
* @property int stock
* @property string[] editions
* @property \DateTimeInterface refreshed_at
*/
class Book extends Model {}
}
20 changes: 12 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
}
],
"require": {
"php": "^8.2|^8.3",
"php": "^8.2|^8.3|^8.4",
"ext-intl": "*",
"code16/pint-config": "^1.2.1",
"guzzlehttp/guzzle": "^7.7",
"illuminate/contracts": "^10.0|^11.0",
"illuminate/contracts": "^10.0|^11.0|^12.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.8",
"orchestra/testbench": "^8.8|^9.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"nunomaduro/collision": "^8.0",
"orchestra/testbench": "^8.8|^9.0|^10.0",
"pestphp/pest": "^2.0|^3.0",
"pestphp/pest-plugin-arch": "^2.0|^3.0",
"pestphp/pest-plugin-laravel": "^2.0|^3.0",
"spatie/laravel-ray": "^1.26"
},
"autoload": {
Expand All @@ -35,7 +36,10 @@
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"post-autoload-dump": [
"@php vendor/bin/pint-config install",
"@composer run prepare"
],
"clear": "@php vendor/bin/testbench package:purge-laravel-titelive-client --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
Expand Down
8 changes: 6 additions & 2 deletions config/titelive-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
'cache_duration' => env('TITELIVE_CLIENT_BOOK_DIRECTORY_CACHE_DURATION_IN_MINUTES', 60 * 24),
'api' => [
'login' => env('TITELIVE_LOGIN'),
'client_number' => env('TITELIVE_CLIENT_NUM'),
'password' => env('TITELIVE_PWD'),
'endpoint' => env('TITELIVE_ENDPOINT', 'https://search.epagine.fr/ws.php'),
'endpoint' => env('TITELIVE_ENDPOINT', 'https://catsearch.epagine.fr/v1/'),
'login_endpoint' => env('TITELIVE_LOGIN_ENDPOINT', 'https://login.epagine.fr/v1/'),
'retry' => [
'times' => env('TITELIVE_CLIENT_BOOK_DIRECTORY_API_RETRY_TIMES', 5),
'sleep_milliseconds' => env('TITELIVE_CLIENT_BOOK_DIRECTORY_API_RETRY_SLEEP_MILLISECONDS', 2000),
],
'params' => [
'code_support' => env('TITELIVE_CLIENT_API_PARAM_CODE_SUPPORT'),
],
],
],
'book_model_class' => \Code16\LaravelTiteliveClient\Models\Book::class,
];
20 changes: 7 additions & 13 deletions database/factories/BookFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

namespace Code16\LaravelTiteliveClient\Database\Factories;

use Code16\LaravelTiteliveClient\Book;
use Illuminate\Database\Eloquent\Factories\Factory;

class BookFactory extends Factory
{
protected $model = Book::class;

private static int $VISUAL_INDEX = 0;

private static array $VISUALS = [
'229/9782070585229',
'904/9782070624904',
Expand Down Expand Up @@ -75,6 +70,11 @@ class BookFactory extends Factory
'613/9782075150613',
];

public function modelName()
{
return config('titelive-client.book_model_class');
}

public function definition()
{
return [
Expand Down Expand Up @@ -113,16 +113,10 @@ public function definition()

private function getVisual(string $size = 'L'): string
{
$visual = sprintf(
return sprintf(
'https://images.epagine.fr/%s_1_%s.jpg',
self::$VISUALS[self::$VISUAL_INDEX],
self::$VISUALS[array_rand(self::$VISUALS)],
['S' => 'v', 'M' => 'm', 'L' => '75'][$size] ?? '75'
);

if (++self::$VISUAL_INDEX >= count(self::$VISUALS)) {
self::$VISUAL_INDEX = 0;
}

return $visual;
}
}
1 change: 1 addition & 0 deletions pint.json
2 changes: 1 addition & 1 deletion src/Api/Clients/BookCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Code16\LaravelTiteliveClient\Api\Clients;

use Code16\LaravelTiteliveClient\Book;
use Code16\LaravelTiteliveClient\Models\Book;

interface BookCache
{
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Clients/BookCacheMockForDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Code16\LaravelTiteliveClient\Api\Clients;

use Code16\LaravelTiteliveClient\Book;
use Code16\LaravelTiteliveClient\Models\Book;

class BookCacheMockForDev implements BookCache
{
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Clients/BookDirectoryClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Code16\LaravelTiteliveClient\Api\Clients;

use Code16\LaravelTiteliveClient\Book;
use Code16\LaravelTiteliveClient\Models\Book;
use Illuminate\Support\Collection;

interface BookDirectoryClient
Expand Down
5 changes: 4 additions & 1 deletion src/Api/Clients/BookDirectoryMockClientForDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace Code16\LaravelTiteliveClient\Api\Clients;

use Code16\LaravelTiteliveClient\Book;
use Code16\LaravelTiteliveClient\Concerns\UsesBookModel;
use Code16\LaravelTiteliveClient\Models\Book;
use Illuminate\Support\Collection;

class BookDirectoryMockClientForDev implements BookDirectoryClient
{
use UsesBookModel;

private array $params = [];

public function getParams(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Clients/RandomBasedOnRefreshDateBookCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Carbon\Carbon;
use Code16\LaravelTiteliveClient\Api\FindBook;
use Code16\LaravelTiteliveClient\Book;
use Code16\LaravelTiteliveClient\Models\Book;

/**
* This cache strategy is based on a simple rule:
Expand Down
7 changes: 7 additions & 0 deletions src/Api/Clients/TiteLive/TiteLiveApiCredentialsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Code16\LaravelTiteliveClient\Api\Clients\TiteLive;

use Exception;

class TiteLiveApiCredentialsException extends Exception {}
7 changes: 7 additions & 0 deletions src/Api/Clients/TiteLive/TiteLiveBookNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Code16\LaravelTiteliveClient\Api\Clients\TiteLive;

use Exception;

class TiteLiveBookNotFoundException extends Exception {}
Loading