127 lignes
3.5 KiB
PHP
Brut Vue normale Historique

2024-12-20 23:45:55 +01:00
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
2025-01-05 15:20:56 +01:00
declare(strict_types=1);
2024-12-20 23:45:55 +01:00
namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Account as AccountEntity;
2025-01-08 15:29:20 +01:00
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
2024-12-21 19:25:33 +01:00
use GuzzleHttp\RequestOptions;
2024-12-20 23:45:55 +01:00
class Account extends Model
{
public const UID = 'uid';
public const STATUS = 'status';
public const TIER = 'tier';
public const USERGROUP = 'usergroup';
public const EMAIL = 'email';
public const FIRSTNAME = 'firstname';
public const LASTNAME = 'lastname';
public const COMPANY = 'company';
public const WEBSITE = 'website';
public const STREET = 'street';
public const CITY = 'city';
public const STATE = 'state';
public const ZIP = 'zip';
public const COUNTRY = 'country';
public const PHONE = 'phone';
public const FAX = 'fax';
public const AFFILIATE_ID = 'affid';
public const ACCESS_RIGHTS = 'access';
public const SENDERS = 'senders';
public const GMAIL_PREVIEW = 'gmailPreview';
public const LIMITS = 'limits';
public const PREFERENCES = 'preferences';
public const SETTINGS = 'settings';
public const SHOW_OTHER_ACCOUNT_INFO = 'showOtherAccountInfo';
public const SHOW_SUPPORT_INFO = 'showSupportInfo';
public const SUPPORT = 'support';
public const LANGUAGE = 'language';
public const SEGMENTS = 'segments';
public const CUSTOMER_DATA = 'customerData';
public const SUBSCRIPTION_INFO = 'subscriptionInfo';
public const ACTIVE_PAYMENTS = 'activePayments';
public const USERNAME = 'username';
public const PASSWORD = 'password';
2024-12-20 23:45:55 +01:00
/**
2025-01-08 15:29:20 +01:00
* @throws CommunicationException
* @throws ResponseContentException
2024-12-20 23:45:55 +01:00
*/
public function login(): array
{
return $this->connection->requestAndParse(
2024-12-20 23:45:55 +01:00
'POST',
'account/login.json',
2024-12-20 23:45:55 +01:00
[
2024-12-21 19:25:33 +01:00
RequestOptions::FORM_PARAMS => [
self::USERNAME => $this->connection->getClientKey(),
self::PASSWORD => $this->connection->getSecretKey(),
],
2024-12-20 23:45:55 +01:00
]
);
}
/**
2025-01-08 15:29:20 +01:00
* @throws CommunicationException
* @throws ResponseContentException
2024-12-20 23:45:55 +01:00
*/
public function logout(): bool
{
$response = $this->connection->requestAndParse(
'POST',
'account/logout.json'
2024-12-20 23:45:55 +01:00
);
return (bool)current($response);
2024-12-20 23:45:55 +01:00
}
/**
2025-01-08 15:29:20 +01:00
* @throws CommunicationException
* @throws ResponseContentException
*/
public function get(): array
{
return $this->connection->requestAndParse(
'GET',
'account.json'
);
}
/**
2025-01-08 15:29:20 +01:00
* @throws CommunicationException
*/
public function getEntity(): AccountEntity
{
return new AccountEntity($this->get(), $this);
}
/**
2025-01-08 15:29:20 +01:00
* @throws CommunicationException
* @throws ResponseContentException
*/
public function update(): bool
{
return (bool) current(
$this->connection->requestAndParse(
'GET',
'account.json'
)
);
}
2024-12-20 23:45:55 +01:00
}