Skip to content

Commit d32a766

Browse files
authored
Merge pull request #294 from dacastro4/codex/prepare-new-version-for-laravel-12
feat: prepare for Laravel 12
2 parents e1e040d + 9e0c39d commit d32a766

File tree

6 files changed

+41
-72
lines changed

6 files changed

+41
-72
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
# CHANGELOG
1+
# Changelog
2+
3+
## Unreleased
4+
5+
- Added support for Laravel 12.
6+
- Switched code style to Laravel Pint and formatted project.
7+
- Improved token check logic in `GmailConnection`.
8+
- Cleaned up and expanded documentation.
29

310
## 0.1
411

5-
First
12+
- Initial release.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Contributions are welcome, and are accepted via pull requests. Please review the
44

55
## Guidelines
66

7-
- Please follow the [PSR-2 Coding Style Guide](http://www.php-fig.org/psr/psr-2), enforced by [StyleCI](https://styleci.io).
7+
- Please run [Laravel Pint](https://laravel.com/docs/pint) before submitting your pull request.
88
- Ensure that the current tests pass, and if you've added something new, add the tests where relevant.
99
- Send a coherent commit history, making sure each individual commit in your pull request is meaningful.
1010
- You may need to [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) to avoid merge conflicts.

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
}
1616
],
1717
"require": {
18-
"php": "^7.4|^8.0",
18+
"php": "^8.2",
1919
"google/apiclient": "^v2.12.6",
20-
"illuminate/auth": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
21-
"illuminate/config": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
22-
"illuminate/database": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
23-
"illuminate/routing": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
24-
"illuminate/session": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
25-
"illuminate/support": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
20+
"illuminate/auth": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
21+
"illuminate/config": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
22+
"illuminate/database": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
23+
"illuminate/routing": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
24+
"illuminate/session": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
25+
"illuminate/support": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
2626
"symfony/mime": "^5.4|^6.0|^7.0",
2727
"ext-json": "*"
2828
},
2929
"require-dev": {
3030
"phpunit/phpunit": "^9.3|^10.5",
3131
"mockery/mockery": "^1.0",
32-
"squizlabs/php_codesniffer": "~3.4",
33-
"orchestra/testbench": "^v4.18.0|^v5.20.0|^v6.25.0|^8.0|^9.0"
32+
"laravel/pint": "^1.0",
33+
"orchestra/testbench": "^v4.18.0|^v5.20.0|^v6.25.0|^8.0|^9.0|^10.0"
3434
},
3535
"autoload": {
3636
"psr-4": {

pint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"preset": "laravel"
3+
}

readme.md

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@
99

1010

1111
# Gmail
12-
Gmail API for Laravel 9 and 10
12+
Gmail API for Laravel 9 through 12
1313

1414
You need to create an application in the [Google Console](https://console.developers.google.com/apis/credentials). Guidance [here](https://developers.google.com/gmail/api/quickstart/php#step_1_turn_on_the_api_name).
1515

16-
if you need **Laravel 5** compatibility please use version `2.0.x`.
17-
if you need **Laravel 6** compatibility please use version `3.0.x`.
18-
if you need **Laravel 7** compatibility please use version `4.0.x`.
19-
if you need **Laravel 8** compatibility please use version `5.0.x`.
20-
2116
# Requirements
2217

23-
* PHP ^8.0
24-
* Laravel 9
18+
* PHP ^8.2
19+
* Laravel 9-12
2520

2621
# Installation
2722

@@ -53,31 +48,6 @@ Now add the alias.
5348

5449
For laravel >=5.5 that's all. This package supports Laravel new [Package Discovery](https://laravel.com/docs/5.5/packages#package-discovery).
5550

56-
For <= PHP 7.4 compatibility use version `v5.0`
57-
58-
# Migration from 5.0 to 6.0
59-
60-
Requires Laravel 9 and you have to change the dependency to `"laravel/laravel": "^9.0"`
61-
Please, follow [Upgrading To 9.0 From 8.x Guide](https://laravel.com/docs/9.x/upgrade)
62-
63-
# Migration from 4.0 to 5.0
64-
65-
Requires Laravel 8 and you have to change the dependency to `"laravel/laravel": "^8.0"`
66-
Please, follow [Upgrading To 8.0 From 7.x Guide](https://laravel.com/docs/8.x/upgrade)
67-
68-
# Migration from 3.0 to 4.0
69-
70-
Requires Laravel 7 and you have to change the dependency to `"laravel/laravel": "^7.0"`
71-
Please, follow [Upgrading To 7.0 From 6.x Guide](https://laravel.com/docs/7.x/upgrade)
72-
73-
# Migration from 2.0 to 3.0
74-
75-
Requires Laravel 6 and you only have to change the dependency to `"laravel/laravel": "^6.0"`
76-
77-
# Migration from 1.0 to 2.0
78-
The only changed made was the multi credentials feature.
79-
- Change your composer.json from `"dacastro4/laravel-gmail": "^1.0"` to `"dacastro4/laravel-gmail": "^2.0"`
80-
8151
I had to change version because of a typo and that might break apps calling those attributes.
8252

8353
All variable with the word "threat" was change to "thread" (yeah, I know.. sorry)
@@ -91,14 +61,6 @@ Ex:
9161

9262
and so on.
9363

94-
# Migration from 0.6 to 1.0
95-
The only changed made was the multi credentials feature.
96-
- Change your composer.json from `"dacastro4/laravel-gmail": "^0.6"` to `"dacastro4/laravel-gmail": "^1.0"`
97-
98-
If you don't want the multi user credentials, you don't have to do anything else, if you do, you're going to have to
99-
login again to create a new credentials file per user.
100-
101-
10264
# Configuration
10365

10466
You only have to set the following variables on your `.env` file and you'll be on your way:

src/GmailConnection.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,22 @@ public function __construct($config = null, $userId = null)
5252
*
5353
* @return bool
5454
*/
55-
public function checkPreviouslyLoggedIn()
56-
{
57-
$fileName = $this->getFileName();
58-
$file = "gmail/tokens/$fileName.json";
59-
$allowJsonEncrypt = $this->_config['gmail.allow_json_encrypt'];
60-
61-
if (Storage::disk('local')->exists($file)) {
62-
if ($allowJsonEncrypt) {
63-
$savedConfigToken = json_decode(decrypt(Storage::disk('local')->get($file)), true);
64-
} else {
65-
$savedConfigToken = json_decode(Storage::disk('local')->get($file), true);
66-
}
67-
68-
return !empty($savedConfigToken['access_token']);
69-
70-
}
71-
72-
return false;
73-
}
55+
public function checkPreviouslyLoggedIn()
56+
{
57+
$fileName = $this->getFileName();
58+
$file = "gmail/tokens/$fileName.json";
59+
$disk = Storage::disk('local');
60+
61+
if (!$disk->exists($file)) {
62+
return false;
63+
}
64+
65+
$contents = $disk->get($file);
66+
$allowJsonEncrypt = $this->_config['gmail.allow_json_encrypt'];
67+
$savedConfigToken = json_decode($allowJsonEncrypt ? decrypt($contents) : $contents, true);
68+
69+
return !empty($savedConfigToken['access_token']);
70+
}
7471

7572
/**
7673
* Refresh the auth token if needed

0 commit comments

Comments
 (0)