From 95e1270da3bded19c8243690469829142c911c62 Mon Sep 17 00:00:00 2001 From: Felix Huber Date: Thu, 16 Sep 2021 21:22:37 +0200 Subject: [PATCH 1/7] wip --- .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 6 +- .github/SECURITY.md | 2 +- CHANGELOG.md | 2 +- LICENSE.md | 2 +- README.md | 28 +- composer.json | 39 ++- config/skeleton.php | 6 - configure-skeleton.sh | 137 ---------- database/factories/ModelFactory.php | 19 -- database/migrations/.gitkeep | 0 phpunit.xml.dist | 2 +- resources/views/.gitkeep | 0 .../CacheMiddlewareInterface.php | 10 + .../LaravelFileCacheMiddleware.php | 23 ++ src/CacheMiddleware/NullCacheMiddleware.php | 17 ++ src/Commands/SkeletonCommand.php | 17 -- src/Configuration.php | 71 +++++ src/DataTransferObjects/EsiAuthentication.php | 16 ++ src/DataTransferObjects/EsiConfiguration.php | 41 +++ src/DataTransferObjects/EsiResponse.php | 138 ++++++++++ src/EsiClient.php | 210 ++++++++++++++ .../EsiScopeAccessDeniedException.php | 8 + .../InvalidAuthenticationException.php | 8 + src/Exceptions/RequestFailedException.php | 44 +++ src/Exceptions/UriDataMissingException.php | 8 + src/Fetcher/GuzzleFetcher.php | 202 ++++++++++++++ src/Log/LogInterface.php | 15 + src/Log/NullLogger.php | 27 ++ src/Log/RotatingFileLogger.php | 102 +++++++ src/Services/CheckAccess.php | 258 ++++++++++++++++++ src/Services/RefreshToken.php | 73 +++++ src/Skeleton.php | 7 - src/SkeletonFacade.php | 16 -- src/SkeletonServiceProvider.php | 53 ---- tests/ExampleTest.php | 12 - tests/Pest.php | 26 +- tests/Stubs/Kernel.php | 22 -- tests/TestCase.php | 81 ------ tests/Unit/Access/CheckAccessTest.php | 58 ++++ tests/Unit/Fetcher/GuzzleFetcherTest.php | 75 +++++ tools/esi.json | 1 + tools/get_endpoints_and_scopes.php | 57 ++++ tools/swagger_download.php | 28 ++ 44 files changed, 1553 insertions(+), 416 deletions(-) delete mode 100644 config/skeleton.php delete mode 100755 configure-skeleton.sh delete mode 100644 database/factories/ModelFactory.php delete mode 100644 database/migrations/.gitkeep delete mode 100644 resources/views/.gitkeep create mode 100644 src/CacheMiddleware/CacheMiddlewareInterface.php create mode 100644 src/CacheMiddleware/LaravelFileCacheMiddleware.php create mode 100644 src/CacheMiddleware/NullCacheMiddleware.php delete mode 100644 src/Commands/SkeletonCommand.php create mode 100644 src/Configuration.php create mode 100644 src/DataTransferObjects/EsiAuthentication.php create mode 100644 src/DataTransferObjects/EsiConfiguration.php create mode 100644 src/DataTransferObjects/EsiResponse.php create mode 100644 src/EsiClient.php create mode 100644 src/Exceptions/EsiScopeAccessDeniedException.php create mode 100644 src/Exceptions/InvalidAuthenticationException.php create mode 100644 src/Exceptions/RequestFailedException.php create mode 100644 src/Exceptions/UriDataMissingException.php create mode 100644 src/Fetcher/GuzzleFetcher.php create mode 100644 src/Log/LogInterface.php create mode 100644 src/Log/NullLogger.php create mode 100644 src/Log/RotatingFileLogger.php create mode 100644 src/Services/CheckAccess.php create mode 100644 src/Services/RefreshToken.php delete mode 100755 src/Skeleton.php delete mode 100644 src/SkeletonFacade.php delete mode 100644 src/SkeletonServiceProvider.php delete mode 100644 tests/ExampleTest.php delete mode 100644 tests/Stubs/Kernel.php delete mode 100644 tests/TestCase.php create mode 100644 tests/Unit/Access/CheckAccessTest.php create mode 100644 tests/Unit/Fetcher/GuzzleFetcherTest.php create mode 100644 tools/esi.json create mode 100644 tools/get_endpoints_and_scopes.php create mode 100644 tools/swagger_download.php diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c68765b..e67dfd5 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: :vendor_name +github: seatplus diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 0d31fb8..8913c04 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: false contact_links: - name: Ask a question - url: https://github.com/vendor_slug/package_slug/discussions/new?category=q-a + url: https://github.com/seatplus/esi-client/discussions/new?category=q-a about: Ask the community for help - name: Request a feature - url: https://github.com/vendor_slug/package_slug/discussions/new?category=ideas + url: https://github.com/seatplus/esi-client/discussions/new?category=ideas about: Share ideas for new features - name: Report a bug - url: https://github.com/vendor_slug/package_slug/issues/new + url: https://github.com/seatplus/esi-client/issues/new about: Report a reproducable bug diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 12ab7c2..4f22a19 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -1,3 +1,3 @@ # Security Policy -If you discover any security related issues, please email author@domain.com instead of using the issue tracker. +If you discover any security related issues, please email felix.a.huber@gmx.net instead of using the issue tracker. diff --git a/CHANGELOG.md b/CHANGELOG.md index 767365d..87a22a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to `:package_name` will be documented in this file. +All notable changes to `esi-client` will be documented in this file. ## 1.0.0 - 202X-XX-XX diff --git a/LICENSE.md b/LICENSE.md index 58c9ad4..c5082ff 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) :vendor_name +Copyright (c) seatplus Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ca1e50f..da736a0 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -# :package_description +# A standalone ESI (Eve Swagger Interface) Client Libary using guzzle -[![Latest Version on Packagist](https://img.shields.io/packagist/v/vendor_slug/package_slug.svg?style=flat-square)](https://packagist.org/packages/vendor_slug/package_slug) -[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/vendor_slug/package_slug/run-tests?label=tests)](https://github.com/vendor_slug/package_slug/actions?query=workflow%3Arun-tests+branch%3Amain) -[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/vendor_slug/package_slug/Check%20&%20fix%20styling?label=code%20style)](https://github.com/vendor_slug/package_slug/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) -[![Total Downloads](https://img.shields.io/packagist/dt/vendor_slug/package_slug.svg?style=flat-square)](https://packagist.org/packages/vendor_slug/package_slug) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/seatplus/esi-client.svg?style=flat-square)](https://packagist.org/packages/seatplus/esi-client) +[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/seatplus/esi-client/run-tests?label=tests)](https://github.com/seatplus/esi-client/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/seatplus/esi-client/Check%20&%20fix%20styling?label=code%20style)](https://github.com/seatplus/esi-client/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) +[![Total Downloads](https://img.shields.io/packagist/dt/seatplus/esi-client.svg?style=flat-square)](https://packagist.org/packages/seatplus/esi-client) --- This repo can be used as to scaffold a Laravel package. Follow these steps to get started: -1. Press the "Use template" button at the top of this repo to create a new repo with the contents of this skeleton -2. Run "./configure-skeleton.sh" to run a script that will replace all placeholders throughout all the files +1. Press the "Use template" button at the top of this repo to create a new repo with the contents of this esi-client +2. Run "./configure-esi-client.sh" to run a script that will replace all placeholders throughout all the files 3. Remove this block of text. 4. Have fun creating your package. 5. If you need help creating a package, consider picking up our Laravel Package Training video course. @@ -19,7 +19,7 @@ This is where your description should go. Limit it to a paragraph or two. Consid ## Support us -[](https://spatie.be/github-ad-click/:package_name) +[](https://spatie.be/github-ad-click/esi-client) We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). @@ -30,19 +30,19 @@ We highly appreciate you sending us a postcard from your hometown, mentioning wh You can install the package via composer: ```bash -composer require vendor_slug/package_slug +composer require seatplus/esi-client ``` You can publish and run the migrations with: ```bash -php artisan vendor:publish --provider="VendorName\Skeleton\SkeletonServiceProvider" --tag="package_slug-migrations" +php artisan vendor:publish --provider="Seatplus\EsiClient\EsiClientServiceProvider" --tag="esi-client-migrations" php artisan migrate ``` You can publish the config file with: ```bash -php artisan vendor:publish --provider="VendorName\Skeleton\SkeletonServiceProvider" --tag="package_slug-config" +php artisan vendor:publish --provider="Seatplus\EsiClient\EsiClientServiceProvider" --tag="esi-client-config" ``` This is the contents of the published config file: @@ -55,8 +55,8 @@ return [ ## Usage ```php -$skeleton = new VendorName\Skeleton(); -echo $skeleton->echoPhrase('Hello, Spatie!'); +$esi-client = new Seatplus\EsiClient(); +echo $esi-client->echoPhrase('Hello, Spatie!'); ``` ## Testing @@ -79,7 +79,7 @@ Please review [our security policy](../../security/policy) on how to report secu ## Credits -- [:author_name](https://github.com/:author_username) +- [Felix Huber](https://github.com/seatplus) - [All Contributors](../../contributors) ## License diff --git a/composer.json b/composer.json index ddf59d9..ca315d1 100644 --- a/composer.json +++ b/composer.json @@ -1,40 +1,44 @@ { - "name": "vendor_slug/package_slug", - "description": ":package_description", + "name": "seatplus/esi-client", + "description": "A standalone ESI (Eve Swagger Interface) Client Libary using guzzle", "keywords": [ - ":vendor_name", + "seatplus", "laravel", - "package_slug" + "esi-client" ], - "homepage": "https://github.com/vendor_slug/package_slug", + "homepage": "https://github.com/seatplus/esi-client", "license": "MIT", "authors": [ { - "name": ":author_name", - "email": "author@domain.com", + "name": "Felix Huber", + "email": "felix.a.huber@gmx.net", "role": "Developer" } ], "require": { "php": "^8.0", - "seatplus/core": "^0.3", - "illuminate/contracts": "^8.37", - "seatplus/auth": "^0.8" + "ext-json": "*", + "firebase/php-jwt": "^5.4", + "kevinrob/guzzle-cache-middleware": "^3.4", + "nesbot/carbon": "^2.53", + "spatie/data-transfer-object": "^3.7" }, "require-dev": { + "fzaninotto/faker": "^1.5", + "illuminate/cache": "^8.60", + "mockery/mockery": "^1.4", "nunomaduro/collision": "^5.3", - "orchestra/testbench": "^6.15", "pestphp/pest-plugin-laravel": "^1.1" }, "autoload": { "psr-4": { - "VendorName\\Skeleton\\": "src", - "VendorName\\Skeleton\\Database\\Factories\\": "database/factories" + "Seatplus\\EsiClient\\": "src", + "Seatplus\\EsiClient\\Database\\Factories\\": "database/factories" } }, "autoload-dev": { "psr-4": { - "VendorName\\Skeleton\\Tests\\": "tests" + "Seatplus\\EsiClient\\Tests\\": "tests" } }, "scripts": { @@ -44,13 +48,6 @@ "config": { "sort-packages": true }, - "extra": { - "laravel": { - "providers": [ - "VendorName\\Skeleton\\SkeletonServiceProvider" - ] - } - }, "minimum-stability": "dev", "prefer-stable": true } diff --git a/config/skeleton.php b/config/skeleton.php deleted file mode 100644 index 1777c28..0000000 --- a/config/skeleton.php +++ /dev/null @@ -1,6 +0,0 @@ -" or ".