Skip to content

Commit 115b8e0

Browse files
committed
feat: add bounces endpoint
1 parent c985607 commit 115b8e0

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/Helpers/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private function call(string $method = 'GET', string $endPoint = '', array $para
1616

1717
$queryOrJson = $method === 'GET' ? 'query' : 'json';
1818
$client = new Client();
19-
$endPoint = 'job/'.$endPoint;
19+
$endPoint = $endPoint;
2020
$newJob = $client->request($method, config('listboss.endpoint').$endPoint, [
2121
$queryOrJson => $params,
2222
'headers' => [

src/Helpers/Job.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ public function save(): void
4242
$params = ['subject' => $this->subject, 'content' => $this->content];
4343
if ($this->id === null) {
4444
// Create new
45-
$result = $this->call('POST', '', $params, updateSelf: true);
45+
$result = $this->call('POST', 'job/', $params, updateSelf: true);
4646
} else {
4747
// Update
48-
$result = $this->call('PUT', (string) $this->id, $params);
48+
$result = $this->call('PUT', 'job/'.(string) $this->id, $params);
4949
}
5050
}
5151

5252
public function start(array $list)
5353
{
5454
$parameters = ['recipients' => $list];
5555

56-
return $this->call(method: 'POST', endPoint: $this->id.'/start', params: $parameters, updateSelf: true);
56+
return $this->call(method: 'POST', endPoint: 'job/'. $this->id.'/start', params: $parameters, updateSelf: true);
5757
}
5858

5959
public function result(string $sort = null, int $page = 1, string $direction = 'desc', string $query = null): object
@@ -70,15 +70,15 @@ public function result(string $sort = null, int $page = 1, string $direction = '
7070
}
7171

7272
return $this->call(
73-
endPoint: $this->id.'/result',
73+
endPoint: 'job/'.$this->id.'/result',
7474
params: $params,
7575
updateSelf: true
7676
);
7777
}
7878

7979
public function status(): ?JobStatus
8080
{
81-
$status = $this->call(endPoint: $this->id.'/status', updateSelf: true);
81+
$status = $this->call(endPoint: 'job/'.$this->id.'/status', updateSelf: true);
8282

8383
$this->statusInfo = $status;
8484

@@ -101,7 +101,7 @@ public function preview(string $email, array $params = []): bool
101101
}
102102
$params = ['recipient' => $email, 'parameters' => (object) $params];
103103

104-
$this->call('POST', $this->id.'/preview', $params, updateSelf: true);
104+
$this->call('POST', 'job/'.$this->id.'/preview', $params, updateSelf: true);
105105

106106
return true;
107107
}

src/Helpers/ListBoss.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ListBoss
1616
public function list(): array
1717
{
1818
$jobs = [];
19-
$jobCall = $this->call(method: 'GET', endPoint: '/');
19+
$jobCall = $this->call(method: 'GET', endPoint: 'job/');
2020
if (isset($jobCall->jobs)) {
2121
foreach ($jobCall->jobs as $job) {
2222
$jobObject = new Job($job->id, subject: $job->subject, status: JobStatus::tryFromName($job->status));
@@ -30,6 +30,11 @@ public function list(): array
3030

3131
public function recipient(int $list, int $recipient): object
3232
{
33-
return $this->call(method: 'GET', endPoint: $list.'/recipient/'.$recipient);
33+
return $this->call(method: 'GET', endPoint: 'job/'.$list.'/recipient/'.$recipient);
34+
}
35+
36+
public function bounces(): object
37+
{
38+
return $this->call(method: 'GET', endPoint: 'bounces');
3439
}
3540
}

0 commit comments

Comments
 (0)