Skip to content

Commit 8fc4aa1

Browse files
RequestTask : query_parameters option is deprecated, use data instead. Add missing throw Exception to allow use error_strategy: *.
1 parent eb8e6e2 commit 8fc4aa1

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ v2.0
88
* [#4](https://github.com/cleverage/rest-process-bundle/issues/4) Update services according to Symfony best practices.
99
Services should not use autowiring or autoconfiguration. Instead, all services should be defined explicitly.
1010
Services must be prefixed with the bundle alias instead of using fully qualified class names => `cleverage_rest_process`
11-
11+
* RequestTask : `query_parameters` option is deprecated, use `data` instead
1212

1313
### Changes
1414

src/Client/Client.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ protected function configureOptions(OptionsResolver $resolver): void
9393
$resolver->setDefaults(
9494
[
9595
'method' => 'GET',
96-
'url_parameters' => [],
97-
'query_parameters' => [],
98-
'headers' => [],
9996
'sends' => 'application/json',
10097
'expects' => 'application/json',
101-
'body' => null,
98+
'url_parameters' => [],
99+
'headers' => [],
100+
'data' => null,
102101
]
103102
);
104103

@@ -107,8 +106,8 @@ protected function configureOptions(OptionsResolver $resolver): void
107106
$resolver->setAllowedTypes('sends', ['string']);
108107
$resolver->setAllowedTypes('expects', ['string']);
109108
$resolver->setAllowedTypes('url_parameters', ['array']);
110-
$resolver->setAllowedTypes('query_parameters', ['array']);
111109
$resolver->setAllowedTypes('headers', ['array']);
110+
$resolver->setAllowedTypes('data', ['array', 'string', 'null']);
112111
}
113112

114113
protected function getOptions(array $options = []): array
@@ -135,11 +134,11 @@ protected function getRequestOptions(array $options = []): array
135134
$requestOptions['headers']['Accept'] = $options['expects'];
136135
}
137136
if ('POST' === $options['method'] && 'application/json' === $options['sends']) {
138-
$requestOptions['json'] = $options['body'];
137+
$requestOptions['json'] = $options['data'];
139138
} elseif ('GET' === $options['method']) {
140-
$requestOptions['query'] = $options['query_parameters'];
139+
$requestOptions['query'] = $options['data'];
141140
} else {
142-
$requestOptions['body'] = $options['body'];
141+
$requestOptions['body'] = $options['data'];
143142
}
144143

145144
return $requestOptions;

src/Task/RequestTask.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function execute(ProcessState $state): void
8080
]
8181
);
8282

83-
return;
83+
throw $e;
8484
}
8585
}
8686

@@ -101,9 +101,9 @@ protected function configureOptions(OptionsResolver $resolver): void
101101
[
102102
'headers' => [],
103103
'url_parameters' => [],
104-
'query_parameters' => [],
105-
'sends' => 'json',
106-
'expects' => 'json',
104+
'data' => null,
105+
'sends' => 'application/json',
106+
'expects' => 'application/json',
107107
'valid_response_code' => [200],
108108
'log_response' => false,
109109
]
@@ -121,13 +121,13 @@ protected function getRequestOptions(ProcessState $state): array
121121
$options = $this->getOptions($state);
122122

123123
$requestOptions = [
124-
'method' => $options['method'],
125124
'url' => $options['url'],
125+
'method' => $options['method'],
126126
'headers' => $options['headers'],
127127
'url_parameters' => $options['url_parameters'],
128-
'query_parameters' => $options['query_parameters'],
129128
'sends' => $options['sends'],
130129
'expects' => $options['expects'],
130+
'data' => $options['data'],
131131
];
132132

133133
$input = $state->getInput() ?: [];

0 commit comments

Comments
 (0)