@@ -144,16 +144,18 @@ def search(self, query, index=None):
144144 for v in search_result [m ]]
145145 return search_result
146146
147- def report (self , scope = None , groups = None , metrics = None , where = None , from_ = None , to = None ,
148- timezone = 'UTC' , emails = None , when = None , interval = None , name = None ,
147+ def report (self , scope = None , groups = None , metrics = None , where = None ,
148+ from_ = None , to = None , daterange = None , timezone = 'UTC' ,
149+ emails = None , when = None , interval = None , name = None ,
149150 sort = None , limit = None , offset = None , save = True , editable = False ):
150151 """Create a report.
151152
152153 See the `reporting atomx wiki <https://wiki.atomx.com/reporting>`_
153154 for details about parameters and available groups, metrics.
154155
155156 :param str scope: Specifies the report type. Should be one of:
156- 'advertiser', 'publisher', 'network_managed', 'network_buy', 'network_sell'.
157+ 'advertiser', 'publisher', 'inventory', 'dsp',
158+ 'network_managed', 'network_buy', 'network_sell'.
157159 If undefined it tries to determine the `scope` automatically based
158160 on the access rights of the api user.
159161 :param list groups: columns to group by.
@@ -167,10 +169,15 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
167169 and ``not in`` a list of numbers.
168170
169171 :param datetime.datetime from_: :class:`datetime.datetime` where the report
170- should start (inclusive). (defaults to last week)
172+ should start (inclusive). (Defaults to last week)
171173 :param datetime.datetime to: :class:`datetime.datetime` where the report
172- should end (exclusive). (defaults to `datetime.now()` if undefined)
173- :param str timezone: Timezone used for all times. (defaults to `UTC`)
174+ should end (exclusive). (Defaults to `datetime.now()` if undefined)
175+ :param str daterange: Use :param:`daterange` to automatically set the reports
176+ `from` and `to` parameters relativ to the current date.
177+ Both :param:`from_` and :param:`to` have to be ``None`` for it.
178+ Dateranges are: today, yesterday, last7days, last14days, last30days, monthtodate,
179+ lastmonth, yeartodate, lifetime. (Defaults to ``None``)
180+ :param str timezone: Timezone used for all times. (Defaults to `UTC`)
174181 For a supported list see https://wiki.atomx.com/timezones
175182 :param emails: One or multiple email addresses that should get
176183 notified once the report is finished and ready to download.
@@ -217,7 +224,9 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
217224 report_json ['when' ] = when
218225 report_json ['interval' ] = interval
219226
220- else : # normal report
227+ elif not from_ and not to and daterange : # Rolling report
228+ report_json ['daterange' ] = daterange
229+ else : # Normal report
221230 if from_ is None :
222231 from_ = datetime .now () - timedelta (days = 7 )
223232 if isinstance (from_ , datetime ):
0 commit comments