Skip to content

Commit 1547e70

Browse files
committed
Merge branch 'main' of github.com:coderflexx/laravel-sendy into tests-scaffolding
2 parents be28903 + 4d29f9c commit 1547e70

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/LaravelSendy.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,17 @@ protected function guzzle(string $type, string $request, array $data = [], array
8080
$mainHeaders = [
8181
'Content-Type' => 'application/json',
8282
'Accept' => 'application/json',
83-
'Authorization' => 'Bearer '.$this->apiKey,
8483
];
8584

8685
$headers = is_array($headers) && count($headers) > 0
8786
? array_merge($mainHeaders, $headers)
8887
: $mainHeaders;
8988

90-
$response = $client->$type($this->apiUrl.$request, [
89+
$response = $client->{$type}($this->apiUrl.$request, [
9190
'headers' => $headers,
92-
'body' => json_encode($data),
91+
'body' => json_encode(array_merge($data, [
92+
'api_key' => $this->apiKey,
93+
])),
9394
]);
9495

9596
$responseObject = $response->getBody()->getContents();

src/Resources/Campaigns.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ class Campaigns
99
{
1010
public function create(array $data)
1111
{
12-
$data = CompaignDTO::from($data)->toArray();
13-
14-
// validate the data
15-
// $this->validate($data);
12+
$data = CompaignDTO::validateAndCreate($data)->toArray();
1613

1714
return LaravelSendy::post('/api/campaigns/create.php', $data);
1815
}

src/Resources/Subscribers.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ class Subscribers
99
{
1010
public function subscribe(array $data)
1111
{
12-
$data = SubscribersDTO::from($data)->toArray();
13-
14-
// validate the data
12+
$data = SubscribersDTO::validateAndCreate($data)->toArray();
1513

1614
return LaravelSendy::post('subscribe', $data);
1715
}

0 commit comments

Comments
 (0)