ax-track 0.1.4 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b614baf18c905b887c8139e5550cddf5e398292d7d2a4a4dc2ee1fea5eb3467
4
- data.tar.gz: 4677ce321f9141b043fd5eba0641577bffb20c0762b65063ca4e3257e945d87d
3
+ metadata.gz: df8a0965e6d150c1d817952ef21243d4c6cde5de9982da627c7eaf62c5612ae4
4
+ data.tar.gz: 15880392636fdd11ca36bd70d17f44862afe9b09a0bc464a70e5fd5e6c31089b
5
5
  SHA512:
6
- metadata.gz: 4392d18959eba1b976967739c4f78e6e07aab07f98f85249623cd63afcd5c7f72ffd17535c150c2ebfe7d87c086f89700cbcac3f6cb3c0eefc3f1d9ee4cdba12
7
- data.tar.gz: d30ae7869e06a8f07e407f3d2b67b5acceb4e22cd77002399f2d23881da9cab6d12a56dd9879f0a16661a02d600ea563f57918af41a074d36a1e3173cc5e1f3c
6
+ metadata.gz: 0daa74bd47a6ce1f42748d80eaf539ef8f4d93d92e8ef56b1839965b6950187ed9323cc747ffde2de8e276bb7e848ed5ffe7825b05eb20ece53be981e004a6c1
7
+ data.tar.gz: 9674635ea14e6987405f9a5ca0b1ce79e030008af98393f620fea3c5dceca6c1ad4075867472d3073b9c5e80fa1426cf05bee4265dcd99bc69d57c48e1177e0c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ax-track (0.1.4)
4
+ ax-track (0.1.9)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
7
 
data/README.md CHANGED
@@ -1,15 +1,18 @@
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:
10
13
 
11
14
  ```ruby
12
- gem 'axTrack'
15
+ gem 'ax-track'
13
16
  ```
14
17
 
15
18
  And then execute:
@@ -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.
File without changes
@@ -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,14 +2,16 @@ module AxTrack
2
2
  class Tracker < Object
3
3
 
4
4
  def initialize(json_response)
5
- @id = json_response['id']
5
+ @tracker_id = json_response['id']
6
+ @asset_id = json_response['asset']
6
7
  @url = json_response['url']
7
8
  @active = json_response['active']
8
9
  @model = json_response['model']
9
- @axtrack_asset_id = json_response['asset']
10
+ @asset_details = Asset.new json_response['asset_details'] if json_response['asset_details']
10
11
  @name = json_response.dig('asset_details', 'name')
11
12
  @last_message_timestamp = DateTime.parse(json_response['last_message_timestamp'], false) if json_response['last_message_timestamp']
12
13
  @url = json_response['url']
14
+ @user_url = website_url(@asset_id)
13
15
  @last_gps_position = GPSPosition.new(json_response['last_gps_measurement'] || json_response['asset_details'])
14
16
 
15
17
  @battery = json_response.dig('asset_details', 'sensor_data', 'battery', 'value')
@@ -21,6 +23,16 @@ module AxTrack
21
23
  create_getters
22
24
  end
23
25
 
26
+ def available_sensor_data
27
+ # returns a hash with available senson data
28
+ self.sensor_data.keys
29
+ end
30
+
31
+ def website_url
32
+ "https://app.ax-track.ch/#/map/assets/#{id}"
33
+ end
34
+
35
+
24
36
  class GPSPosition < Object
25
37
 
26
38
  def initialize(json_response)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AxTrack
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.9"
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.4
4
+ version: 0.1.9
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
@@ -57,7 +57,7 @@ files:
57
57
  - ax_track.gemspec
58
58
  - bin/console
59
59
  - bin/setup
60
- - lib/ax_track.rb
60
+ - lib/ax-track.rb
61
61
  - lib/ax_track/client.rb
62
62
  - lib/ax_track/collection.rb
63
63
  - lib/ax_track/error.rb