@@ -128,11 +128,6 @@ def detailed_time_entries(self, start_date: datetime, end_date: datetime, **kwar
128
128
return response
129
129
130
130
131
- def _harvest_client_name ():
132
- """Gets the value of the HARVEST_CLIENT_NAME env var."""
133
- return os .environ .get ("HARVEST_CLIENT_NAME" )
134
-
135
-
136
131
def _get_info (obj : dict , key : str , env_key : str ):
137
132
"""Read key from obj, populating obj once from a file path at env_key."""
138
133
if obj == {}:
@@ -143,19 +138,6 @@ def _get_info(obj: dict, key: str, env_key: str):
143
138
return obj .get (key )
144
139
145
140
146
- def _toggl_api_token ():
147
- """Gets the value of the TOGGL_API_TOKEN env var."""
148
- return os .environ .get ("TOGGL_API_TOKEN" )
149
-
150
-
151
- def _toggl_client_id ():
152
- """Gets the value of the TOGGL_CLIENT_ID env var."""
153
- client_id = os .environ .get ("TOGGL_CLIENT_ID" )
154
- if client_id :
155
- return int (client_id )
156
- return None
157
-
158
-
159
141
def _toggl_project_info (project : str ):
160
142
"""Return the cached project for the given project key."""
161
143
return _get_info (PROJECT_INFO , project , "TOGGL_PROJECT_INFO" )
@@ -166,11 +148,6 @@ def _toggl_user_info(email: str):
166
148
return _get_info (USER_INFO , email , "TOGGL_USER_INFO" )
167
149
168
150
169
- def _toggl_workspace ():
170
- """Gets the value of the TOGGL_WORKSPACE_ID env var."""
171
- return os .environ .get ("TOGGL_WORKSPACE_ID" )
172
-
173
-
174
151
def _get_first_name (email : str ) -> str :
175
152
"""Get cached first name or derive from email."""
176
153
user = _toggl_user_info (email )
@@ -226,7 +203,7 @@ def convert_to_harvest(
226
203
None. Either prints the resulting CSV data or writes to output_path.
227
204
"""
228
205
if client_name is None :
229
- client_name = _harvest_client_name ( )
206
+ client_name = os . environ . get ( "HARVEST_CLIENT_NAME" )
230
207
231
208
# read CSV file, parsing dates and times
232
209
source = files .read_csv (source_path , usecols = INPUT_COLUMNS , parse_dates = ["Start date" ], cache_dates = True )
@@ -277,11 +254,14 @@ def download_time_entries(
277
254
Returns:
278
255
None. Either prints the resulting CSV data or writes to output_path.
279
256
"""
280
- if ("client_ids" not in kwargs or not kwargs ["client_ids" ]) and isinstance (_toggl_client_id (), int ):
281
- kwargs ["client_ids" ] = [_toggl_client_id ()]
282
-
283
- token = _toggl_api_token ()
284
- workspace = _toggl_workspace ()
257
+ env_client_id = os .environ .get ("TOGGL_CLIENT_ID" )
258
+ if env_client_id :
259
+ env_client_id = int (env_client_id )
260
+ if ("client_ids" not in kwargs or not kwargs ["client_ids" ]) and isinstance (env_client_id , int ):
261
+ kwargs ["client_ids" ] = [env_client_id ]
262
+
263
+ token = os .environ .get ("TOGGL_API_TOKEN" )
264
+ workspace = os .environ .get ("TOGGL_WORKSPACE_ID" )
285
265
toggl = Toggl (token , workspace )
286
266
287
267
response = toggl .detailed_time_entries (start_date , end_date , ** kwargs )
0 commit comments