smartcar 1.0.5 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +18 -3
- data/lib/smartcar/oauth.rb +6 -2
- data/lib/smartcar/vehicle.rb +6 -2
- data/lib/smartcar/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20f8c410ca2e09b81f481f66f8790b9040688dec92973825d7a7ba72cec14a7d
|
4
|
+
data.tar.gz: 5c748df1b3c987a00df29e1f7f65ae8c89c76ad7473acfc8135c27ddad94fe15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bdbd39d8887437f76f53ccea2cdc8f6ae618d5a13558713c44b74ca21ab01fbe960b8d8b66104ace8df1a4c3de2d8a2308e3fe6ec000c9a80b721abda0fca09
|
7
|
+
data.tar.gz: 71f27cea632e1578e878f9bb6c7caa921890236515facc7435f6b17aa2faa1c198c8e7bfd4064fd90ec37ee2533d31aae362b1f0c13ce867b43380d3add3fcbc
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -107,10 +107,10 @@ Smartcar::ExternalServiceError (API error - {"error":"vehicle_state_error","mess
|
|
107
107
|
Example Usage for oAuth -
|
108
108
|
```ruby
|
109
109
|
# To get the redirect URL :
|
110
|
-
2.5.5 :002 > options = {test_mode: true,scope: ["read_battery","read_charge","read_fuel","read_location","control_security","read_odometer","read_tires","read_vin","read_vehicle_info"]}
|
110
|
+
2.5.5 :002 > options = {test_mode: true,scope: ["read_battery","read_charge","read_fuel","read_location","control_security","read_odometer","read_tires","read_vin","read_vehicle_info"],flags: ["country:DE"]}
|
111
111
|
2.5.5 :003 > require 'smartcar'
|
112
112
|
2.5.5 :004 > url = Smartcar::Oauth.authorization_url(options)
|
113
|
-
=> "https://connect.smartcar.com/oauth/authorize?approval_prompt=auto&client_id=2715c6b2-eba8-4fda-85b1-8d849733a344&mode=test&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fcallback&response_type=code&scope=read_battery+read_charge+read_fuel+read_location+control_security+read_odometer+read_tires+read_vin+read_vehicle_info"
|
113
|
+
=> "https://connect.smartcar.com/oauth/authorize?approval_prompt=auto&client_id=2715c6b2-eba8-4fda-85b1-8d849733a344&mode=test&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fcallback&response_type=code&scope=read_battery+read_charge+read_fuel+read_location+control_security+read_odometer+read_tires+read_vin+read_vehicle_info&flags=country%3ADE"
|
114
114
|
# Redirect user to the above URL.
|
115
115
|
# After authentication user control reaches the callback URL with code.
|
116
116
|
# Use the code from the parameters and request a token
|
@@ -123,7 +123,7 @@ Example Usage for oAuth -
|
|
123
123
|
|
124
124
|
## Development
|
125
125
|
|
126
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
126
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
127
127
|
|
128
128
|
To run tests, make sure you have the env variables setup for client id and secret.
|
129
129
|
```shell
|
@@ -135,6 +135,21 @@ Tests can be run using either default rake command OR specific rspec command.
|
|
135
135
|
```ruby
|
136
136
|
bundle exec rake spec
|
137
137
|
```
|
138
|
+
|
139
|
+
Releasing to rubygems right now cannot be automated because of MFA ([source](https://github.com/rubygems/rubygems/issues/3092)). For now the process is to run the gem build and push commands locally and manually enter in the Rubygems MFA code (available on 1password). Steps for that would be :
|
140
|
+
|
141
|
+
```
|
142
|
+
# After merging to master, checkout to master and pull code locally, then run the following
|
143
|
+
gem build
|
144
|
+
Successfully built RubyGem
|
145
|
+
Name: smartcar
|
146
|
+
Version: <version>
|
147
|
+
File: smartcar-<version>.gem
|
148
|
+
# now push the gem built by the build command. This would ask for the MFA code
|
149
|
+
gem push smartcar-<version>.gem
|
150
|
+
```
|
151
|
+
In general it is a good advice to create a tag for every release. If not for the above mentioned MFA bug, creating a tag for a commit on master and pushing the tag would trigger travis to deploy to rubygems automatically.
|
152
|
+
|
138
153
|
## Contributing
|
139
154
|
|
140
155
|
To contribute, please:
|
data/lib/smartcar/oauth.rb
CHANGED
@@ -27,6 +27,7 @@ module Smartcar
|
|
27
27
|
# @option options[:scope] [Array of Strings] - array of scopes that specify what the user can access
|
28
28
|
# EXAMPLE : ['read_odometer', 'read_vehicle_info', 'required:read_location']
|
29
29
|
# For further details refer to https://smartcar.com/docs/guides/scope/
|
30
|
+
# @option options[:flags] [Array of Strings] - an optional array of early access features to enable.
|
30
31
|
#
|
31
32
|
# @return [Smartcar::Oauth] Returns a Smartcar::Oauth Object that has other methods
|
32
33
|
def initialize(options)
|
@@ -40,9 +41,12 @@ module Smartcar
|
|
40
41
|
mode: options[:test_mode] ? TEST : LIVE,
|
41
42
|
response_type: CODE
|
42
43
|
}
|
43
|
-
|
44
|
+
|
45
|
+
%I(scope flags).each do |parameter|
|
46
|
+
@auth_parameters[parameter] = options[parameter].join(' ') unless options[parameter].nil?
|
47
|
+
end
|
44
48
|
%I(state make).each do |parameter|
|
45
|
-
|
49
|
+
@auth_parameters[parameter] = options[parameter] unless options[parameter].nil?
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
data/lib/smartcar/vehicle.rb
CHANGED
@@ -47,16 +47,20 @@ module Smartcar
|
|
47
47
|
# API - https://smartcar.com/docs/api#connect-compatibility
|
48
48
|
# @param vin [String] VIN of the vehicle to be checked
|
49
49
|
# @param scope [Array of Strings] - array of scopes
|
50
|
+
# @param country [String] An optional country code according to
|
51
|
+
# [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
|
52
|
+
# Defaults to US.
|
50
53
|
#
|
51
54
|
# @return [Boolean] true or false
|
52
|
-
def self.compatible?(vin:, scope:)
|
55
|
+
def self.compatible?(vin:, scope:, country: 'US')
|
53
56
|
raise InvalidParameterValue.new, "vin is a required field" if vin.nil?
|
54
57
|
raise InvalidParameterValue.new, "scope is a required field" if scope.nil?
|
55
58
|
|
56
59
|
response, meta = new(token: 'none', id: 'none').fetch(path: COMPATIBLITY_PATH,
|
57
60
|
options: {
|
58
61
|
vin: vin,
|
59
|
-
scope: scope.join(' ')
|
62
|
+
scope: scope.join(' '),
|
63
|
+
country: country
|
60
64
|
},
|
61
65
|
auth: BASIC
|
62
66
|
)
|
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: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashwin Subramanian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
|
-
rubygems_version: 3.
|
176
|
+
rubygems_version: 3.0.8
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Ruby Gem to access smartcar APIs (https://smartcar.com/docs/)
|