Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add report api doc #180

Open
wants to merge 4 commits into
base: 5.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
366 changes: 366 additions & 0 deletions docs/rest_api/reports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,369 @@
* - ``scheduleMonthFrequency``
- string or null
- Frequency for the scheduler

Create Report

Check warning on line 313 in docs/rest_api/reports.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Headings] 'Create Report' should use sentence-style capitalization. Raw Output: {"message": "[Google.Headings] 'Create Report' should use sentence-style capitalization.", "location": {"path": "docs/rest_api/reports.rst", "range": {"start": {"line": 313, "column": 1}}}, "severity": "WARNING"}
***************

.. vale on

.. code-block:: php

<?php

$data = array(
"name" => "New Report",
"description" => "A new report",
"system" => true,
"isScheduled" => false,
"source" => "email.stats",
"columns" => array(
"es.date_sent",
"es.date_read",
"e.subject",
"es.email_address",
"e.id"
),
"filters" => array(
array(
"column" => "e.is_published",
"condition" => "eq",
"value" => "1"
)
),
"tableOrder" => array(
array(
"column" => "es.date_sent",
"direction" => "ASC"
)
),
"graphs" => array(
"mautic.email.graph.line.stats",
"mautic.email.graph.pie.ignored.read.failed",
"mautic.email.table.most.emails.read",
"mautic.email.table.most.emails.sent",
"mautic.email.table.most.emails.read.percent",
"mautic.email.table.most.emails.failed"
),
"groupBy" => null,
"settings" => array(),
"scheduleUnit" => null,
"toAddress" => null,
"scheduleDay" => null,
"scheduleMonthFrequency" => null
);

$report = $reportApi->create($data);

Create a new Report.

.. vale off

**HTTP Request**

.. vale on

``POST /reports/new``

**POST parameters**

.. list-table::
:header-rows: 1

* - Name
- Type
- Description
* - ``name``
- string
- The Report name
* - ``description``
- string
- The Report description
* - ``system``
- boolean
- If true then the Report is visible to all Users. If ``false`` then only creator can see this Report
* - ``isScheduled``
- boolean
- Scheduled Reports send Report Emails as the User defines
* - ``source``
- string
- Report data source type
* - ``columns``
- array
- List of selected columns for this particular Report
* - ``filters``
- array
- Filters applied on this Report
* - ``tableOrder``
- array
- Ordering applied on this Report
* - ``graphs``
- array
- Graphs defined for this Report. API won't return graphs
* - ``groupBy``
- array
- Group by rules applied for this Report
* - ``settings``
- array
- Additional settings for the UI layout
* - ``aggregators``
- array
- Aggregation rules applied on this Report
* - ``scheduleUnit``
- string or null
- Unit for the scheduler
* - ``toAddress``
- string or null
- Email address for the scheduler
* - ``scheduleDay``
- string or null
- Day for the scheduler
* - ``scheduleMonthFrequency``
- string or null
- Frequency for the scheduler


**Response**

``Expected Response Code: 201``

.. code-block:: json

{
"report":
{
"id": 13,
"name": "Brand New Report",
"description": "A new report",
"system": true,
"isScheduled": true,
"source": "email.stats",
"columns": [
"es.date_sent",
"es.date_read",
"e.subject",
"es.email_address",
"e.id"
],
"filters": [],
"tableOrder": [
{
"column": "es.date_sent",
"direction": "ASC"
}
],
"graphs": [
"mautic.email.graph.line.stats",
"mautic.email.graph.pie.ignored.read.failed",
"mautic.email.table.most.emails.read",
"mautic.email.table.most.emails.sent",
"mautic.email.table.most.emails.read.percent",
"mautic.email.table.most.emails.failed"
],
"groupBy": [],
"settings": {
"showGraphsAboveTable": null,
"showDynamicFilters": null,
"hideDateRangeFilter": null
},
"aggregators": [],
"scheduleUnit": "DAILY",
"toAddress": "test2@mailinator.com",
"scheduleDay": null,
"scheduleMonthFrequency": null
}
}

