Skip to content

Commit

Permalink
Made TESLA_USERAGENT string to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Mar 29, 2023
1 parent 50dba1f commit d446999
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Revision history for Tesla-API
- Fix bug in update_data_files() where when a parameter wasn't sent in, we'd
try to use the file path and name instead of the URLs in the fetch HTTP
calls
- Add new X-Tesla-UserAgent constant; it's used in the Tesla API call for
retrieving specific data (Charging History) (PR from 'jankratochvil',
Thanks!)

1.02 2022-07-19
- Add uri(); Generates and returns a new URI object (to be inherited)
Expand Down
4 changes: 2 additions & 2 deletions lib/Tesla/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use constant {
ENDPOINTS_FILE => $ENV{TESLA_API_ENDPOINTS_FILE} // dist_file('Tesla-API', 'endpoints.json'),
OPTION_CODES_FILE => $ENV{TESLA_API_OPTIONCODES_FILE} // dist_file('Tesla-API', 'option_codes.json'),
TOKEN_EXPIRY_WINDOW => 5,
TESLA_USER_AGENT => 'TeslaApp/4.10.0', # Used for charging_history
URL_API => 'https://owner-api.teslamotors.com/',
URL_ENDPOINTS => 'https://raw.githubusercontent.com/tdorssers/TeslaPy/master/teslapy/endpoints.json',
URL_OPTION_CODES => 'https://raw.githubusercontent.com/tdorssers/TeslaPy/master/teslapy/option_codes.json',
Expand Down Expand Up @@ -122,8 +123,7 @@ sub api {

my $header = [
'Content-Type' => 'application/json; charset=UTF-8',
# This header is required for charge_history.
'X-Tesla-User-Agent' => 'TeslaApp/4.10.0',
'X-Tesla-User-Agent' => TESLA_USER_AGENT,
];

if ($auth) {
Expand Down

0 comments on commit d446999

Please sign in to comment.