smartcar 2.1.0 → 3.0.0
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 -20
- data/README.md +38 -36
- data/Rakefile +11 -3
- data/bin/console +4 -3
- data/lib/open_struct_extensions.rb +21 -0
- data/lib/smartcar.rb +173 -43
- data/lib/smartcar/auth_client.rb +154 -0
- data/lib/smartcar/base.rb +21 -29
- data/lib/smartcar/utils.rb +107 -35
- data/lib/smartcar/vehicle.rb +183 -252
- data/lib/smartcar/version.rb +3 -1
- data/lib/smartcar_error.rb +49 -0
- data/ruby-sdk.gemspec +27 -21
- metadata +71 -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 -26
- 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,26 +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, :token
|
9
|
-
|
10
|
-
def initialize(token:)
|
11
|
-
raise InvalidParameterValue.new, "Access Token(token) is a required field" if token.nil?
|
12
|
-
@token = token
|
13
|
-
end
|
14
|
-
|
15
|
-
# Class method Used to get user id
|
16
|
-
# EX : Smartcar::User.fetch
|
17
|
-
# API - https://smartcar.com/docs/api#get-user
|
18
|
-
# @param token [String] Access token
|
19
|
-
#
|
20
|
-
# @return [User] object
|
21
|
-
def self.user_id(token:)
|
22
|
-
new(token: token).get(USER_PATH)['id']
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
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