assistance-engine/docs/developer.avapframework.com/Informe_operaciones_EN.md

200 lines
4.0 KiB
Markdown

Report on the number of users showing the users who have registered by
themselves and those who have registered through an affiliate.
POST: {' '}
`URL_BASE + /ws/admin.py/informesadmin`
## Receives:
All the parameters that the service receives must be indicated in the body
of the request
## Returns:
Depending on the result of the operation, this service can return two
different JSON:
### Answer JSON OK:
```javascript
{
"status"
: <boolean>
,
"codtran"
: <string>
,
"resultado"
:{' '}
{
"mensaje"
: <string>
}
,
"elapsed"
: <float>
}
```
## Where:
* `status:` Shows if the call has been successful (true) or not (false)
* `resultado:` Service answer
* `mensaje:` Indicates the email to which the report will arrive.
* `elapsed:` Operation execution time.
### Answer JSON KO:
```javascript
{
"status"
: <boolean>
,
"nivel"
: <string>
,
"message"
: <string>
,
"error"
: <string>
}
```
## Where:
* `status:` Shows if the call has been successful (true) or not (false).
* `nivel:` Error importance level.
* `message:` Error message.
* `error:` Sole error code.
## Example requests:
### Python - Requests:
```javascript
import requests
url ={' '}
"URL_BASE/ws/admin.py/informesadmin"
payload ={' '}
{
'codigo_pais'
:{' '}
'MX'
,
'id_usuario'
:{' '}
'4532'
,
'id_sesion'
:{' '}
'406-dwr5sTs_m29rnbzw9_miJQ=='
,
'informe'
:{' '}
'informeconsejo'
}
files ={' '}
[
]
headers={' '}
{
}
response = requests
.request
(
"POST"
, url
, headers
=headers
, data{' '}
= payload
, files{' '}
= files
)
print
(response
.text
.encode
(
'utf8'
)
)
```
### NodeJs - Request:
```javascript
var request = require('request');
var options = {
'method': 'POST',
'url': 'URL_BASE/ws/admin.py/informesadmin',
'headers': {},
formData: {
'codigo_pais': 'MX',
'id_usuario': '4532',
'id_sesion': '406-dwr5sTs_m29rnbzw9_miJQ==',
'informe': 'informeconsejo'
}
};
request(options, function (error, response) {{' '}
if (error) throw new Error(error);
console.log(response.body);
});
```
### JavaScript - Fetch:
```javascript
var formdata = new FormData();
formdata.append("codigo_pais", "MX");
formdata.append("id_usuario", "4532");
formdata.append("id_sesion",
"406-dwr5sTs_m29rnbzw9_miJQ==");
formdata.append("informe", "informeconsejo");
var requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow'
};
fetch("URL_BASE/ws/admin.py/informesadmin",
requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
```
### CURL:
```javascript
curl --location --request POST{' '}
'URL_BASE/ws/admin.py/informesadmin'
{' '}
\
--form
'codigo_pais=MX'
{' '}
\
--form
'id_usuario=4532'
{' '}
\
--form{' '}
'id_sesion=406-dwr5sTs_m29rnbzw9_miJQ=='
{' '}
\
--form{' '}
'informe=informeconsejo'
```
## Business logic:
In order to run this service, it is necessary to do it from a user logged
into the system who has an administrator profile. With this endpoint the
requested report is generated and sent to the email of the administrator
user who requests it.