Skip to content

Commit 8a6f3bb

Browse files
author
Laurynas Griciunas
committed
PR changes
1 parent d7fc7ab commit 8a6f3bb

File tree

7 files changed

+42
-109
lines changed

7 files changed

+42
-109
lines changed

src/Paysera/Bundle/CodeGeneratorBundle/Service/BodyResolver.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,31 @@ public function getRequestBody(Method $method)
4242
*/
4343
public function getResponseBody(Method $method)
4444
{
45-
$successfulResponseWithBody = $this->getSuccessfulResponseWithBody($method);
46-
if ($successfulResponseWithBody === null) {
45+
$successfulResponse = $this->getSuccessfulResponse($method);
46+
if ($successfulResponse === null) {
4747
return null;
4848
}
4949

5050
try {
51-
return $successfulResponseWithBody->getBodyByType(self::BODY_JSON);
51+
return $successfulResponse->getBodyByType(self::BODY_JSON);
5252
} catch (Exception $exception) {}
5353

5454
try {
55-
$body = $successfulResponseWithBody->getBodyByType(self::BODY_JAVASCRIPT);
55+
$body = $successfulResponse->getBodyByType(self::BODY_JAVASCRIPT);
5656
$body->setType(new StringType('string'));
5757

5858
return $body;
5959
} catch (Exception $exception) {}
6060

6161
try {
62-
return $successfulResponseWithBody->getBodyByType(self::BODY_OCTET_STREAM);
62+
return $successfulResponse->getBodyByType(self::BODY_OCTET_STREAM);
6363
} catch (Exception $exception) {}
6464

6565
try {
66-
return $successfulResponseWithBody->getBodyByType(self::BODY_TEXT_CSV);
66+
return $successfulResponse->getBodyByType(self::BODY_TEXT_CSV);
6767
} catch (Exception $exception) {}
6868

69-
throw new Exception('No body found');
69+
return null;
7070
}
7171

7272
public function isRawResponse(Method $method)
@@ -104,7 +104,7 @@ public function isIterableResponse(Method $method, ApiDefinition $api)
104104
return false;
105105
}
106106

