1 | <?php |
||
15 | class Report implements CacheableInterface |
||
16 | { |
||
17 | |||
18 | use CachableTrait; |
||
19 | |||
20 | public const BASE_URL = 'http://api.adnxs.com/report'; |
||
21 | public const BASE_URL_DOWNLOAD = 'http://api.adnxs.com/'; |
||
22 | public const SANDBOX_BASE_URL = 'http://api-test.adnxs.com/report'; |
||
23 | public const SANDBOX_BASE_URL_DOWNLOAD = 'http://api-test.adnxs.com/'; |
||
24 | public const CACHE_NAMESPACE = 'appnexus_report'; |
||
25 | public const CACHE_EXPIRATION = 3600; |
||
26 | public const REVENUE_REPORT |
||
27 | = [ |
||
28 | 'report' => [ |
||
29 | 'report_type' => 'seller_platform_billing', |
||
30 | 'timezone' => 'PST', |
||
31 | 'report_interval' => 'last_7_days', |
||
32 | 'name' => 'Weekly SSP Revenue Report', |
||
33 | 'columns' => [ |
||
34 | 0 => 'day', |
||
35 | 1 => 'seller_member_id', |
||
36 | 2 => 'publisher_id', |
||
37 | 3 => 'publisher_name', |
||
38 | 4 => 'publisher_code', |
||
39 | 5 => 'buyer_member_id', |
||
40 | 6 => 'buyer_member_name', |
||
41 | 7 => 'imps', |
||
42 | 8 => 'imps_delivered', |
||
43 | 9 => 'seller_revenue', |
||
44 | ], |
||
45 | ], |
||
46 | ]; |
||
47 | |||
48 | public const SEGMENT_LOAD_REPORT_CUMULATIVE_VC |
||
49 | = [ |
||
50 | 'report' => [ |
||
51 | 'report_type' => 'segment_load', |
||
52 | 'timezone' => 'PST', |
||
53 | 'report_interval' => 'month_to_date', |
||
54 | 'name' => 'Cumulative VC report', |
||
55 | 'columns' => [ |
||
56 | 'avg_daily_uniques', |
||
57 | 'month', |
||
58 | ], |
||
59 | |||
60 | 'groups' => [ |
||
61 | 'month', |
||
62 | |||
63 | ], |
||
64 | 'orders' => [ |
||
65 | 'avg_daily_uniques', |
||
66 | ], |
||
67 | ], |
||
68 | ]; |
||
69 | |||
70 | public const SEGMENT_LOAD_REPORT_DAILY_VC |
||
71 | = [ |
||
72 | 'report' => [ |
||
73 | 'report_type' => 'segment_load', |
||
74 | 'timezone' => 'PST', |
||
75 | 'report_interval' => 'today', |
||
76 | 'name' => 'Cumulative VC report', |
||
77 | 'columns' => [ |
||
78 | 'daily_uniques', |
||
79 | 'day', |
||
80 | ], |
||
81 | |||
82 | 'groups' => [ |
||
83 | 'day', |
||
84 | |||
85 | ], |
||
86 | 'orders' => [ |
||
87 | 'daily_uniques', |
||
88 | ], |
||
89 | ], |
||
90 | ]; |
||
91 | |||
92 | /** @var \SplQueue */ |
||
93 | protected $userSegments; |
||
94 | |||
95 | /** @var ClientInterface|Auth */ |
||
96 | protected $client; |
||
97 | |||
98 | /** @var int */ |
||
99 | protected $memberId; |
||
100 | |||
101 | /** @var Cache */ |
||
102 | protected $cache; |
||
103 | |||
104 | /** @var string */ |
||
105 | protected $baseUrl; |
||
106 | |||
107 | /** @var string */ |
||
108 | protected $baseUrlDownload; |
||
109 | |||
110 | public function __construct(ClientInterface $client, Cache $cache) |
||
118 | |||
119 | /** |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getBaseUrl() |
||
126 | |||
127 | /** |
||
128 | * @param string $baseUrl |
||
129 | */ |
||
130 | public function setBaseUrl($baseUrl) |
||
134 | |||
135 | /** |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getBaseUrlDownload() |
||
142 | |||
143 | /** |
||
144 | * @param string $baseUrlDownload |
||
145 | */ |
||
146 | public function setBaseUrlDownload($baseUrlDownload) |
||
150 | |||
151 | /** |
||
152 | * @param array $reportFormat |
||
153 | * |
||
154 | * @return ReportTicket |
||
155 | * @throws ReportException |
||
156 | */ |
||
157 | public function getReportTicket($reportFormat = self::REVENUE_REPORT) |
||
179 | |||
180 | /** |
||
181 | * @param ReportTicket $reportTicket |
||
182 | * |
||
183 | * @return ReportStatus |
||
184 | * @throws ReportException |
||
185 | */ |
||
186 | public function getReportStatus(ReportTicket $reportTicket) |
||
214 | |||
215 | /** |
||
216 | * @param ReportStatus $reportStatus |
||
217 | * |
||
218 | * @return array |
||
219 | * @throws ReportException |
||
220 | */ |
||
221 | public function getReport(ReportStatus $reportStatus) |
||
253 | } |
||
254 |