**Report Properties**

**Properties**

Same as `List Reports <#list-reports>`_.

.. vale off

Edit Report
*************

.. vale on

.. code-block:: php

<?php

$id = 1;
$data = array(
'name' => 'Updated Report'
);

// Create new a Report if ID 1 isn't found?
$createIfNotFound = true;

$report = $reportApi->edit($id, $data, $createIfNotFound);

Edit a new Report. Note that this supports PUT or PATCH depending on the desired behavior.

**PUT** creates a Report if the given ID doesn't exist and clears all the Report information, adds the information from the request.
**PATCH** fails if the Report with the given ID doesn't exist and updates the Report field values with the values from the request.

.. vale off

**HTTP Request**

.. vale on

To edit a Report and return a 404 if the Report isn't found:

``PATCH /reports/ID/edit``

To edit a Report and create a new one if the Report isn't found:

``PUT /reports/ID/edit``

**POST parameters**

.. list-table::
:header-rows: 1

* - Name
- Type
- Description
* - ``name``
- string
- The Report name
* - ``description``
- string
- The Report description
* - ``system``
- boolean
- If true then the Report is visible to all Users. If ``false`` then only creator can see this Report
* - ``isScheduled``
- boolean
- Scheduled Reports send Report Emails as the User defines
* - ``source``
- string
- Report data source type
* - ``columns``
- array
- List of selected columns for this particular Report
* - ``filters``
- array
- Filters applied on this Report
* - ``tableOrder``
- array
- Ordering applied on this Report
* - ``graphs``
- array
- Graphs defined for this Report. API won't return graphs
* - ``groupBy``
- array
- Group by rules applied for this Report
* - ``settings``
- array
- Additional settings for the UI layout
* - ``aggregators``
- array
- Aggregation rules applied on this Report
* - ``scheduleUnit``
- string or null
- Unit for the scheduler
* - ``toAddress``
- string or null
- Email address for the scheduler
* - ``scheduleDay``
- string or null
- Day for the scheduler
* - ``scheduleMonthFrequency``
- string or null
- Frequency for the scheduler


**Response**

If using ``PUT``, the expected response code is ``200`` if editing the Report or ``201`` if creating the Report.

If ``PATCH``, the expected response code is ``200``.

.. code-block:: json

{
"report":
{
"id": 13,
"name": "Brand New Report",
"description": "A new report",
"system": true,
"isScheduled": true,
"source": "email.stats",
"columns": [
"es.date_sent",
"es.date_read",
"e.subject",
"es.email_address",
"e.id"
],
"filters": [],
"tableOrder": [
{
"column": "es.date_sent",
"direction": "ASC"
}
],
"graphs": [
"mautic.email.graph.line.stats",
"mautic.email.graph.pie.ignored.read.failed",
"mautic.email.table.most.emails.read",
"mautic.email.table.most.emails.sent",
"mautic.email.table.most.emails.read.percent",
"mautic.email.table.most.emails.failed"
],
"groupBy": [],
"settings": {
"showGraphsAboveTable": null,
"showDynamicFilters": null,
"hideDateRangeFilter": null
},
"aggregators": [],
"scheduleUnit": "DAILY",
"toAddress": "test2@mailinator.com",
"scheduleDay": null,
"scheduleMonthFrequency": null
}
}

**Properties**

Same as `List Reports <#list-reports>`_.

.. vale off

Delete Report
***************

.. vale on

.. code-block:: php

<?php

$report = $reportApi->delete($id);

Delete a Report.

.. vale off

**HTTP Request**

.. vale on

``DELETE /reports/ID/delete``

**Response**

``Expected Response Code: 200``

**Properties**

Same as `List Reports <#list-reports>`_.

.. vale off