Skip to content

Commit

Permalink
Merge pull request #6 from franciscobizi/dev
Browse files Browse the repository at this point in the history
Refactoring error methods
  • Loading branch information
franciscobizi committed Oct 13, 2022
2 parents ae266e0 + a3b9a49 commit 59f7f4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/Calendar/GoogleCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getCalendarTimezone(): array
$this->fields = [];
return $this->fetch("GET", 'Error : Failed to get calendar timezone');
}
$this->missingToken();
return $this->unauthenticated();
}

public function getCalendarsList(): array
Expand All @@ -64,7 +64,7 @@ public function getCalendarsList(): array
$this->fields = [];
return $this->fetch("GET", 'Error : Failed to get calendars list');
}
$this->missingToken();
return $this->unauthenticated();
}

public function getCalendarById(string $calendar_id): array
Expand All @@ -76,7 +76,7 @@ public function getCalendarById(string $calendar_id): array
$this->fields = [];
return $this->fetch("GET", 'Error : Failed to get calendars list');
}
$this->missingToken();
return $this->unauthenticated();
}

public function createEvent(array $event, string $calendar_id = ''): array
Expand All @@ -98,7 +98,7 @@ public function createEvent(array $event, string $calendar_id = ''): array
}
return ['message' => "Missing event data body"];
}
$this->missingToken();
return $this->unauthenticated();
}

public function getEvent(string $event_id, string $calendar_id = ''): array
Expand All @@ -110,7 +110,7 @@ public function getEvent(string $event_id, string $calendar_id = ''): array
$this->fields = [];
return $this->fetch("GET", 'Error : Failed to get event');
}
$this->missingToken();
return $this->unauthenticated();
}

public function updateEvent(string $event_id, array $event, string $calendar_id = ''): array
Expand All @@ -131,7 +131,7 @@ public function updateEvent(string $event_id, array $event, string $calendar_id
}
return ['message' => "Missing event data body"];
}
$this->missingToken();
return $this->unauthenticated();
}

public function cancelEvent(string $event_id, $calendar_id = ''): array
Expand All @@ -147,7 +147,7 @@ public function cancelEvent(string $event_id, $calendar_id = ''): array
$this->fields = [];
return $this->fetch("DELETE", 'Error : Failed to cancel event');
}
$this->missingToken();
return $this->unauthenticated();
}

public static function eventData(
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/AuthErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
trait AuthErrorResponse
{
protected function missingToken(string $message = "")
protected function unauthenticated(string $message = "")
{
$message = !empty($message) ? $message : "Missing token. Get token before procceed to this action.";
return ['code' => 401, 'message' => $message];
Expand Down

0 comments on commit 59f7f4b

Please sign in to comment.