Report   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 18
c 2
b 0
f 0
dl 0
loc 63
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A integratedGet() 0 34 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Promopult\TikTokMarketingApi\Service;
6
7
/**
8
 * @psalm-suppress UnusedClass
9
 */
10
final class Report extends \Promopult\TikTokMarketingApi\AbstractService
11
{
12
    /**
13
     * Create an Integrated Report
14
     *
15
     * @param int $advertiserId     Advertiser ID
16
     * @param string $reportType    Report type
17
     * @param array $dimensions     Grouping conditions. Auction and Reservation Ads support different dimensions.
18
     * @param ?string $dataLevel    Reporting data level. Required when report_type is BASIC,AUDIENCE or CATALOG
19
     * @param ?string $serviceType
20
     * @param ?array $metrics       Metrics to query. Defaut: ["spend," "impressions"]
21
     * @param bool $lifetime        Whether to request the lifetime metrics. The lifetime metric name is the same as
22
     *                              the normal one. If lifetime = true, the start_date and end_date parameters will
23
     *                              be ignored.
24
     * @param ?string $startDate    Query start date, format such as: 2020-01-01, required when lifetime = false
25
     * @param ?string $endDate      Query end date, format such as: 2020-01-01, required when lifetime = false
26
     * @param ?array $filters       Filter criteria. Supported filtering criteria vary according to 'service_type' and
27
     *                              'data_level'
28
     * @param ?string $orderField   Sort field. All supported metrics (excluding attribute metrics) support sorting,
29
     *                              not sorting by default
30
     * @param ?string $orderType    Sort. Optional value: ASC, DESC. Default value: DESC
31
     * @param ?int $page            Current number of pages. Default value: 1
32
     * @param ?int $pageSize        Pagination size. Default value: 10
33
     *
34
     * @return array
35
     *
36
     * @throws \Throwable
37
     * @see https://ads.tiktok.com/marketing_api/docs?id=1685752851588097
38
     */
39
    public function integratedGet(
40
        int $advertiserId,
41
        string $reportType,
42
        array $dimensions,
43
        ?string $dataLevel = null,
44
        ?string $serviceType = null,
45
        ?array $metrics = null,
46
        bool $lifetime = false,
47
        ?string $startDate = null,
48
        ?string $endDate = null,
49
        ?array $filters = null,
50
        ?string $orderField = null,
51
        ?string $orderType = null,
52
        ?int $page = null,
53
        ?int $pageSize = null
54
    ): array {
55
        return $this->requestApi(
56
            'GET',
57
            '/open_api/v1.3/report/integrated/get/',
58
            [
59
                'advertiser_id' => $advertiserId,
60
                'service_type' => $serviceType,
61
                'report_type' => $reportType,
62
                'data_level' => $dataLevel,
63
                'dimensions' => $dimensions,
64
                'metrics' => $metrics,
65
                'start_date' => $startDate,
66
                'end_date' => $endDate,
67
                'lifetime' => $lifetime,
68
                'order_field' => $orderField,
69
                'order_type' => $orderType,
70
                'filters' => $filters,
71
                'page' => $page,
72
                'page_size' => $pageSize
73
            ]
74
        );
75
    }
76
}
77