lib/API/MetricsApi.php
/**
     * Create request for operation 'metricExport'
     *
     * @param  string $metric_id (required)
     * @param  string $start_date Beginning of timeframe to pull event data for. The default value is 1 month ago. Can also accept a 10-digit UNIX timestamp. When sending a &#x60;start_date&#x60;, you must also send an &#x60;end_date&#x60;  Ex: &#x60;1610524800&#x60; OR &#x60;2021-01-13&#x60; (optional)
     * @param  string $end_date End of timeframe to pull event data for. The default is the current day, or 1 month from start_date, whichever is sooner. Can also accept a 10-digit UNIX timestamp. When sending an &#x60;end_date&#x60;, you must also send a &#x60;start_date&#x60;. Must be *at most* 31 days after &#x60;start_date&#x60;  Ex: &#x60;1612080000&#x60; OR &#x60;2021-01-31&#x60; (optional)
     * @param  string $unit Granularity to bucket data points into - one of &#x60;day&#x60;, &#x60;week&#x60;, or &#x60;month&#x60;. Defaults to &#x60;day&#x60;. (optional, default to 'day')
     * @param  string $measurement Type of metric to fetch - one of &#x60;unique&#x60;, &#x60;count&#x60;, &#x60;value&#x60;, or &#x60;sum&#x60;. Defaults to &#x60;count&#x60;. For &#x60;sum&#x60; a property name to operate on must be supplied as a JSON-encoded list like &#x60;[\&quot;sum\&quot;,\&quot;ItemCount\&quot;]&#x60; (optional, default to 'count')
     * @param  string $where Optional, JSON-encoded list. Conditions to use to filter the set of events. A max of 1 condition can be given. &#x60;where&#x60; and &#x60;by&#x60; parameters cannot be specified at the same time.  ex: &#x60;[[\&quot;$attributed_flow\&quot;,\&quot;&#x3D;\&quot;,\&quot;FLOW_ID\&quot;]]&#x60; (optional)
     * @param  string $by The name of a property to segment the event data on. &#x60;where&#x60; and &#x60;by&#x60; parameters cannot be specified at the same time. Cannot be used alongside &#x60;where&#x60; parameter. (optional)
     * @param  int $count Maximum number of segments to return. Default &#x3D; 25, **MAX &#x3D; 1000** (optional, default to 25)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
Create request for operation 'metricExport'
@param  string $metric_id (required)
@param  string $start_date Beginning of timeframe to pull event data for. The default value is 1 month ago. Can also accept a 10-digit UNIX timestamp.


Create request for operation ' metricExport ' @param string $metric_id ( required ) @param string $start_date Beginning of timeframe to pull event data for . The default value is 1 month ago . Can also accept a 10 - digit UNIX timestamp .
public function metricExportRequest($metric_id, $start_date = null, $end_date = null, $unit = 'day', $measurement = 'count', $where = null, $by = null, $count = 25)
    {
        if ($metric_id === null || (is_array($metric_id) && count($metric_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $metric_id when calling metricExport'
            );
        }
        if ($count !== null && $count > 1000) {
            throw new \InvalidArgumentException('invalid value for "$count" when calling MetricsApi.metricExport, must be smaller than or equal to 1000.');
        }
        if ($count !== null && $count < 1) {
            throw new \InvalidArgumentException('invalid value for "$count" when calling MetricsApi.metricExport, must be bigger than or equal to 1.');
        }
        $resourcePath = '/v1/metric/{metric_id}/export';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;
        if ($start_date !== null) {
            if('form' === 'form' && is_array($start_date)) {
                foreach($start_date as $key => $value) {
                    $queryParams[$key] = $value;
                }
            }
            else {
                $queryParams['start_date'] = $start_date;
            }
        }
        if ($end_date !== null) {
            if('form' === 'form' && is_array($end_date)) {
                foreach($end_date as $key => $value) {
                    $queryParams[$key] = $value;
                }
            }
            else {
                $queryParams['end_date'] = $end_date;
            }
        }
        if ($unit !== null) {
            if('form' === 'form' && is_array($unit)) {
                foreach($unit as $key => $value) {
                    $queryParams[$key] = $value;
                }
            }
            else {
                $queryParams['unit'] = $unit;
            }
        }
        if ($measurement !== null) {
            if('form' === 'form' && is_array($measurement)) {
                foreach($measurement as $key => $value) {
                    $queryParams[$key] = $value;
                }
            }
            else {
                $queryParams['measurement'] = $measurement;
            }
        }
        if ($where !== null) {
            if('form' === 'form' && is_array($where)) {
                foreach($where as $key => $value) {
                    $queryParams[$key] = $value;
                }
            }
            else {
                $queryParams['where'] = $where;
            }
        }
        if ($by !== null) {
            if('form' === 'form' && is_array($by)) {
                foreach($by as $key => $value) {
                    $queryParams[$key] = $value;
                }
            }
            else {
                $queryParams['by'] = $by;
            }
        }
        if ($count !== null) {
            if('form' === 'form' && is_array($count)) {
                foreach($count as $key => $value) {
                    $queryParams[$key] = $value;
                }
            }
            else {
                $queryParams['count'] = $count;
            }
        }
        if ($metric_id !== null) {
            $resourcePath = str_replace(
                '{' . 'metric_id' . '}',
                ObjectSerializer::toPathValue($metric_id),
                $resourcePath
            );
        }
        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json'],
                []
            );
        }
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                $httpBody = new MultipartStream($multipartContents);
            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = \GuzzleHttp\json_encode($formParams);
            } else {
                $httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
            }
        }
        $apiKey = $this->config->getApiKeyWithPrefix('api_key');
        if ($apiKey !== null) {
            $queryParams['api_key'] = $apiKey;
        }
        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }
        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );
        $query = \GuzzleHttp\Psr7\Query::build($queryParams);
        return new Request(
            'GET',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }
public function metricExportRequest ( $ metric_id , $ start_date = null , $ end_date = null , $ unit = 'day' , $ measurement = 'count' , $ where = null , $ by = null , $ count = 25 ) { if ( $ metric_id === null || ( is_array ( $ metric_id ) && count ( $ metric_id ) === 0 ) ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $metric_id when calling metricExport' ) ; } if ( $ count !== null && $ count > 1000 ) { throw new \ InvalidArgumentException ( 'invalid value for "$count" when calling MetricsApi.metricExport, must be smaller than or equal to 1000.' ) ; } if ( $ count !== null && $ count < 1 ) { throw new \ InvalidArgumentException ( 'invalid value for "$count" when calling MetricsApi.metricExport, must be bigger than or equal to 1.' ) ; } $ resourcePath = '/v1/metric/{metric_id}/export' ; $ formParams = [ ] ; $ queryParams = [ ] ; $ headerParams = [ ] ; $ httpBody = '' ; $ multipart = false ; if ( $ start_date !== null ) { if ( 'form' === 'form' && is_array ( $ start_date ) ) { foreach ( $ start_date as $ key => $ value ) { $ queryParams [ $ key ] = $ value ; } } else { $ queryParams [ 'start_date' ] = $ start_date ; } } if ( $ end_date !== null ) { if ( 'form' === 'form' && is_array ( $ end_date ) ) { foreach ( $ end_date as $ key => $ value ) { $ queryParams [ $ key ] = $ value ; } } else { $ queryParams [ 'end_date' ] = $ end_date ; } } if ( $ unit !== null ) { if ( 'form' === 'form' && is_array ( $ unit ) ) { foreach ( $ unit as $ key => $ value ) { $ queryParams [ $ key ] = $ value ; } } else { $ queryParams [ 'unit' ] = $ unit ; } } if ( $ measurement !== null ) { if ( 'form' === 'form' && is_array ( $ measurement ) ) { foreach ( $ measurement as $ key => $ value ) { $ queryParams [ $ key ] = $ value ; } } else { $ queryParams [ 'measurement' ] = $ measurement ; } } if ( $ where !== null ) { if ( 'form' === 'form' && is_array ( $ where ) ) { foreach ( $ where as $ key => $ value ) { $ queryParams [ $ key ] = $ value ; } } else { $ queryParams [ 'where' ] = $ where ; } } if ( $ by !== null ) { if ( 'form' === 'form' && is_array ( $ by ) ) { foreach ( $ by as $ key => $ value ) { $ queryParams [ $ key ] = $ value ; } } else { $ queryParams [ 'by' ] = $ by ; } } if ( $ count !== null ) { if ( 'form' === 'form' && is_array ( $ count ) ) { foreach ( $ count as $ key => $ value ) { $ queryParams [ $ key ] = $ value ; } } else { $ queryParams [ 'count' ] = $ count ; } } if ( $ metric_id !== null ) { $ resourcePath = str_replace ( '{' . 'metric_id' . '}' , ObjectSerializer :: toPathValue ( $ metric_id ) , $ resourcePath ) ; } if ( $ multipart ) { $ headers = $ this -> headerSelector -> selectHeadersForMultipart ( [ 'application/json' ] ) ; } else { $ headers = $ this -> headerSelector -> selectHeaders ( [ 'application/json' ] , [ ] ) ; } if ( count ( $ formParams ) > 0 ) { if ( $ multipart ) { $ multipartContents = [ ] ; foreach ( $ formParams as $ formParamName => $ formParamValue ) { $ formParamValueItems = is_array ( $ formParamValue ) ? $ formParamValue : [ $ formParamValue ] ; foreach ( $ formParamValueItems as $ formParamValueItem ) { $ multipartContents [ ] = [ 'name' => $ formParamName , 'contents' => $ formParamValueItem ] ; } } $ httpBody = new MultipartStream ( $ multipartContents ) ; } elseif ( $ headers [ 'Content-Type' ] === 'application/json' ) { $ httpBody = \ GuzzleHttp \ json_encode ( $ formParams ) ; } else { $ httpBody = \ GuzzleHttp \ Psr7 \ Query :: build ( $ formParams ) ; } } $ apiKey = $ this -> config -> getApiKeyWithPrefix ( 'api_key' ) ; if ( $ apiKey !== null ) { $ queryParams [ 'api_key' ] = $ apiKey ; } $ defaultHeaders = [ ] ; if ( $ this -> config -> getUserAgent ( ) ) { $ defaultHeaders [ 'User-Agent' ] = $ this -> config -> getUserAgent ( ) ; } $ headers = array_merge ( $ defaultHeaders , $ headerParams , $ headers ) ; $ query = \ GuzzleHttp \ Psr7 \ Query :: build ( $ queryParams ) ; return new Request ( 'GET' , $ this -> config -> getHost ( ) . $ resourcePath . ( $ query ? " ? { $ query } " : '' ) , $ headers , $ httpBody ) ; }
Create request for operation 'metricExport'
 @param  string $metric_id (required)
 @param  string $start_date Beginning of timeframe to pull event data for.
Create request for operation ' metricExport ' @param string $metric_id ( required ) @param string $start_date Beginning of timeframe to pull event data for .
// verify the required parameter 'metric_id' is set // query params // query params // query params // query params // query params // query params // query params // path params // for model (json/xml) // for HTTP post (form) // for HTTP post (form) // this endpoint requires API key authentication