Skip to content

FIX - Broken Unit Tests. #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.4, 8.3]
laravel: [12.*, 11.*, 10.*]
laravel: [12.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
testbench: 8.*
php: 8.4


name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![Latest Version on Packagist](https://img.shields.io/packagist/v/coderflexx/laravel-sendy.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-sendy)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/coderflexx/laravel-sendy/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/coderflexx/laravel-sendy/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/coderflexx/laravel-sendy/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/coderflexx/laravel-sendy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/coderflexx/laravel-sendy.svg?style=flat-square)](https://packagist.org/packages/coderflexx/laravel-sendy)

---

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^8.4",
"php": "^8.3",
"ext-curl": "*",
"ext-json": "*",
"illuminate/contracts": "^10.0||^11.0||^12.0",
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ parameters:
level: 5
paths:
- src
- config
- database
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
5 changes: 3 additions & 2 deletions src/Concerns/InteractsWithHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Coderflex\LaravelSendy\Exceptions\InvalidApiKeyException;
use Coderflex\LaravelSendy\Exceptions\InvalidApiUrlException;
use Exception;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;

/**
Expand All @@ -16,7 +17,7 @@
*/
trait InteractsWithHttpRequests
{
public function __call(string $function, array $args): mixed
public function __call(string $function, array $args): Response
{
$options = ['get', 'post', 'put', 'delete', 'patch'];
$path = $args[0] ?? null;
Expand Down Expand Up @@ -65,7 +66,7 @@ protected function sendRequest(string $type, string $request, array $data = [],
$client = Http::withHeaders(array_merge([
'Content-Type' => 'application/json',
'Accept' => 'application/json',
], $headers ?? []));
], $headers));

return $async
? $client->async()->{$type}($url, $payload)
Expand Down
1 change: 1 addition & 0 deletions src/Facades/Sendy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @method static \Coderflex\LaravelSendy\Resources\Lists lists()
* @method static \Coderflex\LaravelSendy\Resources\Brands brands()
* @method static \Coderflex\LaravelSendy\Resources\Campaigns campaigns()
* @method static mixed post(string $endpoint, array $data, bool $async = false)
*/
class Sendy extends Facade
{
Expand Down
11 changes: 8 additions & 3 deletions src/Resources/Brands.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

namespace Coderflex\LaravelSendy\Resources;

use Coderflex\LaravelSendy\Facades\Sendy;
use Coderflex\LaravelSendy\Sendy;
use Illuminate\Http\Client\Response;

class Brands
{
public function get()
public function __construct(
protected Sendy $sendy
) {}

public function get(): Response
{
return Sendy::post('/api/brands/get-brands.php');
return $this->sendy->post('/api/brands/get-brands.php');
}
}
15 changes: 10 additions & 5 deletions src/Resources/Campaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
namespace Coderflex\LaravelSendy\Resources;

use Coderflex\LaravelSendy\DTOs\Campaigns\CampaignDTO;
use Coderflex\LaravelSendy\Facades\Sendy;
use Coderflex\LaravelSendy\Sendy;
use Illuminate\Http\Client\Response;

class Campaigns
{
public function create(array $data, bool $async = false)
public function __construct(
protected Sendy $sendy
) {}

public function create(array $data, bool $async = false): Response
{
$data = CampaignDTO::validate($data);

return Sendy::post('/api/campaigns/create.php', $data, $async);
return $this->sendy->post('/api/campaigns/create.php', $data, $async);
}

public function createAndSend(array $data, bool $async = false)
public function createAndSend(array $data, bool $async = false): Response
{
$data = array_merge($data, [
'send_compaign' => 1,
]);

return Sendy::post('/api/campaigns/create.php', $data, $async);
return $this->sendy->post('/api/campaigns/create.php', $data, $async);
}
}
16 changes: 8 additions & 8 deletions src/Resources/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
namespace Coderflex\LaravelSendy\Resources;

use Coderflex\LaravelSendy\DTOs\Lists\ListsDTO;
use Coderflex\LaravelSendy\Facades\Sendy;
use Coderflex\LaravelSendy\Sendy;
use Illuminate\Http\Client\Response;

class Lists
{
/**
* Get all lists for a specific brand.
*
* @return array
*/
public function get(array $data, bool $async = false)
public function __construct(
protected Sendy $sendy
) {}

public function get(array $data, bool $async = false): Response
{
$data = ListsDTO::validate($data);

return Sendy::post('/api/lists/get-lists.php', $data, $async);
return $this->sendy->post('/api/lists/get-lists.php', $data, $async);
}
}
27 changes: 16 additions & 11 deletions src/Resources/Subscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,49 @@
use Coderflex\LaravelSendy\DTOs\Subscribers\SubscribeDTO;
use Coderflex\LaravelSendy\DTOs\Subscribers\SubscriberStatusDTO;
use Coderflex\LaravelSendy\DTOs\Subscribers\UnsubscribeDTO;
use Coderflex\LaravelSendy\Facades\Sendy;
use Coderflex\LaravelSendy\Sendy;
use Illuminate\Http\Client\Response;

class Subscribers
{
public function subscribe(array $data, bool $async = false)
public function __construct(
protected Sendy $sendy
) {}

public function subscribe(array $data, bool $async = false): Response
{
$data = SubscribeDTO::validate($data);

return Sendy::post('subscribe', $data, $async);
return $this->sendy->post('subscribe', $data, $async);
}

public function unsubscribe(array $data, bool $async = false)
public function unsubscribe(array $data, bool $async = false): Response
{
$data = UnsubscribeDTO::validate($data);

return Sendy::post('api/subscribers/unsubscribe.php', $data, $async);
return $this->sendy->post('api/subscribers/unsubscribe.php', $data, $async);
}

public function delete(array $data, bool $async = false)
public function delete(array $data, bool $async = false): Response
{
$data = DeleteSubscriberDTO::validate($data);

return Sendy::post('api/subscribers/delete.php', $data, $async);
return $this->sendy->post('api/subscribers/delete.php', $data, $async);
}

public function status(array $data, bool $async = false)
public function status(array $data, bool $async = false): Response
{
$data = SubscriberStatusDTO::validate($data);

return Sendy::post('api/subscribers/subscription-status.php', $data, $async);
return $this->sendy->post('api/subscribers/subscription-status.php', $data, $async);
}

public function count(int $listId, bool $async = false)
public function count(int $listId, bool $async = false): Response
{
$data = [
'list_id' => $listId,
];

return Sendy::post('api/subscribers/subscriber-count.php', $data, $async);
return $this->sendy->post('api/subscribers/subscriber-count.php', $data, $async);
}
}
8 changes: 4 additions & 4 deletions src/Sendy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ class Sendy

public function subscribers(): Resources\Subscribers
{
return new Resources\Subscribers;
return new Resources\Subscribers($this);
}

public function lists(): Resources\Lists
{
return new Resources\Lists;
return new Resources\Lists($this);
}

public function brands(): Resources\Brands
{
return new Resources\Brands;
return new Resources\Brands($this);
}

public function campaigns(): Resources\Campaigns
{
return new Resources\Campaigns;
return new Resources\Campaigns($this);
}
}