Skip to content

Commit

Permalink
Merge pull request #10 from Lumen5/chris-report-usage
Browse files Browse the repository at this point in the history
adding report_usage method to allow for reporting at specified times
  • Loading branch information
cbowal committed Oct 18, 2018
2 parents 22c8c3b + b8c447a commit 96d989d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pygetty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__doc__ = 'Wrapper for Getty v3 API'
__author__ = 'Josh Klar <josh@lumen5.com>'
__version__ = '1.1.7'
__version__ = '1.1.8'
22 changes: 21 additions & 1 deletion pygetty/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ def report_usage_now(
Reports asset usage at the current moment for a single asset.
Returns 1 on success, or raises ReportingFailed.
"""
return report_usage(
id,
pendulum.now().isoformat(),
api_key=api_key,
client_secret=client_secret,
auth_token_manager=auth_token_manager,
)


def report_usage(
id,
usage_date,
api_key=None,
client_secret=None,
auth_token_manager=None,
):
"""
Reports asset usage at the specified time for a single asset.
Returns 1 on success, or raises ReportingFailed.
"""
auth_token_manager = flex_auth(
api_key=api_key,
client_secret=client_secret,
Expand All @@ -40,7 +60,7 @@ def report_usage_now(
'asset_usages': [{
'asset_id': id,
'quantity': 1,
'usage_date': pendulum.now().isoformat(),
'usage_date': usage_date,
}],
},
)
Expand Down

0 comments on commit 96d989d

Please sign in to comment.