From c289cfdce00ae1f2ee3374a531ba51c50a46ebd2 Mon Sep 17 00:00:00 2001 From: Tom Shaw Date: Thu, 18 Apr 2024 10:11:39 -0500 Subject: [PATCH] refactor: remove explicit GoogleClient::class dependency in GoogleApiManager --- README.md | 10 ++++------ src/GoogleApiManager.php | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5d60152..acd9902 100644 --- a/README.md +++ b/README.md @@ -128,11 +128,9 @@ This package includes a Google `Calendar` and `Gmail` adapter classes. Feel free > Using the client to create a calendar event for the following day 1:00PM. ```php - public function add(GoogleClient $client) + public function add() { - $calendar = GoogleApi::calendar($client); - - $calendar->setCalendarId('email@example.com'); + $calendar = GoogleApi::calendar()->setCalendarId('email@example.com'); $summary = 'Test Event'; $location = '123 Test St, Test City, TS'; @@ -150,7 +148,7 @@ This package includes a Google `Calendar` and `Gmail` adapter classes. Feel free > Using the client to send emails. ```php - public function mount(GoogleClient $client, Order $id) + public function mount(Order $id) { $model = Order::with(['user'])->where('id', $id)->first(); @@ -159,7 +157,7 @@ This package includes a Google `Calendar` and `Gmail` adapter classes. Feel free storage_path('app/public/invoice.pdf'), ]; - $gmail = GoogleApi::gmail($client); + $gmail = GoogleApi::gmail(); $gmail->from('email@example.com', 'Company Name'); $gmail->to($model->user->email, $model->user->name); $gmail->cc('sales@example.com'); diff --git a/src/GoogleApiManager.php b/src/GoogleApiManager.php index 8d24a54..6c780d9 100644 --- a/src/GoogleApiManager.php +++ b/src/GoogleApiManager.php @@ -7,13 +7,13 @@ class GoogleApiManager { - public function gmail(GoogleClient $client): GoogleMail + public function gmail(): GoogleMail { - return new GoogleMail($client); + return new GoogleMail(app(GoogleClient::class)); } - public function calendar(GoogleClient $client): GoogleCalendar + public function calendar(): GoogleCalendar { - return new GoogleCalendar($client); + return new GoogleCalendar(app(GoogleClient::class)); } }