107-
private function getSuccessfulResponseWithBody(Method $method): ?Response
107+
private function getSuccessfulResponse(Method $method): ?Response
108108
{
109109
if ($method->getResponse(StatusCodeInterface::STATUS_OK) !== null) {
110110
return ($method->getResponse(StatusCodeInterface::STATUS_OK));

tests/PhpGeneratorBundle/RestClient/Fixtures/expected/transfer-surveillance-assistant/README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This library provides `ClientFactory` class, which you should use to get the API
1212
use Paysera\Test\TransferSurveillanceAssistantClient\ClientFactory;
1313

1414
$clientFactory = new ClientFactory([
15-
'base_url' => 'http://transfer-surveillance-assistant.paysera.lan/rest/v1/', // optional, in case you need a custom one.
15+
'base_url' => 'http://example.com/transfer-surveillance-assistant/rest/v1/', // optional, in case you need a custom one.
1616
'mac' => [ // use this, if API requires Mac authentication.
1717
'mac_id' => 'my-mac-id',
1818
'mac_secret' => 'my-mac-secret',
@@ -39,17 +39,6 @@ Now, that you have instance of `TransferSurveillanceAssistantClient`, you can us
3939
### Methods
4040

4141

42-
Get the generated analysis report, if it exists
43-
44-
45-
```php
46-
47-
$result = $transferSurveillanceAssistantClient->getAnalysisTaskReport($id);
48-
```
49-
---
50-
51-
52-
5342
Submit a new analysis task for processing
5443

5544

@@ -65,3 +54,12 @@ $result = $transferSurveillanceAssistantClient->createAnalysisTask($analysisTask
6554
```
6655
---
6756

57+
I am not a real endpoint
58+
59+
60+
```php
61+
62+
$transferSurveillanceAssistantClient->updateAnalysisTask();
63+
```
64+
---
65+

tests/PhpGeneratorBundle/RestClient/Fixtures/expected/transfer-surveillance-assistant/src/ClientFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class ClientFactory extends ClientFactoryAbstract
99
{
10-
const DEFAULT_BASE_URL = 'http://transfer-surveillance-assistant.paysera.lan/rest/v1/';
10+
const DEFAULT_BASE_URL = 'http://example.com/transfer-surveillance-assistant/rest/v1/';
1111

1212
protected $apiClient;
1313

tests/PhpGeneratorBundle/RestClient/Fixtures/expected/transfer-surveillance-assistant/src/Entity/AnalysisReport.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/PhpGeneratorBundle/RestClient/Fixtures/expected/transfer-surveillance-assistant/src/TransferSurveillanceAssistantClient.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,39 @@ public function withOptions(array $options)
2222
}
2323

2424
/**
25-
* Get the generated analysis report, if it exists
26-
* GET /analysis-tasks/{id}/report
25+
* Submit a new analysis task for processing
26+
* POST /analysis-tasks
2727
*
28-
* @param string $id
29-
* @return Entities\AnalysisReport
28+
* @param Entities\AnalysisTaskInput $analysisTaskInput
29+
* @return Entities\AnalysisTaskOutput
3030
*/
31-
public function getAnalysisTaskReport($id)
31+
public function createAnalysisTask(Entities\AnalysisTaskInput $analysisTaskInput)
3232
{
3333
$request = $this->apiClient->createRequest(
34-
RequestMethodInterface::METHOD_GET,
35-
sprintf('analysis-tasks/%s/report', rawurlencode($id)),
36-
null
34+
RequestMethodInterface::METHOD_POST,
35+
'analysis-tasks',
36+
$analysisTaskInput
3737
);
3838
$data = $this->apiClient->makeRequest($request);
3939

40-
return new Entities\AnalysisReport($data);
40+
return new Entities\AnalysisTaskOutput($data);
4141
}
4242

4343
/**
44-
* Submit a new analysis task for processing
45-
* POST /analysis-tasks
44+
* I am not a real endpoint
45+
* PUT /analysis-tasks
4646
*
47-
* @param Entities\AnalysisTaskInput $analysisTaskInput
48-
* @return Entities\AnalysisTaskOutput
47+
* @return null
4948
*/
50-
public function createAnalysisTask(Entities\AnalysisTaskInput $analysisTaskInput)
49+
public function updateAnalysisTask()
5150
{
5251
$request = $this->apiClient->createRequest(
53-
RequestMethodInterface::METHOD_POST,
52+
RequestMethodInterface::METHOD_PUT,
5453
'analysis-tasks',
55-
$analysisTaskInput
54+
null
5655
);
5756
$data = $this->apiClient->makeRequest($request);
5857

59-
return new Entities\AnalysisTaskOutput($data);
58+
return null;
6059
}
6160
}
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#%RAML 1.0
22
title: Transfer Surveillance Assistant
33
version: "1.0"
4-
baseUri: http://transfer-surveillance-assistant.paysera.lan/rest/v1
4+
baseUri: http://example.com/transfer-surveillance-assistant/rest/v1/
55
protocols: [HTTP]
66

77
uses:
@@ -10,7 +10,6 @@ uses:
1010
types:
1111
AnalysisTaskInput: !include types/analysis-task-input.raml
1212
AnalysisTaskOutput: !include types/analysis-task-output.raml
13-
AnalysisReport: !include types/analysis-report.raml
1413

1514
/analysis-tasks:
1615
post:
@@ -24,13 +23,9 @@ types:
2423
body:
2524
application/json:
2625
type: AnalysisTaskOutput
27-
/{id}:
28-
/report:
29-
get:
30-
description: Get the generated analysis report, if it exists
31-
responses:
32-
200:
33-
body:
34-
application/json:
35-
type: AnalysisReport
36-
26+
put:
27+
description: I am not a real endpoint
28+
responses:
29+
202:
30+
description: This is not the response you're looking for
31+
body: null

tests/PhpGeneratorBundle/RestClient/Fixtures/raml/transfer-surveillance-assistant/types/analysis-report.raml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)