smartcar 2.4.0 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +32 -0
- data/.travis.yml +1 -2
- data/Gemfile +4 -2
- data/Gemfile.lock +78 -16
- data/README.md +38 -36
- data/Rakefile +11 -3
- data/bin/console +4 -3
- data/lib/smartcar.rb +167 -55
- data/lib/smartcar/auth_client.rb +154 -0
- data/lib/smartcar/base.rb +18 -26
- data/lib/smartcar/utils.rb +102 -20
- data/lib/smartcar/vehicle.rb +183 -249
- data/lib/smartcar/version.rb +3 -1
- data/lib/smartcar_error.rb +49 -0
- data/ruby-sdk.gemspec +28 -21
- metadata +84 -24
- data/lib/smartcar/battery.rb +0 -13
- data/lib/smartcar/battery_capacity.rb +0 -9
- data/lib/smartcar/charge.rb +0 -13
- data/lib/smartcar/engine_oil.rb +0 -12
- data/lib/smartcar/fuel.rb +0 -15
- data/lib/smartcar/location.rb +0 -10
- data/lib/smartcar/oauth.rb +0 -119
- data/lib/smartcar/odometer.rb +0 -9
- data/lib/smartcar/permissions.rb +0 -9
- data/lib/smartcar/tire_pressure.rb +0 -19
- data/lib/smartcar/user.rb +0 -35
- data/lib/smartcar/vehicle_attributes.rb +0 -12
- data/lib/smartcar/vin.rb +0 -10
data/lib/smartcar/odometer.rb
DELETED
data/lib/smartcar/permissions.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
module Smartcar
|
2
|
-
# class to represent permissions response
|
3
|
-
#@attr [Array] permissions Array of permissions granted on the vehicle.
|
4
|
-
class Permissions < Base
|
5
|
-
# Path Proc for hitting permissions end point
|
6
|
-
PATH = Proc.new{|id| "/vehicles/#{id}/permissions"}
|
7
|
-
attr_reader :permissions
|
8
|
-
end
|
9
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Smartcar
|
2
|
-
# class to represent Tire Pressure response
|
3
|
-
#@attr [Number] back_left Last recorded tire pressure of the back left tire.
|
4
|
-
#@attr [Number] back_right Last recorded tire pressure of the back right tire.
|
5
|
-
#@attr [Number] front_left Last recorded tire pressure of the front left tire.
|
6
|
-
#@attr [Number] front_right Last recorded tire pressure of the front right tire.
|
7
|
-
|
8
|
-
class TirePressure < Base
|
9
|
-
# Path Proc for hitting tire pressure end point
|
10
|
-
PATH = Proc.new{|id| "/vehicles/#{id}/tires/pressure"}
|
11
|
-
attr_reader :backLeft, :backRight, :frontLeft, :frontRight
|
12
|
-
|
13
|
-
# just to have Ruby-esque method names
|
14
|
-
alias_method :back_left, :backLeft
|
15
|
-
alias_method :back_right, :backRight
|
16
|
-
alias_method :front_left, :frontLeft
|
17
|
-
alias_method :front_right, :frontRight
|
18
|
-
end
|
19
|
-
end
|
data/lib/smartcar/user.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module Smartcar
|
2
|
-
# Class to get to user API.
|
3
|
-
#@attr [String] id Smartcar user id.
|
4
|
-
#@attr [String] token Access token used to connect to Smartcar API.
|
5
|
-
class User < Base
|
6
|
-
# Path for hitting user end point
|
7
|
-
USER_PATH = '/user'.freeze
|
8
|
-
attr_reader :id
|
9
|
-
|
10
|
-
# Class method Used to get user id
|
11
|
-
# EX : Smartcar::User.user_id
|
12
|
-
# API - https://smartcar.com/docs/api#get-user
|
13
|
-
# @param token [String] Access token
|
14
|
-
#
|
15
|
-
# @return [String] User ID
|
16
|
-
def self.user_id(token:, version: Smartcar.get_api_version)
|
17
|
-
# @deprecated Please use {#get} instead
|
18
|
-
warn "[DEPRECATION] `Smartcar::User.user_id` is deprecated and will be removed in next major version update. Please use `Smartcar::User.get` instead."
|
19
|
-
get(token: token, version: version).id
|
20
|
-
end
|
21
|
-
|
22
|
-
# Class method Used to get user id
|
23
|
-
# EX : Smartcar::User.get
|
24
|
-
# API - https://smartcar.com/docs/api#get-user
|
25
|
-
# @param token [String] Access token
|
26
|
-
#
|
27
|
-
# @return [User] User object
|
28
|
-
def self.get(token:, version: Smartcar.get_api_version)
|
29
|
-
user = new(token: token, version: version)
|
30
|
-
body, _meta = user.fetch(path: USER_PATH)
|
31
|
-
user.instance_variable_set('@id', body['id'])
|
32
|
-
user
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Smartcar
|
2
|
-
# class to represent Vehicle attributes like make model year
|
3
|
-
#@attr [String] id Smartcar vehicle ID
|
4
|
-
#@attr [String] make Manufacturer of the vehicle.
|
5
|
-
#@attr [String] model Model of the vehicle.
|
6
|
-
#@attr [Number] year Model year of the vehicle.
|
7
|
-
class VehicleAttributes < Base
|
8
|
-
# Path Proc for hitting vehicle attributes end point
|
9
|
-
PATH = Proc.new{|id| "/vehicles/#{id}"}
|
10
|
-
attr_accessor :id, :make, :model, :year
|
11
|
-
end
|
12
|
-
end
|
data/lib/smartcar/vin.rb
DELETED