From 5f141f355bdef98444b89cfc740c69d7557c51c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20NAGY?= Date: Thu, 19 Apr 2018 15:05:29 +0200 Subject: [PATCH] Use new filter condition after CPS migration #DRUPS-25 --- Apigee/ManagementAPI/DeveloperAppAnalytics.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Apigee/ManagementAPI/DeveloperAppAnalytics.php b/Apigee/ManagementAPI/DeveloperAppAnalytics.php index 97f1268..4c6fc7f 100644 --- a/Apigee/ManagementAPI/DeveloperAppAnalytics.php +++ b/Apigee/ManagementAPI/DeveloperAppAnalytics.php @@ -114,11 +114,13 @@ public function getAllEnvironments() /** * After ensuring params are valid, fetches analytics data. * - * @param string $devIdOrCompanyName + * @param string $devEmailOrCompany * The ID of the developer or company name that owns the app. If you * do not pass in this parameter you will get analytics for any app * in the org with this app name, since app name is not unique across * developers. + * @param bool $is_company + * If TRUE get app for company, otherwise for developer. * @param string $appName * The name of the app. * @param string $metric @@ -155,17 +157,18 @@ public function getAllEnvironments() * * @return array */ - public function getByAppName($devIdOrCompanyName, $appName, $metric, $tStart, $tEnd, $tUnit, $sortBy, $sortOrder = 'ASC') + public function getByAppName($devEmailOrCompany, $is_company, $appName, $metric, $tStart, $tEnd, $tUnit, $sortBy, $sortOrder = 'ASC') { $params = self::validateParameters($metric, $tStart, $tEnd, $tUnit, $sortBy, $sortOrder); // We need to filter analytics by the developer or company name. If we do not // we will get back data for all apps with the app name, since they are not // unique. For example, two developers can make an app named "test". - if (!empty($devIdOrCompanyName)) { - $org = $this->config->orgName; - $params['filter'] = "(developer eq '$org@@@$devIdOrCompanyName')"; + if (!empty($devEmailOrCompany)) { + $filter_property = $is_company ? 'developer' : 'developer_email'; + $params['filter'] = "({$filter_property} eq '{$devEmailOrCompany}')"; } + $params['developer_app'] = $appName; $url = 'apps?';