Commit 8c8baa05 authored by Dzulfqar Ridha's avatar Dzulfqar Ridha

update reporting

parent 644eeaf7
<?php
/**
* Created by PhpStorm.
* User: gets
* Date: 4/4/2019
* Time: 3:24 PM
*/
namespace App\Http\Controllers;
use App\Classes\MResponse;
class ApplicationController extends BaseController
{
public function callsDevActivityForService(){
$mResponse = new MResponse();
$statusCode = 200;
try {
$response = $this->masheryClient()->request('GET', 'https://api.mashery.com/v3/rest/reports/calls/developer_activity/service/yn7qb677qd3734sfd8wj2uzy', [
'query' => [
'start_date' => '2019-02-01T00%3A00%3A00Z',
'end_date' => '2019-02-07T00%3A00%3A00Z',
'format' => 'csv',
'limit' => '1000'
]
]);
$resBody = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() != 200) {
$statusCode = $response->getStatusCode();
$mResponse->message = $resBody;
} else {
$mResponse->success = true;
$mResponse->message = 'success';
$mResponse->data = $resBody;
}
} catch (\Exception $e) {
$statusCode = 500;
$mResponse->message = $e->getMessage();
}
return response()->json($mResponse, $statusCode);
}
public function callsStatusForService(){
$mResponse = new MResponse();
$statusCode = 200;
try {
$response = $this->masheryClient()->request('GET', 'https://api.mashery.com/v3/rest/reports/calls/status/service/yn7qb677qd3734sfd8wj2uzy', [
'query' => [
'start_date' => '2019-02-01T00%3A00%3A00Z',
'end_date' => '2019-02-07T00%3A00%3A00Z',
'format' => 'csv',
]
]);
$resBody = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() != 200) {
$statusCode = $response->getStatusCode();
$mResponse->message = $resBody;
} else {
$mResponse->success = true;
$mResponse->message = 'success';
$mResponse->data = $resBody;
}
} catch (\Exception $e) {
$statusCode = 500;
$mResponse->message = $e->getMessage();
}
return response()->json($mResponse, $statusCode);
}
public function callsMethodsForService(){
$mResponse = new MResponse();
$statusCode = 200;
try {
$response = $this->masheryClient()->request('GET', 'https://api.mashery.com/v3/rest/reports/calls/methods/service/yn7qb677qd3734sfd8wj2uzy', [
'query' => [
'start_date' => '2019-02-01T00%3A00%3A00Z',
'end_date' => '2019-02-07T00%3A00%3A00Z',
'format' => 'csv',
'method_limit' => '5',
]
]);
$resBody = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() != 200) {
$statusCode = $response->getStatusCode();
$mResponse->message = $resBody;
} else {
$mResponse->success = true;
$mResponse->message = 'success';
$mResponse->data = $resBody;
}
} catch (\Exception $e) {
$statusCode = 500;
$mResponse->message = $e->getMessage();
}
return response()->json($mResponse, $statusCode);
}
public function callsStatusForServiceForDev(){
$mResponse = new MResponse();
$statusCode = 200;
try {
$response = $this->masheryClient()->request('GET', 'https://api.mashery.com/v3/rest/reports/calls/status/service/yn7qb677qd3734sfd8wj2uzy/developer/q5qkbdsuza46gyvp5htp8xga', [
'query' => [
'start_date' => '2019-02-01T00%3A00%3A00Z',
'end_date' => '2019-02-07T00%3A00%3A00Z',
'format' => 'csv'
]
]);
$resBody = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() != 200) {
$statusCode = $response->getStatusCode();
$mResponse->message = $resBody;
} else {
$mResponse->success = true;
$mResponse->message = 'success';
$mResponse->data = $resBody;
}
} catch (\Exception $e) {
$statusCode = 500;
$mResponse->message = $e->getMessage();
}
return response()->json($mResponse, $statusCode);
}
public function callsMethodsForServiceForDev(){
$mResponse = new MResponse();
$statusCode = 200;
try {
$response = $this->masheryClient()->request('GET', 'https://api.mashery.com/v3/rest/reports/calls/methods/service/yn7qb677qd3734sfd8wj2uzy/developer/q5qkbdsuza46gyvp5htp8xga', [
'query' => [
'start_date' => '2019-02-01T00%3A00%3A00Z',
'end_date' => '2019-02-07T00%3A00%3A00Z',
'format' => 'csv'
]
]);
$resBody = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() != 200) {
$statusCode = $response->getStatusCode();
$mResponse->message = $resBody;
} else {
$mResponse->success = true;
$mResponse->message = 'success';
$mResponse->data = $resBody;
}
} catch (\Exception $e) {
$statusCode = 500;
$mResponse->message = $e->getMessage();
}
return response()->json($mResponse, $statusCode);
}
public function callsErrocodesForServiceForDev(){
$mResponse = new MResponse();
$statusCode = 200;
try {
$response = $this->masheryClient()->request('GET', 'https://api.mashery.com/v3/rest/reports/calls/errorcodes/service/yn7qb677qd3734sfd8wj2uzy/developer/q5qkbdsuza46gyvp5htp8xga', [
'query' => [
'start_date' => '2019-02-01T00%3A00%3A00Z',
'end_date' => '2019-02-07T00%3A00%3A00Z',
'format' => 'csv',
'errorcode_limit' => '5',
]
]);
$resBody = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() != 200) {
$statusCode = $response->getStatusCode();
$mResponse->message = $resBody;
} else {
$mResponse->success = true;
$mResponse->message = 'success';
$mResponse->data = $resBody;
}
} catch (\Exception $e) {
$statusCode = 500;
$mResponse->message = $e->getMessage();
}
return response()->json($mResponse, $statusCode);
}
}
......@@ -30,10 +30,10 @@ $router->group(['middleware' => 'client.auth'], function () use ($router) {
$router->group(['prefix' => 'application'], function () use ($router) {
$router->post('create', 'ApplicationController@create');
$router->post('update', 'ApplicationController@update');
$router->post('delete', 'ApplicationController@delete');
$router->post('by-userid', 'ApplicationController@getByUserId');
$router->post('by-appid', 'ApplicationController@getByAppId');
$router->put('update', 'ApplicationController@update');
$router->del('delete', 'ApplicationController@delete');
$router->get('by-userid', 'ApplicationController@getByUserId');
$router->get('by-appid', 'ApplicationController@getByAppId');
});
$router->group(['prefix' => 'package'], function () use ($router) {
......@@ -44,10 +44,19 @@ $router->group(['middleware' => 'client.auth'], function () use ($router) {
$router->group(['prefix' => 'packageKey'], function () use ($router) {
$router->post('create', 'PackageKeyController@create');
$router->post('activate', 'PackageKeyController@activate');
$router->post('disable', 'PackageKeyController@disable');
$router->post('delete', 'PackageKeyController@delete');
$router->post('by-username', 'PackageKeyController@getByUser');
$router->post('update-plan', 'PackageKeyController@updatePlan');
$router->put('activate', 'PackageKeyController@activate');
$router->put('disable', 'PackageKeyController@disable');
$router->del('delete', 'PackageKeyController@delete');
$router->get('by-username', 'PackageKeyController@getByUser');
$router->put('update-plan', 'PackageKeyController@updatePlan');
});
$router->group(['prefix' => 'report'], function () use ($router) {
$router->get('devact-serv', 'ReportingController@callsDevActivityForService');
$router->get('status-serv', 'ReportingController@callsStatusForService');
$router->get('method-serv', 'ReportingController@callsMethodsForService');
$router->get('status-serv-dev', 'ReportingController@callsStatusForServiceForDev');
$router->get('method-serv-dev', 'ReportingController@callsMethodsForServiceForDev');
$router->get('error-serv-dev', 'ReportingController@callsErrocodesForServiceForDev');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment