Skip to content

Commit

Permalink
[ruby] Add Vehicle#share_location
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Apr 15, 2023
1 parent 9108149 commit e015312
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/tesla_api/vehicle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ def media_volume_down
command("media_volume_down")["response"]
end

# Sends a location for the car to start navigation
def share_location(address, locale: "us-US")
params = {
type: "share_ext_content_raw",
locale: locale,
timestamp_ms: Time.now.to_i,
value: {"android.intent.extra.TEXT" => address}
}
command("share", body: params)["response"]
end

private

def data_request(name)
Expand Down
117 changes: 117 additions & 0 deletions spec/cassettes/vehicle-share_location.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions spec/lib/tesla_api/vehicle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,12 @@
end
end
end

context "sharing" do
describe "#share_location", vcr: {cassette_name: "vehicle-share_location"} do
it "shares a location with car GPS" do
expect(vehicle.share_location("Tesla HQ, Deer Creek Road, Palo Alto, CA, USA")["result"]).to eq(true)
end
end
end
end

0 comments on commit e015312

Please sign in to comment.