Skip to content

Commit c121867

Browse files
committed
Renamed MemoryAccountStore to LoginAccountStore
1 parent 062099b commit c121867

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

Atomx/ApiClient.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use GuzzleHttp\Client;
55
use GuzzleHttp\Exception\RequestException;
66
use GuzzleHttp\Message\Response;
7+
use GuzzleHttp\Stream\StreamInterface;
78

89
class ApiClient {
910
protected $endpoint;
@@ -64,6 +65,12 @@ public function post($fields = [])
6465
return $this->postUrl($this->endpoint, ['json' => $fields]);
6566
}
6667

68+
/**
69+
* @param $url
70+
* @param array $options
71+
* @return string|StreamInterface
72+
* @throws ApiException
73+
*/
6774
public function postUrl($url, $options = [])
6875
{
6976
return $this->request('post', $url, $options);
@@ -133,7 +140,6 @@ public function __get($name)
133140

134141
public function fill($fields)
135142
{
136-
// TODO: Merge with the other fields
137143
$this->fields = $fields;
138144
}
139145

Atomx/AtomxClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function __construct($accountStore = null, $idOrFields = null)
2626
if ($accountStore) {
2727
$this->accountStore = $accountStore;
2828
$this->apiBase = $accountStore->getApiBase();
29+
} else if ($this->requiresToken) {
30+
throw new \InvalidArgumentException("{$this->endpoint} endpoint requires an AccountStore for the token");
2931
} else {
3032
$this->apiBase = AtomxClient::API_BASE;
3133
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use Atomx\Exceptions\TotpRequiredException;
44
use Atomx\Resources\Login;
55

6-
class MemoryAccountStore implements AccountStore {
6+
class LoginAccountStore implements AccountStore {
77
protected $token = null;
88
protected $username, $password, $totp, $apiBase;
99

Atomx/Resources/Report.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public function run($json, $timeout = 600)
2323
return new ReportStreamer($stream);
2424
}
2525

26+
/**
27+
* @param Response $response
28+
* @return \GuzzleHttp\Stream\StreamInterface|mixed|null|string
29+
* @throws ApiException
30+
*/
2631
protected function handleResponse(Response $response)
2732
{
2833
if ($response->getStatusCode() == 200) {

tests/ClientTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
use Atomx\AccountStore;
44
use Atomx\Exceptions\ApiException;
55
use Atomx\Exceptions\TotpRequiredException;
6-
use Atomx\MemoryAccountStore;
6+
use Atomx\LoginAccountStore;
77
use Atomx\Resources\Advertiser;
8+
use Atomx\Resources\Browsers;
89
use Atomx\Resources\Domain;
910
use Atomx\Resources\Login;
10-
use Atomx\Resources\Totp;
1111
use GuzzleHttp\Message\Response;
1212
use GuzzleHttp\Stream\Stream;
1313
use GuzzleHttp\Subscriber\History;
@@ -23,13 +23,22 @@ public function getPassword() { return ''; }
2323
public function getApiBase() { return 'https://api.atomx.com/v3/'; }
2424
}
2525

26-
class TestLoginAccountStore extends MemoryAccountStore {
26+
class TestLoginAccountStore extends LoginAccountStore {
2727
private $loginClient;
2828
public function setLoginClient($client) { $this->loginClient = $client; }
2929
protected function getLoginClient() { return $this->loginClient; }
3030
}
3131

3232
class ClientTest extends \PHPUnit_Framework_TestCase {
33+
/**
34+
* @expectedException \InvalidArgumentException
35+
*/
36+
public function testTokenEndpointWithoutAS()
37+
{
38+
new Advertiser();
39+
}
40+
41+
3342
public function testDiscardInvalidToken()
3443
{
3544
$store = new TestAccountStore();

0 commit comments

Comments
 (0)