Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdrakedennis committed Mar 31, 2023
2 parents 198aa26 + 074888f commit 80ecc57
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 82 deletions.
9 changes: 3 additions & 6 deletions src/Requests/Baskets/CreateBasketRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ class CreateBasketRequest extends Request implements HasBody
public function __construct(
protected string $returnUrl,
protected string $completeUrl
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::POST;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
Expand All @@ -37,7 +34,7 @@ protected function defaultBody(): array
{
return [
'return_url' => $this->returnUrl,
'complete_url' => $this->completeUrl
'complete_url' => $this->completeUrl,
];
}
}
11 changes: 3 additions & 8 deletions src/Requests/Baskets/GetBasketRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,26 @@

namespace Shimmer\LaravelTebexCheckout\Requests\Baskets;

use App\Data\TebexCheckout\Responses\Baskets\BasketResponse;
use Saloon\Contracts\Response;
use Saloon\Enums\Method;
use Saloon\Http\Request;

class GetBasketRequest extends Request
{
public function __construct(
protected string $ident
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::GET;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/baskets/' . $this->ident;
return '/baskets/'.$this->ident;
}
}
12 changes: 4 additions & 8 deletions src/Requests/Baskets/Packages/AddPackageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Shimmer\LaravelTebexCheckout\Requests\Baskets\Packages;

use Saloon\Contracts\Body\HasBody;
use Saloon\Contracts\Response;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Traits\Body\HasJsonBody;
Expand All @@ -16,30 +15,27 @@ public function __construct(
protected string $ident,
protected object $package,
protected string $type,
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::POST;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/baskets/'. $this->ident . '/packages';
return '/baskets/'.$this->ident.'/packages';
}

protected function defaultBody(): array
{
return [
'package' => $this->package,
'type' => $this->type
'type' => $this->type,
];
}
}
9 changes: 3 additions & 6 deletions src/Requests/Baskets/Packages/DeletePackageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@ class DeletePackageRequest extends Request
public function __construct(
protected string $ident,
protected int $rowId
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::DELETE;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/baskets/' . $this->ident . '/packages/' . $this->rowId;
return '/baskets/'.$this->ident.'/packages/'.$this->rowId;
}
}
11 changes: 4 additions & 7 deletions src/Requests/Baskets/Sales/CreateSaleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,28 @@ public function __construct(
protected string $name,
protected string $discountType,
protected float $amount
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::POST;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/baskets/' . $this->ident . '/sales';
return '/baskets/'.$this->ident.'/sales';
}

protected function defaultBody(): array
{
return [
'name' => $this->name,
'discount_type' => $this->discountType,
'amount' => $this->amount
'amount' => $this->amount,
];
}
}
9 changes: 3 additions & 6 deletions src/Requests/Checkout/CreateCheckoutRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ class CreateCheckoutRequest extends Request implements HasBody
public function __construct(
protected array $basket,
protected array $items,
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::POST;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
Expand All @@ -37,7 +34,7 @@ protected function defaultBody(): array
{
return [
'basket' => $this->basket,
'items' => $this->items
'items' => $this->items,
];
}
}
9 changes: 3 additions & 6 deletions src/Requests/Payments/GetPaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ class GetPaymentRequest extends Request
{
public function __construct(
protected string $txnID
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::GET;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/payments/' . $this->txnID . '?type=txn_id';
return '/payments/'.$this->txnID.'?type=txn_id';
}
}
9 changes: 3 additions & 6 deletions src/Requests/Payments/RefundPaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ class RefundPaymentRequest extends Request
{
public function __construct(
protected string $txnID
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::POST;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/payments/' . $this->txnID . '/refund?type=txn_id';
return '/payments/'.$this->txnID.'/refund?type=txn_id';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ class CancelRecurringPaymentRequest extends Request
{
public function __construct(
protected string $reference
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::DELETE;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/recurring-payments/' . $this->reference;
return '/recurring-payments/'.$this->reference;
}
}
9 changes: 3 additions & 6 deletions src/Requests/RecurringPayments/GetRecurringPaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ class GetRecurringPaymentRequest extends Request
{
public function __construct(
protected string $reference
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::GET;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/recurring-payments/' . $this->reference;
return '/recurring-payments/'.$this->reference;
}
}
11 changes: 4 additions & 7 deletions src/Requests/RecurringPayments/UpdateRecurringPaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,26 @@ class UpdateRecurringPaymentRequest extends Request implements HasBody
public function __construct(
protected string $reference,
protected array $items,
){}
) {
}

/**
* Define the HTTP method
*
* @var Method
*/
protected Method $method = Method::PUT;

/**
* Define the endpoint for the request
*
* @return string
*/
public function resolveEndpoint(): string
{
return '/recurring-payments/' . $this->reference;
return '/recurring-payments/'.$this->reference;
}

protected function defaultBody(): array
{
return [
'items' => $this->items
'items' => $this->items,
];
}
}
5 changes: 2 additions & 3 deletions src/TebexCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ class TebexCheckout extends Connector
public function __construct(
public string $username,
public string $password
){}
) {
}

/**
* The Base URL of the API
*
* @return string
*/
public function resolveBaseUrl(): string
{
Expand Down
12 changes: 6 additions & 6 deletions tests/CheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

it('successfully creates a checkout request', function () {
$mockClient = new MockClient([
CreateCheckoutRequest::class => MockResponse::fixture('create.checkout.request')
CreateCheckoutRequest::class => MockResponse::fixture('create.checkout.request'),
]);

$checkout = new TebexCheckout('foo', 'bar');
Expand All @@ -18,16 +18,16 @@
'return_url' => 'http://foo.com',
'complete_url' => 'http://bar.com',
'custom' => [
'baz' => 'buzz'
]
'baz' => 'buzz',
],
],
items: [
[
'package' => [
'name' => 'foobar',
'price' => 12.34
]
]
'price' => 12.34,
],
],
]
);

Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Shimmer\LaravelTebexCheckout\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Shimmer\LaravelTebexCheckout\LaravelTebexCheckoutServiceProvider;

Expand Down

0 comments on commit 80ecc57

Please sign in to comment.