Skip to content

Commit

Permalink
Merge pull request #67 from wedevBr/fix/CodeWithMain
Browse files Browse the repository at this point in the history
Fix/code with main
  • Loading branch information
adeildo-jr authored Apr 12, 2024
2 parents 4382099 + bf46da9 commit 294ece6
Show file tree
Hide file tree
Showing 298 changed files with 3,582 additions and 3,003 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"require-dev": {
"orchestra/testbench": "^7.24.|^8.0",
"phpunit/phpunit": "^9.0|^10.0|^11.0",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "^1.10",
"laravel/pint": "^1.15"
},
"extra": {
"laravel": {
Expand Down
32 changes: 16 additions & 16 deletions config/laradumps.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@

'send_livewire_failed_validation' => [
'enabled' => env('DS_SEND_LIVEWIRE_FAILED_VALIDATION', false),
'sleep' => env('DS_SEND_LIVEWIRE_FAILED_VALIDATION_SLEEP', 400),
'sleep' => env('DS_SEND_LIVEWIRE_FAILED_VALIDATION_SLEEP', 400),
],

/*
Expand Down Expand Up @@ -271,27 +271,27 @@

'ide_handlers' => [
'atom' => [
'handler' => 'atom://core/open/file?filename=',
'handler' => 'atom://core/open/file?filename=',
'line_separator' => '&line=',
],
'phpstorm' => [
'handler' => 'phpstorm://open?file=',
'handler' => 'phpstorm://open?file=',
'line_separator' => '&line=',
],
'sublime' => [
'handler' => 'subl://open?url=file://',
'handler' => 'subl://open?url=file://',
'line_separator' => '&line=',
],
'vscode' => [
'handler' => 'vscode://file/',
'handler' => 'vscode://file/',
'line_separator' => ':',
],
'vscode_remote' => [
'handler' => 'vscode://vscode-remote/',
'handler' => 'vscode://vscode-remote/',
'line_separator' => ':',
'local_path' => 'wsl+' . env('DS_PREFERRED_WSL_DISTRO', 'Ubuntu20.04LTS'),
'remote_path' => env('DS_REMOTE_PATH', null),
'work_dir' => env('DS_WORKDIR', '/var/www/html'),
'local_path' => 'wsl+'.env('DS_PREFERRED_WSL_DISTRO', 'Ubuntu20.04LTS'),
'remote_path' => env('DS_REMOTE_PATH', null),
'work_dir' => env('DS_WORKDIR', '/var/www/html'),
],
],

Expand Down Expand Up @@ -404,13 +404,13 @@
*/

'level_log_colors_map' => [
'error' => env('DS_LOG_COLOR_ERROR', 'border-red-600'),
'critical' => env('DS_LOG_COLOR_CRITICAL', 'border-red-900'),
'alert' => env('DS_LOG_COLOR_ALERT', 'border-red-500'),
'error' => env('DS_LOG_COLOR_ERROR', 'border-red-600'),
'critical' => env('DS_LOG_COLOR_CRITICAL', 'border-red-900'),
'alert' => env('DS_LOG_COLOR_ALERT', 'border-red-500'),
'emergency' => env('DS_LOG_COLOR_EMERGENCY', 'border-red-600'),
'warning' => env('DS_LOG_COLOR_WARNING', 'border-orange-300'),
'notice' => env('DS_LOG_COLOR_NOTICE', 'border-green-300'),
'info' => env('DS_LOG_COLOR_INFO', 'border-blue-300'),
'debug' => env('DS_LOG_COLOR_INFO', 'border-black'),
'warning' => env('DS_LOG_COLOR_WARNING', 'border-orange-300'),
'notice' => env('DS_LOG_COLOR_NOTICE', 'border-green-300'),
'info' => env('DS_LOG_COLOR_INFO', 'border-blue-300'),
'debug' => env('DS_LOG_COLOR_INFO', 'border-black'),
],
];
59 changes: 18 additions & 41 deletions src/Auth/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

/**
* Class Auth
*
* @package WeDevBr\Celcoin
*/
class Auth
{
Expand All @@ -33,17 +31,18 @@ class Auth

/** @var ?string */
protected ?string $tokenExpiry = null;

/**
* @var ?string
*/
protected ?string $mtlsPassphrase = null;

protected ?string $mtlsCert = null;

protected ?string $mtlsKey = null;

/**
* Returns the instance of this class
*
* @return self
*/
public static function login(): self
{
Expand All @@ -56,104 +55,95 @@ public static function login(): self
return self::$login;
}

/**
* @return self
*/
public function setClientCredentials(): self
{
$this->clientId = $this->clientId ?? config('celcoin')['client_id'];
$this->clientSecret = $this->clientSecret ?? config('celcoin')['client_secret'];
$this->mtlsPassphrase = $this->mtlsPassphrase ?? config('celcoin.mtls_passphrase');

return $this;
}

/**
* @param null|string $clientId
* @param null|string $clientId
* @return self
*/
public function setClientId($clientId)
{
$this->clientId = $clientId;

return $this;
}

/**
* @param null|string $clientSecret
* @param null|string $clientSecret
* @return self
*/
public function setClientSecret($clientSecret)
{
$this->clientSecret = $clientSecret;

return $this;
}

/**
* @param string $grantType
* @return self
*/
public function setGrantType(string $grantType)
{
$this->grantType = $grantType;

return $this;
}

/**
* @param string $passPhrase
* @return $this
*/
public function setPassphrase(string $passPhrase): self
{
$this->mtlsPassphrase = $passPhrase;

return $this;
}

/**
* @param string $token
* @return self
*/
public function setToken(string $token): self
{
$this->token = $token;

return $this;
}

/**
* Reset token for new request
*
* @return self
*/
public function resetToken(): self
{
$this->token = null;

return $this;
}

/**
* @return ?string
*
* @throws RequestException
*/
public function getToken(): ?string
{
if (now()->unix() > $this->tokenExpiry || !$this->token) {
if (now()->unix() > $this->tokenExpiry || ! $this->token) {
$this->auth();
}

return $this->token;
}

/**
* @param string $tokenExpiry
* @return self
*/
public function setTokenExpiry(string $tokenExpiry): self
{
$this->tokenExpiry = $tokenExpiry;

return $this;
}

/**
* @return mixed
*/
public function getTokenExpiry(): mixed
{
return $this->tokenExpiry;
Expand All @@ -162,48 +152,36 @@ public function getTokenExpiry(): mixed
public function setCertPath(string $path): self
{
$this->mtlsCert = $path;

return $this;
}

/**
* Set the cert.pem file path
* @param string $path
* @return self
*/
public function setKeyPath(string $path): self
{
$this->mtlsKey = $path;

return $this;
}


/**
* @return string|null
*/
public function getMtlsKeyPath(): ?string
{
return $this->mtlsKey;
}

/**
* @return string|null
*/
public function getMtlsPassphrase(): ?string
{
return $this->mtlsPassphrase;
}


/**
* @return string|null
*/
public function getMtlsCertPath(): ?string
{
return $this->mtlsCert;
}

/**
* @return void
* @throws RequestException
*/
private function auth(): void
Expand All @@ -213,7 +191,7 @@ private function auth(): void
$body = [
'grant_type' => $this->grantType,
'client_secret' => $this->clientSecret,
'client_id' => $this->clientId
'client_id' => $this->clientId,
];

$request = Http::asForm();
Expand Down Expand Up @@ -244,5 +222,4 @@ private function auth(): void

event(new CelcoinAuthenticatedEvent($this->token, $this->tokenExpiry));
}

}
Loading

0 comments on commit 294ece6

Please sign in to comment.