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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6df6669e5c15f39ac72709670832be91b8b2aa935ffa593816a18dbe9958eb3
4
- data.tar.gz: a24adc8735234811a9d89a6bebe76d0fac0be474b64641e825e9af67f535305b
3
+ metadata.gz: 95e294f6bd99ab7e87c04391742d8f670ade8cb020c53fac68eb0a5849bc5675
4
+ data.tar.gz: 960a6e7a575c81141cec86665ed328599cadf98afe5c28260a53e78e2b075bbf
5
5
  SHA512:
6
- metadata.gz: 59dfcb20ad49c457b93e4c4705164703ce31154a924f7a6a654aae15a6015d94de8ad96b6ec75498b17a7ca5f596a3c53eb91ff034a7be3e497898e598776984
7
- data.tar.gz: c2115e2ae5e4e1b138df9889c33ff903d966b4208e8e39b75196f77284819a05d423180d1b49a42b440d2a40a3776028bd061d864223d86e474790c2d98b0502
6
+ metadata.gz: 86d54e1f259fbb4486d9bc5e465ae3ad322055dc29ab0588c04677975e0d73f8e93ce6337ae288cc0e3fbcc45c6efcc89f158485826c3503209c6b8f1e954b59
7
+ data.tar.gz: ce387bfd144fc624417b4dae73148303dfe87be436643ab4df523c49ef46f3ff8fc0d881338c52ee4027f243eebdcc1861e3ed28631fdd4ea539c35e4025c133
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ax-track (0.2)
4
+ ax-track (0.2.5)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
7
 
@@ -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/#{@tracker_id}"
35
+ "https://app.ax-track.ch/#/map/assets/#{@id}"
27
36
  end
28
37
 
29
38
  def available_sensor_data
@@ -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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AxTrack
4
- VERSION = "0.2"
4
+ VERSION = "0.2.5"
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.2'
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-16 00:00:00.000000000 Z
11
+ date: 2021-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday