ax-track 0.1.6 → 0.1.11
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/README.md +5 -2
- data/bin/console +1 -1
- data/lib/ax_track/client.rb +4 -0
- data/lib/ax_track/objects/tracker.rb +25 -11
- 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: 0b806d59d64c2fbc85c9d6dc0fd9bbb364fd817276d1c8b35ef59b8eb8cb8b19
|
4
|
+
data.tar.gz: 4316ccfdccf8e0e13f6116099a7ab7af70261cd8899c6eadee9c7517fac3ffe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 558c705bc452ab1362c1419f98b2b368f633d0d518d9ebf2cbf9ee09bffbaade1fa9372f45ac283fa61ee07e367e9ccb20de24f7b45d20c99c308a2d1a8ffd83
|
7
|
+
data.tar.gz: aab5a0b04004c6101c840f3dcaf5f47bbca15c756b211e67dc35dde2f696794eef1bd7d38536973f63f894e7161004f0cd5e18368fafb19371a09c592378f298
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
# AxTrack
|
1
|
+
# AxTrack API Ruby Wrapper
|
2
2
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/axTrack`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
7
|
+
## Open questions
|
8
|
+
* how do I know what type of sensors are available.
|
9
|
+
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
Add this line to your application's Gemfile:
|
@@ -23,7 +26,7 @@ Or install it yourself as:
|
|
23
26
|
## Usage
|
24
27
|
|
25
28
|
```ruby
|
26
|
-
client
|
29
|
+
client = AxTrack::Client.new(api_key: your_api_key)
|
27
30
|
```
|
28
31
|
|
29
32
|
### Trackers
|
data/bin/console
CHANGED
data/lib/ax_track/client.rb
CHANGED
@@ -9,10 +9,14 @@ module AxTrack
|
|
9
9
|
|
10
10
|
BASE_URL = 'https://prod.api.ax-track.ch/api/v1'.freeze
|
11
11
|
|
12
|
+
APIKeyMissing = Class.new(StandardError)
|
13
|
+
|
12
14
|
attr_reader :api_key, :adapter
|
13
15
|
def initialize(api_key: ENV['AXTRACK_API_KEY'], adapter: Faraday.default_adapter)
|
14
16
|
@api_key = api_key
|
15
17
|
@adapter = adapter
|
18
|
+
|
19
|
+
raise APIKeyMissing, "No API key provided" if !defined?(api_key) || api_key.nil? || api_key.empty?
|
16
20
|
end
|
17
21
|
|
18
22
|
def trackers
|
@@ -2,25 +2,39 @@ module AxTrack
|
|
2
2
|
class Tracker < Object
|
3
3
|
|
4
4
|
def initialize(json_response)
|
5
|
-
@
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
5
|
+
@tracker_id = json_response['id']
|
6
|
+
@asset_id = json_response['asset']
|
7
|
+
@identifier = json_response['identifier']
|
8
|
+
@url = json_response['url']
|
9
|
+
@active = json_response['active']
|
10
|
+
@model = json_response['model']
|
11
|
+
@asset_details = Asset.new json_response['asset_details'] if json_response['asset_details']
|
12
|
+
@name = json_response.dig('asset_details', 'name')
|
11
13
|
@last_message_timestamp = DateTime.parse(json_response['last_message_timestamp'], false) if json_response['last_message_timestamp']
|
12
|
-
@url
|
14
|
+
@url = json_response['url']
|
15
|
+
@user_url = website_url
|
13
16
|
@last_gps_position = GPSPosition.new(json_response['last_gps_measurement'] || json_response['asset_details'])
|
14
17
|
|
15
|
-
@battery
|
18
|
+
@battery = json_response.dig('asset_details', 'sensor_data', 'battery', 'value')
|
19
|
+
sensor_data = json_response.dig('asset_details', 'sensor_data')
|
16
20
|
|
17
|
-
sensor_data
|
18
|
-
sensor_data.delete('battery')
|
19
|
-
@sensor_data = sensor_data
|
21
|
+
@sensor_data = sensor_data
|
20
22
|
|
21
23
|
create_getters
|
22
24
|
end
|
23
25
|
|
26
|
+
def available_sensor_data
|
27
|
+
# returns a hash with available senson data
|
28
|
+
sensor_data_temp = self.sensor_data.keys
|
29
|
+
sensor_data_temp = sensor_data_temp.unshift('gps') if self.respond_to? :last_gps_position
|
30
|
+
sensor_data_temp
|
31
|
+
end
|
32
|
+
|
33
|
+
def website_url
|
34
|
+
"https://app.ax-track.ch/#/map/assets/#{@tracker_id}"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
24
38
|
class GPSPosition < Object
|
25
39
|
|
26
40
|
def initialize(json_response)
|
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: 0.1.
|
4
|
+
version: 0.1.11
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|