diff --git a/Changes b/Changes index 502b966..11bce30 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,9 @@ Revision history for Tesla-API - Remove WWW::Mechanize timeout (it defaults to 180 secs in LWP::UserAgent) - Add API_TIMEOUT_RETRIES; If a Tesla API call times out, try it again this many times + - Accept PR #9 (fix compatibility with JSON < 4) and apply that change to + all instances of encode_json() + - 0.09 2022-03-22 - In CI script, manually install File::ShareDir::Install, as it doesn't get diff --git a/lib/Tesla/API.pm b/lib/Tesla/API.pm index 35d7621..24dcff8 100644 --- a/lib/Tesla/API.pm +++ b/lib/Tesla/API.pm @@ -364,7 +364,12 @@ sub _access_token_generate { redirect_uri => "https://auth.tesla.com/void/callback", }; - my $request = HTTP::Request->new('POST', $url, $header, encode_json($request_data)); + my $request = HTTP::Request->new( + 'POST', + $url, + $header, + JSON->new->allow_nonref->encode($request_data) + ); my $response = $self->mech->request($request); @@ -428,7 +433,12 @@ sub _access_token_refresh { client_id => 'ownerapi', }; - my $request = HTTP::Request->new('POST', $url, $header, encode_json($request_data)); + my $request = HTTP::Request->new( + 'POST', + $url, + $header, + JSON->new->allow_nonref->encode($request_data) + ); my $response = $self->mech->request($request); @@ -460,7 +470,8 @@ sub _access_token_update { $self->_access_token_data($token_data); open my $fh, '>', CACHE_FILE or die $!; - print $fh encode_json($token_data); + + print $fh JSON->new->allow_nonref->encode($token_data); } sub _authentication_code { # If an access token is unavailable, prompt the user with a URL to