Reports

The most relevant endpoints are located at https://api-nguc.weblink.se/swagger/#/Report.

How to get required data
  • Get the different report types that can be specified: GET /company/report/type
    The "group" key gives a hint about what optional data can be used.

    Example request:
    curl \
    -H "Authorization: Bearer {TOKEN}" \
    "https://api-nguc.weblink.se/company/report/type"
    
    Success response:
    [
    	{
    		"id": "1",
    		"name": "Queue - Missed",
    		"description": null,
    		"group": "queue",
    		"added": "2015-06-24 00:00:00",
    		"class_name": "ReportQueueMissed"
    	},
    ]
    
  • Get which fields can be used for configuring the report: GET /company/report/argument/fields
    The key of the returned object is the id of the report type except "any" which are fields that're valid for all report types.

    Example request:
    curl \
    -H "Authorization: Bearer {TOKEN}" \
    "https://api-nguc.weblink.se/company/report/argument/fields"
    
    Success response:
    {
    	"all": [
    		{
    			"key": "format",
    			"description": "The format of the emailed file?",
    			"mandatory": "1",
    			"type": "enum('html', 'csv', 'xlsx', 'pdf')"
    		},
    		{
    			"key": "email",
    			"description": "The email to send the report to?",
    			"mandatory": "1",
    			"type": "email"
    		},
    		{
    			"key": "only_when_data",
    			"description": null,
    			"mandatory": "0",
    			"type": "bool"
    		},
    		{
    			"key": "report_language",
    			"description": "Not doing anything, yet",
    			"mandatory": "0",
    			"type": "enum('en_GB')"
    		}
    	],
    	"1": [
    		{
    			"key": "queue_id",
    			"description": null,
    			"mandatory": "0",
    			"type": "pbx_queue"
    		},
    		{
    			"key": "option",
    			"description": null,
    			"mandatory": "0",
    			"type": "enum('missedCalls', 'queueRapportPerDay', 'memberRapportPerHour')"
    		}
    	],
    
How to get optional data for certain reports
  • Get the values that are valid for certain types fields: (The id is used in the different argument calls)
    • pbx_app_callback_destination: Get callback destinations
    • pbx_queue: Get company queues
    • pbx_user: Get company users
      Valid formats:
      • csv
      • html
      • pdf
      • xlsx
      Valid intervals:
      • hour
      • day
      • week
      • month

      List existing reports GET /company/report

      It's possible to set the GET variables "limit" and "limit_from" to change how many results are returned.

      Example request:
      curl \
      -H "Authorization: Bearer {TOKEN}" \
      "https://api-nguc.weblink.se/company/report?limit_from=0&limit=5"
      
      Success response:
      {
      	"count": "21",
      	"limit": 1,
      	"limit_from": 20,
      	"reports": [
      		{
      			"arguments": {
      				"format": [
      					{
      						"id": "25341",
      						"value": "csv",
      						"added": "2024-09-02 14:26:51"
      					}
      				],
      				"email": [
      					{
      						"id": "25342",
      						"value": "test@example.com",
      						"added": "2024-09-02 14:26:51"
      					}
      				]
      			}
      		}
      	]
      }
      
Commonly used endpoints

Body:

{
    "interval": "hour",
    "active": 0,
    "name": "",
    "description": "",
    "email_link_only": 0,
    "report_type_id": "1",
    "arguments": [
        {
            "key": "format",
            "value": "csv"
        },
        {
            "key": "email",
            "value": "test@example.com"
        }
    ]
}

Example:

			curl \
			-H "Authorization: Bearer {TOKEN}" \
			-H "Content-Type: application/json" \
			-d \
			'{
					"interval": "hour",
					"active": 0,
					"name": "",
					"description": "",
					"email_link_only": 0,
					"report_type_id": "1",
					"arguments": [
							{
									"key": "format",
									"value": "csv"
							},
							{
									"key": "email",
									"value": "test@example.com"
							}
					]
			}' \
			"https://api-nguc.weblink.se/company/report"
							
If successful the JSON {"id":"2613"} is returned with the id the report got in the system.

Example:

			curl \
			-H "Authorization: Bearer {TOKEN}" \
			-H "Content-Type: application/json" \
			-d \
			'{
				"key": "option",
				"value": "missedCalls"
			}' \
			"https://api-nguc.weblink.se/company/report/2613/argument"
							
If successful the JSON {"id":"25343"} is returned with the id the argument got in the system.

Same body as create report without the bottom two keys.

Example:

			curl \
			-X PATCH \
			-H "Authorization: Bearer {TOKEN}" \
			-H "Content-Type: application/json" \
			-d \
			'{
					"interval": "hour",
					"active": 0,
					"name": "Test",
					"description": "",
					"email_link_only": 0
			}' \
			"https://api-nguc.weblink.se/company/report/2613"
							
Returns an empty array.

Same jsonBody as create report argument.

Example:

			curl \
			-X PATCH \
			-H "Authorization: Bearer {TOKEN}" \
			-H "Content-Type: application/json" \
			-d \
			'{
				"key": "option",
				"value": "queueRapportPerDay"
			}' \
			"https://api-nguc.weblink.se/company/report/2613/argument/25343"
							

Example:

			curl \
			-X DELETE \
			-H "Authorization: Bearer {TOKEN}" \
			"https://api-nguc.weblink.se/company/report/2613"
							

Example:

			curl \
			-X DELETE \
			-H "Authorization: Bearer {TOKEN}" \
			"https://api-nguc.weblink.se/company/report/2613/argument/25343"
							

The e-mails used are the once that're assigned to the report as "email" arguments.

Example:

			curl \
			-H "Authorization: Bearer {TOKEN}" \
			"https://api-nguc.weblink.se/company/report/2613/send"
							

Example:

curl \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d \
'{
		"interval": "hour",
		"report_type_id": "1",
		"arguments": [
				{
						"key": "format",
						"value": "csv"
				},
				{
						"key": "email",
						"value": "test@example.com"
				}
		]
}' \
"https://api-nguc.weblink.se/company/report/download/csv"