084d1063 by fehrlich

update guzzle

1 parent 18600cf5
vendor
\ No newline at end of file
vendor
.dccache
......
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "./vendor/bin/phpunit",
"port": 0,
"runtimeArgs": [
// "-dxdebug.start_with_request=yes",
"tests",
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
\ No newline at end of file
namespace: Tests
support_namespace: Support
# suite config
suites:
api:
actor: ApiTester
path: .
modules:
enabled:
- REST:
url: http://localhost/api
depends: PhpBrowser
step_decorators:
- \Codeception\Step\AsJson
paths:
tests: tests
output: tests/_output
data: tests/Support/Data
support: tests/Support
settings:
shuffle: false
lint: true
\ No newline at end of file
......@@ -9,14 +9,17 @@
}
],
"require": {
"guzzlehttp/guzzle-services": "^1.1",
"guzzlehttp/oauth-subscriber": "^0.3.0",
"guzzlehttp/guzzle": "^6.3"
"guzzlehttp/guzzle-services": "^1.3",
"guzzlehttp/oauth-subscriber": "^0.6.0",
"guzzlehttp/guzzle": "^7.4"
},
"license": "MIT",
"autoload": {
"psr-4": {
"fehrlich\\ImmoScoutAPI\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^9.5"
}
}
}
\ No newline at end of file
......
This diff could not be displayed because it is too large.
......@@ -127,13 +127,20 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return static
*/
public static function createClient($key, $secret, $authorized = true)
{
public static function createClient(
$key,
$secret,
$authorized = true,
callable $commandToRequestTransformer = null,
callable $responseToResultTransformer = null,
HandlerStack $commandHandlerStack = null,
array $config = []) {
$token = '';
$token_secret = '';
if ($authorized) {
$tokenArray = static::restoreAccessToken();
if($tokenArray && is_array($tokenArray)){
if ($tokenArray && is_array($tokenArray)) {
$token = $tokenArray[0];
$token_secret = $tokenArray[1];
}
......@@ -156,7 +163,13 @@ abstract class ImmoScoutAPI extends GuzzleClient
'auth' => 'oauth',
]);
$newGuzzleClient = new static($client, new Description([]));
$newGuzzleClient = new static(
$client, new Description([]),
$commandToRequestTransformer,
$responseToResultTransformer,
$commandHandlerStack,
$config
);
$newGuzzleClient->client = $client;
$newGuzzleClient->oAuth = $oAuth;
$newGuzzleClient->consumerKey = $key;
......@@ -551,7 +564,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
{
try {
return json_decode((string) $res->getBody(), true);
} catch (\Exception $ex) {
} catch (\Exception$ex) {
throw new InvalidResponse('invalid json response');
}
}
......@@ -724,7 +737,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @param string $reId realestate id used by is24 *
*/
public function delete($reId)
public function deleteRealestate($reId)
{
$res = $this->callUserMethod('realestate/' . $reId, 'DELETE');
......
<?php
use fehrlich\ImmoScoutAPI\ImmoScoutAPI;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
class TestScoutAPI extends ImmoScoutAPI
{
public $token;
public $secret;
protected static $stack = null;
public static $accessToken;
public static $accessSecret;
public static function setStack($stack)
{
TestScoutAPI::$stack = $stack;
}
public function saveRequestToken($token, $secret)
{
}
public function restoreRequestToken()
{
return [
"myToken",
"mySecret",
];
}
public function saveAccessToken($token, $secret)
{
}
public static function restoreAccessToken()
{
return [
"myAaccessToken",
"myAccessSecret",
];
}
// public static function createClient($key,
// $secret,
// $authorized = true,
// callable $commandToRequestTransformer = null,
// callable $responseToResultTransformer = null,
// HandlerStack $commandHandlerStack = null,
// array $config = []) {
// return new Client(['handler' => self::$stack]);
// }
}
final class APITest extends TestCase
{
public function setUp(): void
{
parent::setUp();
$mock = new MockHandler([
new Response(200, ['X-Foo' => 'Bar'], 'Hello, World'),
new Response(202, ['Content-Length' => 0]),
new RequestException('Error Communicating with Server', new Request('GET', 'test')),
]);
$handlerStack = HandlerStack::create($mock);
$container = [];
$history = Middleware::history($container);
$handlerStack->push($history);
$this->client = TestScoutAPI::createClient("myKey", "mySecret");
$this->client->client = new Client([
'base_uri' => "http://localhost",
'handler' => $handlerStack,
'verify' => false,
]);
}
public function testDefaultDomain()
{
self::assertEquals($this->client->getDomain(), "sandbox-immobilienscout24.de");
}
public function testSwichingSandbox()
{
$this->client->useSandbox();
self::assertEquals($this->client->getDomain(), "sandbox-immobilienscout24.de");
$this->client->dontUseSandbox();
self::assertEquals($this->client->getDomain(), "immobilienscout24.de");
}
// public function testSetUser()
// {
// $this->client->setUser("test");
// self::assertEquals($this->client->user, "test");
// }
// public function testVerifyApplication()
// {
// $this->client->verifyApplication("myUrl");
// }
}
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!