Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions examples/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.

from datetime import date, timedelta
import time
from datetime import datetime, timedelta
import warnings

from connect.config import Config
Expand Down Expand Up @@ -36,9 +35,12 @@ def process_request(self, request):
contract=Contract(id=request.contract.id)
)

today = datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0)
yesterday = today - timedelta(days=1)

usages = [
UsageRecord(
record_id='unique record value',
usage_record_id='unique record value',

item_search_criteria='item.mpn',
# Possible values are item.mpn or item.local_id.
Expand All @@ -49,10 +51,10 @@ def process_request(self, request):
quantity=1,
# Quantity to be reported.

start_time_utc=(date.today() - timedelta(1)).strftime('%Y-%m-%d'),
start_time_utc=yesterday.strftime('%Y-%m-%d %H:%M:%S'),
# From when to report.

end_time_utc=time.strftime('%Y-%m-%d %H:%M:%S'),
end_time_utc=today.strftime('%Y-%m-%d %H:%M:%S'),
# Till when to report.

asset_search_criteria='parameter.param_b',
Expand Down