smartcar 2.2.0 → 2.3.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
  SHA256:
3
- metadata.gz: 8df9188b608db089e0225bdeaad7a7e585ec19ce0c2f8e024f16055c555c48cf
4
- data.tar.gz: e85c23cacda1e774df87a84a4d916f7675584e4cb1f8d43f20496d9e04d6c213
3
+ metadata.gz: 8b46d97dfaa2c543d0c5a5a7fbe7be668991babc0b0d35b81c432dc6ae3b3d06
4
+ data.tar.gz: 6e67faac4de5a809023fad29fba657bba0648a67978831d4c19a1a26e7bc039b
5
5
  SHA512:
6
- metadata.gz: fcce1b264d733d8abd2c5f0bb8fd84c2edd219ac45d1303b04deb0b5b2257b6a301cdeeb4e1c415ffbf8f339fd8543095e9d5897237f68e4e43e625f1e0f49c7
7
- data.tar.gz: 3283ea8c41227ef0d46503b2b78be6581eadd6fc9c1d2b81e0f80ae65c06a868461040f0cb260a464cd966587fb491d826efea10a557928d94fe71ce82091d8a
6
+ metadata.gz: 92f3f9cb5002eae3d5289d5e426a7954ca2f789a55f264360083f7a85a46d95279c63b516a6aa09b6661b5604afc33e38ddcf1c9d990429a8204e162930b684c
7
+ data.tar.gz: 9a33b2a71aa62207a38143383fb010b2bf557214f265d5fd2b3eb5e747d19627fc1cd5e33670e75539f34a3d9f10d6ea293818e68e239311b6ce93af3673734e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smartcar (2.2.0)
4
+ smartcar (2.3.0)
5
5
  oauth2 (~> 1.4)
6
6
 
7
7
  GEM
@@ -60,4 +60,4 @@ DEPENDENCIES
60
60
  smartcar!
61
61
 
62
62
  BUNDLED WITH
63
- 2.1.2
63
+ 2.1.4
data/lib/smartcar.rb CHANGED
@@ -17,8 +17,8 @@ require "smartcar/vehicle"
17
17
  require "smartcar/user"
18
18
 
19
19
 
20
- # Main Smartcar umbrella module
21
- module Smartcar
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 being used
33
- API_VERSION = "v1.0".freeze
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 = "/#{API_VERSION}#{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
@@ -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, _meta = new(token: token, id: 'none').fetch(
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(' '),
@@ -1,4 +1,4 @@
1
1
  module Smartcar
2
2
  # Gem current version number
3
- VERSION = "2.2.0"
3
+ VERSION = "2.3.0"
4
4
  end
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.2.0
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-02 00:00:00.000000000 Z
11
+ date: 2021-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler