smartcar 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/smartcar.rb +4 -4
- data/lib/smartcar/base.rb +2 -2
- data/lib/smartcar/user.rb +4 -4
- data/lib/smartcar/vehicle.rb +6 -5
- data/lib/smartcar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b46d97dfaa2c543d0c5a5a7fbe7be668991babc0b0d35b81c432dc6ae3b3d06
|
4
|
+
data.tar.gz: 6e67faac4de5a809023fad29fba657bba0648a67978831d4c19a1a26e7bc039b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92f3f9cb5002eae3d5289d5e426a7954ca2f789a55f264360083f7a85a46d95279c63b516a6aa09b6661b5604afc33e38ddcf1c9d990429a8204e162930b684c
|
7
|
+
data.tar.gz: 9a33b2a71aa62207a38143383fb010b2bf557214f265d5fd2b3eb5e747d19627fc1cd5e33670e75539f34a3d9f10d6ea293818e68e239311b6ce93af3673734e
|
data/Gemfile.lock
CHANGED
data/lib/smartcar.rb
CHANGED
@@ -17,8 +17,8 @@ require "smartcar/vehicle"
|
|
17
17
|
require "smartcar/user"
|
18
18
|
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
# Main Smartcar umbrella module
|
21
|
+
module Smartcar
|
22
22
|
# Error raised when a config is not found
|
23
23
|
class ConfigNotFound < StandardError; end
|
24
24
|
# Error raised when Smartcar returns non 400, 404, 401, 200 or 204 response
|
@@ -29,8 +29,8 @@ require "smartcar/user"
|
|
29
29
|
class AuthenticationError < ExternalServiceError; end
|
30
30
|
# Error raised when Smartcar returns 400 response
|
31
31
|
class BadRequestError < ExternalServiceError; end
|
32
|
-
# Smartcar API version
|
33
|
-
|
32
|
+
# Smartcar API version - default version.
|
33
|
+
DEFAULT_API_VERSION = "v1.0".freeze
|
34
34
|
# Host to connect to smartcar
|
35
35
|
SITE = "https://api.smartcar.com/".freeze
|
36
36
|
|
data/lib/smartcar/base.rb
CHANGED
@@ -15,7 +15,7 @@ module Smartcar
|
|
15
15
|
# Number of seconds to wait for response
|
16
16
|
REQUEST_TIMEOUT = 310
|
17
17
|
|
18
|
-
attr_accessor :token, :error, :meta, :unit_system
|
18
|
+
attr_accessor :token, :error, :meta, :unit_system, :version
|
19
19
|
|
20
20
|
%i{get post patch put delete}.each do |verb|
|
21
21
|
# meta programming and define all Restful methods.
|
@@ -29,7 +29,7 @@ module Smartcar
|
|
29
29
|
request.headers['Authorization'] = "BASIC #{get_basic_auth}" if data[:auth] == BASIC
|
30
30
|
request.headers['sc-unit-system'] = unit_system if unit_system
|
31
31
|
request.headers['Content-Type'] = "application/json"
|
32
|
-
complete_path = "/#{
|
32
|
+
complete_path = "/#{version}#{path}"
|
33
33
|
if verb==:get
|
34
34
|
request.url complete_path, data
|
35
35
|
else
|
data/lib/smartcar/user.rb
CHANGED
@@ -13,10 +13,10 @@ module Smartcar
|
|
13
13
|
# @param token [String] Access token
|
14
14
|
#
|
15
15
|
# @return [String] User ID
|
16
|
-
def self.user_id(token:)
|
16
|
+
def self.user_id(token:, version: DEFAULT_API_VERSION)
|
17
17
|
# @deprecated Please use {#get} instead
|
18
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).id
|
19
|
+
get(token: token, version: version).id
|
20
20
|
end
|
21
21
|
|
22
22
|
# Class method Used to get user id
|
@@ -25,8 +25,8 @@ module Smartcar
|
|
25
25
|
# @param token [String] Access token
|
26
26
|
#
|
27
27
|
# @return [User] User object
|
28
|
-
def self.get(token:)
|
29
|
-
user = new(token: token)
|
28
|
+
def self.get(token:, version: DEFAULT_API_VERSION)
|
29
|
+
user = new(token: token, version: version)
|
30
30
|
body, _meta = user.fetch(path: USER_PATH)
|
31
31
|
user.instance_variable_set('@id', body['id'])
|
32
32
|
user
|
data/lib/smartcar/vehicle.rb
CHANGED
@@ -16,13 +16,14 @@ module Smartcar
|
|
16
16
|
|
17
17
|
attr_reader :id
|
18
18
|
|
19
|
-
def initialize(token:, id:, unit_system: IMPERIAL)
|
19
|
+
def initialize(token:, id:, unit_system: IMPERIAL, version: DEFAULT_API_VERSION)
|
20
20
|
raise InvalidParameterValue.new, "Invalid Units provided : #{unit_system}" unless UNITS.include?(unit_system)
|
21
21
|
raise InvalidParameterValue.new, "Vehicle ID (id) is a required field" if id.nil?
|
22
22
|
raise InvalidParameterValue.new, "Access Token(token) is a required field" if token.nil?
|
23
23
|
@token = token
|
24
24
|
@id = id
|
25
25
|
@unit_system = unit_system
|
26
|
+
@version = version
|
26
27
|
end
|
27
28
|
|
28
29
|
# Class method Used to get all the vehicles in the app. This only returns
|
@@ -31,8 +32,8 @@ module Smartcar
|
|
31
32
|
# @param options [Hash] - Optional filter parameters (check documentation)
|
32
33
|
#
|
33
34
|
# @return [Array] of vehicle IDs(Strings)
|
34
|
-
def self.all_vehicle_ids(token:, options: {})
|
35
|
-
response,
|
35
|
+
def self.all_vehicle_ids(token:, options: {}, version: DEFAULT_API_VERSION)
|
36
|
+
response, meta = new(token: token, id: 'none', version: version).fetch(
|
36
37
|
path: PATH.call(''),
|
37
38
|
options: options
|
38
39
|
)
|
@@ -48,11 +49,11 @@ module Smartcar
|
|
48
49
|
# Defaults to US.
|
49
50
|
#
|
50
51
|
# @return [Boolean] true or false
|
51
|
-
def self.compatible?(vin:, scope:, country: 'US')
|
52
|
+
def self.compatible?(vin:, scope:, country: 'US', version: DEFAULT_API_VERSION)
|
52
53
|
raise InvalidParameterValue.new, "vin is a required field" if vin.nil?
|
53
54
|
raise InvalidParameterValue.new, "scope is a required field" if scope.nil?
|
54
55
|
|
55
|
-
response, meta = new(token: 'none', id: 'none').fetch(path: COMPATIBLITY_PATH,
|
56
|
+
response, meta = new(token: 'none', id: 'none', version: version).fetch(path: COMPATIBLITY_PATH,
|
56
57
|
options: {
|
57
58
|
vin: vin,
|
58
59
|
scope: scope.join(' '),
|
data/lib/smartcar/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartcar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashwin Subramanian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|