tesla_api 0.1.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45741a5c5b2afc5cd2e0eb6b2ecafa1115847868
4
- data.tar.gz: 79c210bf38a56293ff3fc7261780eb84fcd87684
3
+ metadata.gz: c7441f6abbbf1b45ba289dfa54e436ad1bf01afe
4
+ data.tar.gz: c8924314065402e270be9a040d5b8b1b897a7814
5
5
  SHA512:
6
- metadata.gz: aec12640955ab16d5a77611e4bb66d34ff3084b362caf572372d59c8a2a7b484d8a46224d0a4f2dff0360d912b1e49f5eaf6c99a7c31ac4e4204814e10b207a7
7
- data.tar.gz: 87ae5a2fac0c7ade54796a83d0c0eb6b87a3eddc20415f2c67c2c3959dda4e08ae38abe64e4052be0f3f4d5ee9656659a4dbc63aad79f8a5744880c65232444e
6
+ metadata.gz: 02e8ad2eae1b2579fb1ee71a96ddc312d7aab6161e4dd52e4c8c224004985a88afb91f6a7b83f942468de56264961746f8793872c9d2897b8dd10dc58668e2e9
7
+ data.tar.gz: a7721fae02bcf38a700bf939c28501ae0c2b63c74e2e6856ec81dfc788e74d101662037aba80064d0d5b73fc6907539967f086797b574a3186c006e75625eba2
data/.travis.yml CHANGED
@@ -9,3 +9,5 @@ env:
9
9
  - TESLA_PASS=oilLOL
10
10
  - TESLA_CLIENT_ID=1
11
11
  - TESLA_CLIENT_SECRET=2
12
+ notifications:
13
+ email: false
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in tesla_api.gemspec
4
3
  gemspec
4
+
5
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -6,7 +6,7 @@ This is unofficial documentation of the Tesla JSON API used by the iOS and Andro
6
6
  The API provides functionality to monitor and control the Model S (and future Tesla vehicles) remotely.
7
7
  The project provides both a documention of the API and a Ruby library to for accessing it.
8
8
 
9
- ## Ruby Gem [![Gem Version](https://img.shields.io/gem/v/tesla_api.svg)](http://rubygems.org/gems/tesla_api) [![Build Status](https://img.shields.io/travis/timdorr/model-s-api/master.svg)](https://travis-ci.org/timdorr/model-s-api)
9
+ ## Ruby Gem [![Gem Version](https://img.shields.io/gem/v/tesla_api.svg)](http://rubygems.org/gems/tesla_api) [![Build Status](https://img.shields.io/travis/timdorr/model-s-api/master.svg)](https://travis-ci.org/timdorr/model-s-api) [![Coverage Status](https://img.shields.io/coveralls/timdorr/model-s-api.svg)](https://coveralls.io/r/timdorr/model-s-api?branch=master)
10
10
 
11
11
  This gem provides a basic wrapper around the API to easily query and command the car remotely.
12
12
  It also provides access to the streaming API and a means to process data coming from it.
@@ -9,10 +9,20 @@ module TeslaApi
9
9
  @vehicle = vehicle
10
10
  end
11
11
 
12
+ # Properties
13
+
12
14
  def [](key)
13
15
  vehicle[key]
14
16
  end
15
17
 
18
+ def method_missing(name)
19
+ if vehicle.keys.include?(name.to_s)
20
+ vehicle[name.to_s]
21
+ else
22
+ raise NoMethodError.new("Vehicle does not have property `#{name}`", name)
23
+ end
24
+ end
25
+
16
26
  # State
17
27
 
18
28
  def mobile_enabled
@@ -1,3 +1,3 @@
1
1
  module TeslaApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -0,0 +1,89 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://owner-api.teslamotors.com/oauth/token
