ax-track 0.1.6 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '02813bb03bbdae12acc66ad967ab18af1dbe704c1c5e6dcdd9050ae50920f859'
4
- data.tar.gz: a01c20a2eae5bbcfc115657eae3bfc7bd16a3f1a5a54cfc5161d241f547f0f0c
3
+ metadata.gz: 0b806d59d64c2fbc85c9d6dc0fd9bbb364fd817276d1c8b35ef59b8eb8cb8b19
4
+ data.tar.gz: 4316ccfdccf8e0e13f6116099a7ab7af70261cd8899c6eadee9c7517fac3ffe6
5
5
  SHA512:
6
- metadata.gz: 3fdd57611cf426cda622a067d98f2e30c97f2649e9d440019f245de167480667072ab01386a839a952f58bf539e83418684c91fc69e7c1ae99388ca84ed1f9bc
7
- data.tar.gz: 5102fb92eb961a55f2a1dfd7341c27f1d79a11f231499ba9e0809eb21d62001c5491faae9e908031ca922d94e67991e3c468e26431b00d06d224374845300e3d
6
+ metadata.gz: 558c705bc452ab1362c1419f98b2b368f633d0d518d9ebf2cbf9ee09bffbaade1fa9372f45ac283fa61ee07e367e9ccb20de24f7b45d20c99c308a2d1a8ffd83
7
+ data.tar.gz: aab5a0b04004c6101c840f3dcaf5f47bbca15c756b211e67dc35dde2f696794eef1bd7d38536973f63f894e7161004f0cd5e18368fafb19371a09c592378f298
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ax-track (0.1.6)
4
+ ax-track (0.1.11)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
7
 
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 == AxTrack::Client.new(api_key: your_api_key)
29
+ client = AxTrack::Client.new(api_key: your_api_key)
27
30
  ```
28
31
 
29
32
  ### Trackers
data/bin/console CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "bundler/setup"
5
- require "ax_track"
5
+ require "ax-track"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -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
- @id = json_response['id']
6
- @url = json_response['url']
7
- @active = json_response['active']
8
- @model = json_response['model']
9
- @axtrack_asset_id = json_response['asset']
10
- @name = json_response.dig('asset_details', 'name')
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 = json_response['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 = json_response.dig('asset_details', 'sensor_data', 'battery', 'value')
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 = json_response.dig('asset_details', '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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AxTrack
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.11"
5
5
  end
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.6
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-04 00:00:00.000000000 Z
11
+ date: 2021-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday