Skip to content

Commit 2bd26ee

Browse files
Add RequestTask documentation
1 parent 8fc4aa1 commit 2bd26ee

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ CleverAge\RestProcessBundle\CleverAgeRestProcessBundle::class => ['all' => true]
2222
## Reference
2323

2424
- Tasks
25-
- [RequestTask]
25+
- [RequestTask](reference/tasks/request_task.md)
2626
- Transformers
2727
- [RequestTransformer]
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
RequestTask
2+
===============
3+
4+
Call a Rest Request and get result.
5+
6+
Task reference
7+
--------------
8+
9+
* **Client Service Interface**: `CleverAge\RestProcessBundle\Client\ClientInterface`
10+
* **Task Service**: `CleverAge\RestProcessBundle\Task\RequestTask`
11+
12+
Accepted inputs
13+
---------------
14+
15+
`array`: inputs are merged with task defined options.
16+
17+
Possible outputs
18+
----------------
19+
20+
`string`: the result content of the rest call.
21+
22+
Options
23+
-------
24+
25+
### For Client
26+
27+
| Code | Type | Required | Default | Description |
28+
|--------|----------|:--------:|---------|------------------------------------------------|
29+
| `code` | `string` | **X** | | Service identifier, used by Task client option |
30+
| `uri` | `string` | **X** | | Base uri, concatenated with Task `url` |
31+
32+
### For Task
33+
34+
| Code | Type | Required | Default | Description |
35+
|-----------------------|-----------------------------|:--------:|--------------------|------------------------------------------------------------------------------------------|
36+
| `client` | `string` | **X** | | `ClientInterface` service identifier |
37+
| `url` | `string` | **X** | | Relative url to call |
38+
| `method` | `string` | **X** | | HTTP method from `['HEAD', 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'TRACE', 'PATCH']` |
39+
| `headers` | `array` | | `[]` | |
40+
| `url_parameters` | `array` | | `[]` | Search/Replace data on `url` |
41+
| `data` | `array`, `string` or `null` | | `null` | Treated as `body`, `query` or `json` on HttpClient, depending on `method` and `sends` |
42+
| `sends` | `string` | | `application/json` | `Content-Type` header, if value is not empty |
43+
| `expects` | `string` | | `application/json` | `Accept` header, if value is not empty |
44+
| `valid_response_code` | `array` | | `[200]` | One or more [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) |
45+
| `log_response` | `bool` | | `false` | |
46+
47+
Examples
48+
--------
49+
50+
### Client
51+
52+
```yaml
53+
services:
54+
app.cleverage_rest_process.client.apicarto_ign:
55+
class: CleverAge\RestProcessBundle\Client\Client
56+
bind:
57+
$code: 'domain_sample'
58+
$uri: 'https://domain/api'
59+
tags:
60+
- { name: cleverage.rest.client }
61+
```
62+
63+
### Task
64+
65+
```yaml
66+
# Task configuration level
67+
code:
68+
service: '@CleverAge\RestProcessBundle\Task\RequestTask'
69+
error_strategy: 'stop'
70+
options:
71+
client: domain_sample
72+
url: '/sample/{parameter}'
73+
method: 'GET'
74+
url_parameters: { parameter: '{{ parameter }}' }
75+
```
76+
77+
```yaml
78+
# Task configuration level
79+
code:
80+
service: '@CleverAge\RestProcessBundle\Task\RequestTask'
81+
error_strategy: 'stop'
82+
options:
83+
client: domain_sample
84+
url: '/sample'
85+
method: 'POST'
86+
data: # May be a json string or an array
87+
parameter_1:
88+
parameter_11: "eleven"
89+
array: [-1, 666]
90+
```

0 commit comments

Comments
 (0)