complete endpoint tasks

This commit is contained in:
Daniel Seifert 2024-12-22 13:54:42 +01:00
bovenliggende 2e5dbcbea0
commit da7e3bf38b
Getekend door: DanielS
GPG sleutel-ID: 6A513E13AEE66170
3 gewijzigde bestanden met toevoegingen van 129 en 5 verwijderingen

Bestand weergeven

@ -42,4 +42,4 @@ $subscriber = $klicktipp->subscriber()->search($subscriberId);
|--------------------------------------------------------------------------------------|-------------------------|
| account | :ballot_box_with_check: |
| subscriber | :ballot_box_with_check: |
| tag | :white_check_mark: |
| tag | :ballot_box_with_check: |

Bestand weergeven

@ -50,4 +50,88 @@ class Subscriber extends Model
)
);
}
/**
* @throws BaseException|GuzzleException
*/
public function subscribe(
string $mailAddress,
string $listId,
string $tagId,
array $fields,
string $smsNumber
): string
{
return current(
$this->connection->requestAndParse(
'POST',
'subscriber',
[
RequestOptions::FORM_PARAMS => [
'email' => trim($mailAddress),
'listid' => trim($listId),
'tagid' => trim($tagId),
'fields' => array_filter($fields),
'smsnumber' => trim($smsNumber),
]
]
)
);
}
/**
* @throws BaseException|GuzzleException
*/
public function unsubscribe(string $mailAddress): string
{
return current(
$this->connection->requestAndParse(
'POST',
'subscriber/unsubscribe',
[
RequestOptions::FORM_PARAMS => [
'email' => trim($mailAddress)
]
]
)
);
}
/**
* @throws BaseException|GuzzleException
*/
public function tag(string $mailAddress, string $tagId): string
{
return current(
$this->connection->requestAndParse(
'POST',
'subscriber/tag',
[
RequestOptions::FORM_PARAMS => [
'email' => trim($mailAddress),
'tagid' => trim($tagId)
]
]
)
);
}
/**
* @throws BaseException|GuzzleException
*/
public function untag(string $mailAddress, string $tagId): string
{
return current(
$this->connection->requestAndParse(
'POST',
'subscriber/search',
[
RequestOptions::FORM_PARAMS => [
'email' => trim($mailAddress),
'tagid' => trim($tagId)
]
]
)
);
}
}

Bestand weergeven

@ -27,12 +27,52 @@ class Tag extends Model
{
$data = $this->connection->requestAndParse(
'GET',
'tag/'.urlencode(trim($tagId)),
[
RequestOptions::QUERY => $this->getQuery()
]
'tag/'.urlencode(trim($tagId))
);
return new TagEntity($data);
}
/**
* @throws BaseException|GuzzleException
*/
public function create(string $name): array
{
return $this->connection->requestAndParse(
'POST',
'tag/',
[
RequestOptions::FORM_PARAMS => [
'name' => trim($name)
]
]
);
}
/**
* @throws BaseException|GuzzleException
*/
public function update(string $tagId, string $newName): array
{
return $this->connection->requestAndParse(
'PUT',
'tag/'.urlencode(trim($tagId)),
[
RequestOptions::FORM_PARAMS => [
'name' => trim($newName)
]
]
);
}
/**
* @throws BaseException|GuzzleException
*/
public function delete(string $tagId): array
{
return $this->connection->requestAndParse(
'DELETE',
'tag/'.urlencode(trim($tagId))
);
}
}