-
Notifications
You must be signed in to change notification settings - Fork 0
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
9 changed files
with
196 additions
and
15 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
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 Unolia\UnoliaCLI\Http\Integrations\Unolia\Requests; | ||
|
||
use Saloon\Contracts\Body\HasBody; | ||
use Saloon\Enums\Method; | ||
use Saloon\Http\Request; | ||
use Saloon\Traits\Body\HasJsonBody; | ||
|
||
class Login extends Request implements HasBody | ||
{ | ||
use HasJsonBody; | ||
|
||
protected Method $method = Method::POST; | ||
|
||
public function __construct( | ||
public readonly string $email, | ||
public readonly string $password, | ||
public readonly ?string $two_factor_code = null, | ||
public readonly ?string $token_name = null, | ||
) { | ||
} | ||
|
||
public function defaultBody(): array | ||
{ | ||
return array_filter([ | ||
'email' => $this->email, | ||
'password' => $this->password, | ||
'two_factor_code' => $this->two_factor_code, | ||
'token_name' => $this->token_name, | ||
]); | ||
} | ||
|
||
public function resolveEndpoint(): string | ||
{ | ||
return 'login'; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Unolia\UnoliaCLI\Http\Integrations\Unolia\Requests; | ||
|
||
use Saloon\Enums\Method; | ||
use Saloon\Http\Request; | ||
|
||
class Logout extends Request | ||
{ | ||
protected Method $method = Method::DELETE; | ||
|
||
public function resolveEndpoint(): string | ||
{ | ||
return 'logout'; | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
namespace Unolia\UnoliaCLI\Http\Integrations\Unolia; | ||
|
||
use Saloon\Http\Auth\TokenAuthenticator; | ||
use Saloon\Http\Connector; | ||
use Saloon\Traits\Plugins\AcceptsJson; | ||
use Unolia\UnoliaCLI\Helpers\Helpers; | ||
|
||
class UnoliaAuth extends Connector | ||
{ | ||
use AcceptsJson; | ||
|
||
public function __construct( | ||
public readonly ?string $token = null, | ||
public readonly ?string $api_url = null, | ||
) { | ||
} | ||
|
||
protected function defaultAuth(): ?TokenAuthenticator | ||
{ | ||
return $this->token ? new TokenAuthenticator($this->token) : null; | ||
} | ||
|
||
protected function defaultHeaders(): array | ||
{ | ||
return [ | ||
'User-Agent' => Helpers::getUserAgent(), | ||
]; | ||
} | ||
|
||
public function resolveBaseUrl(): string | ||
{ | ||
return $this->api_url ?? 'https://app.unolia.com/api/'; | ||
} | ||
} |
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