-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.php
More file actions
126 lines (115 loc) · 3.51 KB
/
Account.php
File metadata and controls
126 lines (115 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?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
*/
declare(strict_types=1);
namespace D3\KlicktippPhpClient\Resources;
use D3\KlicktippPhpClient\Entities\Account as AccountEntity;
use D3\KlicktippPhpClient\Exceptions\CommunicationException;
use D3\KlicktippPhpClient\Exceptions\ResponseContentException;
use GuzzleHttp\RequestOptions;
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';
/**
* @throws CommunicationException
* @throws ResponseContentException
*/
public function login(): array
{
return $this->connection->requestAndParse(
'POST',
'account/login.json',
[
RequestOptions::FORM_PARAMS => [
self::USERNAME => $this->connection->getClientKey(),
self::PASSWORD => $this->connection->getSecretKey(),
],
]
);
}
/**
* @throws CommunicationException
* @throws ResponseContentException
*/
public function logout(): bool
{
$response = $this->connection->requestAndParse(
'POST',
'account/logout.json'
);
return (bool)current($response);
}
/**
* @throws CommunicationException
* @throws ResponseContentException
*/
public function get(): array
{
return $this->connection->requestAndParse(
'GET',
'account.json'
);
}
/**
* @throws CommunicationException
*/
public function getEntity(): AccountEntity
{
return new AccountEntity($this->get(), $this);
}
/**
* @throws CommunicationException
* @throws ResponseContentException
*/
public function update(): bool
{
return (bool) current(
$this->connection->requestAndParse(
'GET',
'account.json'
)
);
}
}