-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
513 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/vendor | ||
/.idea | ||
/vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Contracts\Telegram; | ||
|
||
use Carbon\CarbonInterface; | ||
|
||
interface Entity | ||
{ | ||
public function toArray(): array; | ||
|
||
public function getId(): string; | ||
|
||
public function setId(string $id): void; | ||
|
||
public function getFirstName(): string; | ||
|
||
public function setFirstName(string $firstName): void; | ||
|
||
public function getLastName(): string; | ||
|
||
public function setLastName(string $lastName): void; | ||
|
||
public function getUsername(): string; | ||
|
||
public function setUsername(string $username): void; | ||
|
||
public function getPhotoUrl(): string; | ||
|
||
public function setPhotoUrl(string $photoUrl): void; | ||
|
||
public function getAuthDate(): CarbonInterface; | ||
|
||
public function setAuthDate(CarbonInterface $authDate): void; | ||
|
||
public function getHash(): string; | ||
|
||
public function setHash(string $hash): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Contracts\Telegram; | ||
|
||
interface EntityFactory | ||
{ | ||
public function create(): Entity; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Contracts\Telegram; | ||
|
||
use Exception; | ||
|
||
final class NotAllRequiredAttributesException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Contracts\Validation\Rules; | ||
|
||
use Exception; | ||
|
||
final class ResponseOutdatedException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Contracts\Validation\Rules; | ||
|
||
use Azate\LaravelTelegramLoginAuth\Contracts\Telegram\Entity; | ||
|
||
interface Rule | ||
{ | ||
public function validate(Entity $entity): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Contracts\Validation\Rules; | ||
|
||
use Exception; | ||
|
||
final class SignatureException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Contracts\Validation; | ||
|
||
use Azate\LaravelTelegramLoginAuth\Contracts\Telegram\Entity; | ||
use Azate\LaravelTelegramLoginAuth\Contracts\Validation\Rules\Rule as RuleContract; | ||
|
||
interface ValidatorChain | ||
{ | ||
public function addRule(RuleContract $rule): void; | ||
|
||
public function validate(Entity $entity): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Providers; | ||
|
||
use Azate\LaravelTelegramLoginAuth\Contracts\Validation\ValidatorChain as ValidatorChainContract; | ||
use Azate\LaravelTelegramLoginAuth\Validation\ValidatorChain; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
final class LaravelServiceProvider extends ServiceProvider | ||
{ | ||
public function boot(): void | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
$this->publishes([ | ||
$this->getPackageConfigPath() => $this->app->configPath('telegram_login_auth.php'), | ||
], 'config'); | ||
} | ||
} | ||
|
||
private function getPackageConfigPath(): string | ||
{ | ||
return dirname(__DIR__, 2) . '/config/telegram_login_auth.php'; | ||
} | ||
|
||
public function register(): void | ||
{ | ||
$this->mergeConfigFrom($this->getPackageConfigPath(), 'telegram_login_auth'); | ||
|
||
$this->app->bind(ValidatorChainContract::class, ValidatorChain::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Azate\LaravelTelegramLoginAuth\Telegram; | ||
|
||
use Azate\LaravelTelegramLoginAuth\Contracts\Telegram\NotAllRequiredAttributesException; | ||
use Illuminate\Support\Collection; | ||
|
||
abstract class AbstractEntityFactory | ||
{ | ||
protected function createAttributesCollection(array $attributes): Collection | ||
{ | ||
$attributesCollection = new Collection($attributes); | ||
|
||
if ($attributesCollection->count() !== count($this->getRequiredAttributes())) { | ||
throw new NotAllRequiredAttributesException(); | ||
} | ||
|
||
return $attributesCollection; | ||
} | ||
|
||
protected function getRequiredAttributes(): array | ||
{ | ||
return [ | ||
'id', | ||
'first_name', | ||
'last_name', | ||
'username', | ||
'photo_url', | ||
'auth_date', | ||
'hash', | ||
]; | ||
} | ||
} |
Oops, something went wrong.