generated from spatie/package-skeleton-php
-
-
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.
Added Contracts for Request and Response
- Loading branch information
1 parent
b8598b4
commit 767e95c
Showing
4 changed files
with
97 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace CleaniqueCoders\KongAdminApi\Contracts; | ||
|
||
use Saloon\Enums\Method; | ||
|
||
/** | ||
* Interface Request | ||
* | ||
* Defines the contract for API request objects, outlining the methods required | ||
* to configure and retrieve details about an API request, such as the HTTP method | ||
* and endpoint. | ||
*/ | ||
interface Request | ||
{ | ||
/** | ||
* Set the HTTP method for the request. | ||
* | ||
* @param Method $method The HTTP method (e.g., GET, POST, PATCH, DELETE) | ||
*/ | ||
public function setMethod(Method $method): self; | ||
|
||
/** | ||
* Get the HTTP method for the request. | ||
* | ||
* @return Method The HTTP method | ||
*/ | ||
public function getMethod(): Method; | ||
|
||
/** | ||
* Set the endpoint for the API request. | ||
* | ||
* @param string $endpoint The API endpoint | ||
*/ | ||
public function setEndpoint(string $endpoint): self; | ||
|
||
/** | ||
* Get the endpoint for the API request. | ||
* | ||
* @return string The endpoint for the API request | ||
*/ | ||
public function getEndpoint(): string; | ||
|
||
/** | ||
* Resolve and retrieve the complete endpoint path for the API request. | ||
* | ||
* @return string The resolved endpoint path | ||
*/ | ||
public function resolveEndpoint(): string; | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace CleaniqueCoders\KongAdminApi\Contracts; | ||
|
||
use DateTimeInterface; | ||
|
||
/** | ||
* Interface Response | ||
* | ||
* Defines the contract for API response objects, specifying the structure and methods | ||
* required for interacting with the response data, such as status, data, and timestamps. | ||
*/ | ||
interface Response | ||
{ | ||
/** | ||
* Get the HTTP status code of the response. | ||
*/ | ||
public function getStatusCode(): string; | ||
|
||
/** | ||
* Get the HTTP status phrase of the response. | ||
*/ | ||
public function getStatusPhrase(): string; | ||
|
||
/** | ||
* Get the data payload from the API response. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function getData(): array; | ||
|
||
/** | ||
* Get the timestamp when the response was processed. | ||
*/ | ||
public function getRespondedAt(): DateTimeInterface; | ||
|
||
/** | ||
* Convert the response data to an array format. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(): array; | ||
} |