smartcar 3.3.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/smartcar/vehicle.rb +20 -0
- data/lib/smartcar/version.rb +1 -1
- data/lib/smartcar_error.rb +2 -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: c3ad3ad7082e2d27def7f0ee201f1b8f8b20eb25d3f17fffe71aecbb666dab87
|
4
|
+
data.tar.gz: ce9c4420338126a9cd6a22b2ae2da01f2ef9b469aaeb7df5a160377e54d939ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61339cf13180062815aca1ed833d5761a0c3613595818526fc9f247e44a23d4e76f547f859c769a5bdd90917ef3e77f74048ad624806aefe8a060331b13eb2a7
|
7
|
+
data.tar.gz: 9974454e496f5e67cb7bf121e696fea11c0b1ab22583a521293fcb42e750cfc70073efb33e63f1c8c2b11f77ddb1afc23f56904b7a6de2e8f03348c62fe6f0df
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smartcar (3.
|
4
|
+
smartcar (3.5.0)
|
5
5
|
oauth2 (~> 1.4)
|
6
6
|
recursive-open-struct (~> 1.1.3)
|
7
7
|
|
@@ -20,15 +20,15 @@ GEM
|
|
20
20
|
rexml
|
21
21
|
diff-lcs (1.5.0)
|
22
22
|
docile (1.4.0)
|
23
|
-
faraday (2.
|
23
|
+
faraday (2.4.0)
|
24
24
|
faraday-net_http (~> 2.0)
|
25
25
|
ruby2_keywords (>= 0.0.4)
|
26
|
-
faraday-net_http (2.0
|
26
|
+
faraday-net_http (2.1.0)
|
27
27
|
hashdiff (1.0.1)
|
28
|
-
jwt (2.
|
28
|
+
jwt (2.4.1)
|
29
29
|
multi_json (1.15.0)
|
30
30
|
multi_xml (0.6.0)
|
31
|
-
oauth2 (1.4.
|
31
|
+
oauth2 (1.4.10)
|
32
32
|
faraday (>= 0.17.3, < 3.0)
|
33
33
|
jwt (>= 1.0, < 3.0)
|
34
34
|
multi_json (~> 1.3)
|
data/lib/smartcar/vehicle.rb
CHANGED
@@ -52,11 +52,18 @@ module Smartcar
|
|
52
52
|
}
|
53
53
|
},
|
54
54
|
vin: { path: proc { |id| "/vehicles/#{id}/vin" } },
|
55
|
+
get_charge_limit: { path: proc { |id| "/vehicles/#{id}/charge/limit" } },
|
55
56
|
disconnect!: { type: :delete, path: proc { |id| "/vehicles/#{id}/application" } },
|
56
57
|
lock!: { type: :post, path: proc { |id| "/vehicles/#{id}/security" }, body: { action: 'LOCK' } },
|
57
58
|
unlock!: { type: :post, path: proc { |id| "/vehicles/#{id}/security" }, body: { action: 'UNLOCK' } },
|
58
59
|
start_charge!: { type: :post, path: proc { |id| "/vehicles/#{id}/charge" }, body: { action: 'START' } },
|
59
60
|
stop_charge!: { type: :post, path: proc { |id| "/vehicles/#{id}/charge" }, body: { action: 'STOP' } },
|
61
|
+
set_charge_limit!: {
|
62
|
+
type: :post,
|
63
|
+
path: proc { |id| "/vehicles/#{id}/charge/limit" },
|
64
|
+
body: proc { |limit| { limit: limit } },
|
65
|
+
skip: true
|
66
|
+
},
|
60
67
|
subscribe!: {
|
61
68
|
type: :post,
|
62
69
|
path: proc { |id, webhook_id| "/vehicles/#{id}/webhooks/#{webhook_id}" },
|
@@ -228,6 +235,19 @@ module Smartcar
|
|
228
235
|
build_response(response, headers)
|
229
236
|
end
|
230
237
|
|
238
|
+
# Set the charge limit for a given vehicle
|
239
|
+
#
|
240
|
+
# @param limit [float] A value between 0 and 1 denoting the charge limit to be set.
|
241
|
+
#
|
242
|
+
# @return [OpenStruct] Meta attribute with the relevant items from response headers.
|
243
|
+
def set_charge_limit!(limit)
|
244
|
+
path = METHODS.dig(:set_charge_limit!, :path).call(id)
|
245
|
+
body = METHODS.dig(:set_charge_limit!, :body).call(limit)
|
246
|
+
|
247
|
+
response, headers = post(path, {}, body)
|
248
|
+
build_response(response, headers)
|
249
|
+
end
|
250
|
+
|
231
251
|
# Method to get batch requests.
|
232
252
|
# API - https://smartcar.com/docs/api#post-batch-request
|
233
253
|
# @param paths [Array] Array of paths as strings. Ex ['/battery', '/odometer']
|
data/lib/smartcar/version.rb
CHANGED
data/lib/smartcar_error.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Custom SmartcarError class to represent errors from Smartcar APIs.
|
4
4
|
class SmartcarError < StandardError
|
5
|
-
attr_reader :code, :status_code, :request_id, :type, :description, :doc_url, :resolution, :detail
|
5
|
+
attr_reader :code, :status_code, :request_id, :type, :description, :doc_url, :resolution, :detail, :retry_after
|
6
6
|
|
7
7
|
def initialize(status, body, headers)
|
8
8
|
@status_code = status
|
@@ -11,6 +11,7 @@ class SmartcarError < StandardError
|
|
11
11
|
@request_id = headers['sc-request-id']
|
12
12
|
return
|
13
13
|
end
|
14
|
+
@retry_after = headers['retry-after']
|
14
15
|
body = coerce_attributes(body)
|
15
16
|
|
16
17
|
super("#{body[:type]}:#{body[:code]} - #{body[:description]}")
|
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: 3.
|
4
|
+
version: 3.5.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: 2023-
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|