Skip to content

Commit 970310e

Browse files
committed
Changed daily field to number of days
1 parent d0d9f5a commit 970310e

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

component_config/configSchema.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,41 @@
44
"required": [
55
"#client_id",
66
"#client_secret",
7-
"daily_load",
7+
"days",
88
"manual_authentication",
99
"endpoint"
1010
],
1111
"properties": {
1212
"#client_id": {
1313
"type": "string",
1414
"format": "password",
15-
"title": "Allegro Client ID"
15+
"title": "Allegro Client ID",
16+
"propertyOrder": 1
1617
},
1718
"#client_secret": {
1819
"type": "string",
1920
"format": "password",
20-
"title": "Allegro Client Secret"
21+
"title": "Allegro Client Secret",
22+
"propertyOrder": 2
2123
},
2224
"endpoint": {
2325
"title": "Endpoint",
2426
"type": "string",
2527
"enum": [
2628
"Billing entries"
27-
]
29+
],
30+
"propertyOrder": 3
2831
},
29-
"daily_load": {
30-
"type": "boolean",
31-
"title": "Daily load"
32+
"days": {
33+
"type": "integer",
34+
"title": "Days",
35+
"description": "How many days to load",
36+
"propertyOrder": 4
3237
},
3338
"manual_authentication": {
3439
"type": "boolean",
35-
"title": "Manual Authentication"
40+
"title": "Manual Authentication",
41+
"propertyOrder": 5
3642
}
3743
}
3844
}

src/component.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
KEY_CLIENT_ID = '#client_id'
1818
KEY_CLIENT_SECRET = '#client_secret'
1919
ENDPOINTS = 'endpoint'
20-
DAILY = 'daily_load'
20+
DAYS = 'days'
2121
AUTHENTICATION = 'manual_authentication'
2222

2323
CODE_URL = "https://allegro.pl/auth/oauth/device"
@@ -59,7 +59,7 @@ def run(self):
5959
self.client_ID = params.get(KEY_CLIENT_ID)
6060
self.client_secret = params.get(KEY_CLIENT_SECRET)
6161
self.endpoint = params.get(ENDPOINTS)
62-
self.daily = params.get(DAILY)
62+
self.days = params.get(DAYS)
6363
self.authentication = params.get(AUTHENTICATION)
6464

6565
# Get state file
@@ -223,13 +223,11 @@ def parse_biling_entries(data):
223223
return df
224224

225225
logging.info('Getting dates.')
226-
if self.daily:
227-
# Set start and stop date to yesterday
228-
start_date = stop_date = datetime.today().date() - timedelta(days=1)
229-
else:
230-
# Set start to 1.1.2020 and stop to yesterday
231-
start_date = date(year=2020, month=1, day=1)
232-
stop_date = datetime.today().date() - timedelta(days=1)
226+
227+
# Set start to 1.1.2020 and stop to yesterday
228+
today = datetime.today().date()
229+
start_date = today - timedelta(days=1)
230+
stop_date = datetime.today().date() - timedelta(days=self.days)
233231

234232
# Get date list
235233
date_list = date_range_list(start_date, stop_date)

0 commit comments

Comments
 (0)