ax-track 0.2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ax_track/client.rb +2 -1
- data/lib/ax_track/objects/tracker.rb +11 -2
- data/lib/ax_track/resource.rb +6 -1
- data/lib/ax_track/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: 95e294f6bd99ab7e87c04391742d8f670ade8cb020c53fac68eb0a5849bc5675
|
4
|
+
data.tar.gz: 960a6e7a575c81141cec86665ed328599cadf98afe5c28260a53e78e2b075bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86d54e1f259fbb4486d9bc5e465ae3ad322055dc29ab0588c04677975e0d73f8e93ce6337ae288cc0e3fbcc45c6efcc89f158485826c3503209c6b8f1e954b59
|
7
|
+
data.tar.gz: ce387bfd144fc624417b4dae73148303dfe87be436643ab4df523c49ef46f3ff8fc0d881338c52ee4027f243eebdcc1861e3ed28631fdd4ea539c35e4025c133
|
data/Gemfile.lock
CHANGED
data/lib/ax_track/client.rb
CHANGED
@@ -12,6 +12,8 @@ module AxTrack
|
|
12
12
|
APIKeyMissing = Class.new(StandardError)
|
13
13
|
|
14
14
|
attr_reader :api_key, :adapter
|
15
|
+
attr_writer :connection
|
16
|
+
|
15
17
|
def initialize(api_key: nil, adapter: nil, stubs: nil)
|
16
18
|
@api_key = api_key || ENV['AXTRACK_API_KEY']
|
17
19
|
@adapter = adapter || Faraday.default_adapter
|
@@ -38,6 +40,5 @@ module AxTrack
|
|
38
40
|
conn.headers['Authorization'] = "Token #{api_key}" unless api_key.empty?
|
39
41
|
end
|
40
42
|
end
|
41
|
-
|
42
43
|
end
|
43
44
|
end
|
@@ -6,6 +6,10 @@ module AxTrack
|
|
6
6
|
@asset_details
|
7
7
|
end
|
8
8
|
|
9
|
+
def asset_id
|
10
|
+
asset_details.id
|
11
|
+
end
|
12
|
+
|
9
13
|
def name
|
10
14
|
@name = @asset_details['name']
|
11
15
|
end
|
@@ -15,15 +19,20 @@ module AxTrack
|
|
15
19
|
end
|
16
20
|
|
17
21
|
def last_gps_position
|
18
|
-
GPSPosition.new(@last_gps_measurement || { lat: asset_details.lat, lng: asset_details.lng } )
|
22
|
+
#GPSPosition.new(@last_gps_measurement || { lat: asset_details.lat, lng: asset_details.lng } )
|
23
|
+
GPSPosition.new(@last_gps_measurement)
|
19
24
|
end
|
20
25
|
|
21
26
|
def battery
|
22
27
|
asset_details&.sensor_data.dig('battery', 'value')
|
23
28
|
end
|
24
29
|
|
30
|
+
def sensor_data
|
31
|
+
asset_details.sensor_data
|
32
|
+
end
|
33
|
+
|
25
34
|
def website_url
|
26
|
-
"https://app.ax-track.ch/#/map/assets/#{@
|
35
|
+
"https://app.ax-track.ch/#/map/assets/#{@id}"
|
27
36
|
end
|
28
37
|
|
29
38
|
def available_sensor_data
|
data/lib/ax_track/resource.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module AxTrack
|
3
2
|
class Resource
|
4
3
|
attr_reader :client, :response
|
@@ -27,6 +26,12 @@ module AxTrack
|
|
27
26
|
def request(http_method: :get, endpoint:, headers: {}, params: {}, body: {}, result_subset: nil)
|
28
27
|
raise "Client not defined" unless defined? @client
|
29
28
|
endpoint = endpoint + "/" unless endpoint[-1] == "/"
|
29
|
+
|
30
|
+
if body.keys.include?(:picture)
|
31
|
+
body[:picture] = Faraday::FilePart.new(body[:picture].url, body[:picture].content_type, body[:picture].filename)
|
32
|
+
end
|
33
|
+
|
34
|
+
# client.connection['headers']['Content-Type'] = 'multipart/form-data' if body.key? :picture
|
30
35
|
@response = client.connection.public_send(http_method, endpoint, params.merge(body))
|
31
36
|
|
32
37
|
unless response_successful?
|
data/lib/ax_track/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ax-track
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Baumann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|