6
+ body:
7
+ encoding: UTF-8
8
+ string: grant_type=password&client_id=<TESLA_CLIENT_ID>&client_secret=<TESLA_CLIENT_SECRET>&email=<TESLA_EMAIL>&password=<TESLA_PASS>
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Mon, 15 Dec 2014 04:42:49 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Status:
32
+ - 200 OK
33
+ Cache-Control:
34
+ - no-store
35
+ Pragma:
36
+ - no-cache
37
+ X-Ua-Compatible:
38
+ - IE=Edge,chrome=1
39
+ X-Request-Id:
40
+ - 8f8740e0685ac8fc647ef935ca48fbaf
41
+ X-Runtime:
42
+ - '0.628793'
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"access_token":"7740526bd5eb7d9d24421e6f3b37a7ca226aba9c508719dc673338425625771c","token_type":"bearer","expires_in":7776000}'
46
+ http_version:
47
+ recorded_at: Mon, 15 Dec 2014 04:42:49 GMT
48
+ - request:
49
+ method: get
50
+ uri: https://owner-api.teslamotors.com/api/1/vehicles
51
+ body:
52
+ encoding: US-ASCII
53
+ string: ''
54
+ headers:
55
+ Authorization:
56
+ - Bearer 7740526bd5eb7d9d24421e6f3b37a7ca226aba9c508719dc673338425625771c
57
+ response:
58
+ status:
59
+ code: 200
60
+ message: OK
61
+ headers:
62
+ Server:
63
+ - nginx
64
+ Date:
65
+ - Mon, 15 Dec 2014 04:42:50 GMT
66
+ Content-Type:
67
+ - application/json; charset=utf-8
68
+ Content-Length:
69
+ - '446'
70
+ Connection:
71
+ - keep-alive
72
+ Status:
73
+ - 200 OK
74
+ X-Ua-Compatible:
75
+ - IE=Edge,chrome=1
76
+ Etag:
77
+ - '"89d57312f9ec321aacf9b239c20308fc"'
78
+ Cache-Control:
79
+ - max-age=0, private, must-revalidate
80
+ X-Request-Id:
81
+ - ea98a1d1bbd2d88330f543c23fb92a4d
82
+ X-Runtime:
83
+ - '0.389659'
84
+ body:
85
+ encoding: UTF-8
86
+ string: '{"response":[{"color":null,"display_name":"Nikola","id":1514029006966957156,"option_codes":"MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013,COUS","vehicle_id":490215852,"vin":"5YJSA1CN5CFP01657","tokens":["99b8958b9408b1ac","79eb37ed5c55fe6a"],"state":"online","remote_start_enabled":true,"calendar_enabled":true,"notifications_enabled":true}],"count":1}'
87
+ http_version:
88
+ recorded_at: Mon, 15 Dec 2014 04:42:50 GMT
89
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe TeslaApi::Vehicle do
4
+ let(:tesla_api) { TeslaApi::Client.new(ENV["TESLA_EMAIL"], ENV["TESLA_PASS"], ENV["TESLA_CLIENT_ID"], ENV["TESLA_CLIENT_SECRET"]) }
5
+
6
+ subject(:vehicle) { tesla_api.vehicles.first }
7
+
8
+ describe "#[]", vcr: { cassette_name: "vehicle" } do
9
+ it "contains the vehicle name" do
10
+ expect(vehicle["display_name"]).to eq("Nikola")
11
+ end
12
+ end
13
+
14
+ describe "#method_missing", vcr: {cassette_name: "vehicle"} do
15
+ it "doesn't provide dynamic methods for nonexistent properties" do
16
+ expect{vehicle.gas_level}.to raise_exception(NoMethodError)
17
+ end
18
+
19
+ it "provides a dynamic method for the display_name" do
20
+ expect(vehicle.display_name).to eq("Nikola")
21
+ end
22
+ end
23
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  require 'dotenv'
2
2
  require 'vcr'
3
3
  require 'webmock/rspec'
4
+ require 'coveralls'
4
5
 
5
6
  require 'tesla_api'
6
7
 
7
8
  Dotenv.load
8
9
 
10
+ Coveralls::Output.silent = true
11
+ Coveralls.wear!
12
+
9
13
  VCR.configure do |c|
10
14
  c.cassette_library_dir = "spec/cassettes"
11
15
  c.hook_into :webmock
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tesla_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Dorr
@@ -144,7 +144,9 @@ files:
144
144
  - lib/tesla_api/version.rb
145
145
  - spec/cassettes/client-initialize.yml
146
146
  - spec/cassettes/client-vehicles.yml
147
+ - spec/cassettes/vehicle.yml
147
148
  - spec/lib/tesla_api/client_spec.rb
149
+ - spec/lib/tesla_api/vehicle_spec.rb
148
150
  - spec/spec_helper.rb
149
151
  - tesla_api.gemspec
150
152
  homepage: https://github.com/timdorr/model-s-api
@@ -174,5 +176,7 @@ summary: A wrapper for the Tesla API
174
176
  test_files:
175
177
  - spec/cassettes/client-initialize.yml
176
178
  - spec/cassettes/client-vehicles.yml
179
+ - spec/cassettes/vehicle.yml
177
180
  - spec/lib/tesla_api/client_spec.rb
181
+ - spec/lib/tesla_api/vehicle_spec.rb
178
182
  - spec/spec_helper.rb