ax-track-ruby-client 0.1.0
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 +7 -0
- data/.github/workflows/main.yml +16 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +16 -0
- data/axTrack.gemspec +38 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/axTrack/client.rb +38 -0
- data/lib/axTrack/collection.rb +25 -0
- data/lib/axTrack/error.rb +4 -0
- data/lib/axTrack/object.rb +18 -0
- data/lib/axTrack/objects/asset.rb +14 -0
- data/lib/axTrack/objects/tracker.rb +37 -0
- data/lib/axTrack/resource.rb +61 -0
- data/lib/axTrack/resources/asset_resource.rb +23 -0
- data/lib/axTrack/resources/tracker_resource.rb +17 -0
- data/lib/axTrack/version.rb +5 -0
- data/lib/axTrack.rb +20 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e2aafcc13472293e19ebff4ca09a931f47337f139631f89679ef7b4ff4872ba3
|
4
|
+
data.tar.gz: b6f0fe9494ed96c5b88f1e33c09b2aa9ed99a073c18f2897607c5d8bc6375ec8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c74cc67d1a9ad6a8e5f356ebc460994a4b35767a631468603c4cc64aeb8289bb379a03d7194b5a236370dec40072ecd997a39491a5948065dc3714dc7d04a3e1
|
7
|
+
data.tar.gz: 25534232f081ac3cd8e9b6d0538b0136d2bd73f48e8f73fff292bf2a830faf1eb3229fc94756cb663ad772e1961b4c0a377fdf6403057484cb5fd0ebce4a81d3
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.7.2
|
14
|
+
bundler-cache: true
|
15
|
+
- name: Run the default task
|
16
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ax-track-ruby-client (0.1.0)
|
5
|
+
faraday (~> 1.7)
|
6
|
+
faraday_middleware (~> 1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.2)
|
12
|
+
faraday (1.8.0)
|
13
|
+
faraday-em_http (~> 1.0)
|
14
|
+
faraday-em_synchrony (~> 1.0)
|
15
|
+
faraday-excon (~> 1.1)
|
16
|
+
faraday-httpclient (~> 1.0.1)
|
17
|
+
faraday-net_http (~> 1.0)
|
18
|
+
faraday-net_http_persistent (~> 1.1)
|
19
|
+
faraday-patron (~> 1.0)
|
20
|
+
faraday-rack (~> 1.0)
|
21
|
+
multipart-post (>= 1.2, < 3)
|
22
|
+
ruby2_keywords (>= 0.0.4)
|
23
|
+
faraday-em_http (1.0.0)
|
24
|
+
faraday-em_synchrony (1.0.0)
|
25
|
+
faraday-excon (1.1.0)
|
26
|
+
faraday-httpclient (1.0.1)
|
27
|
+
faraday-net_http (1.0.1)
|
28
|
+
faraday-net_http_persistent (1.2.0)
|
29
|
+
faraday-patron (1.0.0)
|
30
|
+
faraday-rack (1.0.0)
|
31
|
+
faraday_middleware (1.1.0)
|
32
|
+
faraday (~> 1.0)
|
33
|
+
minitest (5.14.4)
|
34
|
+
multipart-post (2.1.1)
|
35
|
+
parallel (1.21.0)
|
36
|
+
parser (3.0.2.0)
|
37
|
+
ast (~> 2.4.1)
|
38
|
+
rainbow (3.0.0)
|
39
|
+
rake (13.0.6)
|
40
|
+
regexp_parser (2.1.1)
|
41
|
+
rexml (3.2.5)
|
42
|
+
rubocop (1.22.0)
|
43
|
+
parallel (~> 1.10)
|
44
|
+
parser (>= 3.0.0.0)
|
45
|
+
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
|
+
rexml
|
48
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
49
|
+
ruby-progressbar (~> 1.7)
|
50
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
51
|
+
rubocop-ast (1.12.0)
|
52
|
+
parser (>= 3.0.1.1)
|
53
|
+
ruby-progressbar (1.11.0)
|
54
|
+
ruby2_keywords (0.0.5)
|
55
|
+
unicode-display_width (2.1.0)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
x86_64-darwin-19
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
ax-track-ruby-client!
|
62
|
+
minitest (~> 5.0)
|
63
|
+
rake (~> 13.0)
|
64
|
+
rubocop (~> 1.7)
|
65
|
+
|
66
|
+
BUNDLED WITH
|
67
|
+
2.2.19
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Philipp Baumann
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# AxTrack
|
2
|
+
|
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
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'axTrack'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install axTrack
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
client == AxTrack::Client.new(api_key: your_api_key)
|
27
|
+
```
|
28
|
+
|
29
|
+
### Trackers
|
30
|
+
```ruby
|
31
|
+
# Get a list of all trackers
|
32
|
+
client.tracker.list
|
33
|
+
|
34
|
+
# Get the specific information of a specific tracker
|
35
|
+
client.tracker.retrieve(:tracker_id)
|
36
|
+
```
|
37
|
+
|
38
|
+
### Assets
|
39
|
+
```ruby
|
40
|
+
# Get a list of all assets
|
41
|
+
client.asset.list
|
42
|
+
|
43
|
+
# Get a specific asset
|
44
|
+
client.asset.retrieve(:asset_id)
|
45
|
+
|
46
|
+
# Update a specif asset
|
47
|
+
client.asset.update(:tracker_id, params)
|
48
|
+
#t Example: to update the name
|
49
|
+
client.tracker.update(:tracker_id, name: 'New name')
|
50
|
+
```
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/axTrack.
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
65
|
+
|
66
|
+
## Open development
|
67
|
+
* Pagination for development
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/axTrack.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/axTrack/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ax-track-ruby-client"
|
7
|
+
spec.version = AxTrack::VERSION
|
8
|
+
spec.authors = ["Philipp Baumann"]
|
9
|
+
spec.email = ["philipp@timly.ch"]
|
10
|
+
|
11
|
+
spec.summary = "API Wrapper for AX Track (from Adnexo)."
|
12
|
+
spec.description = "Official library for the AX Track application."
|
13
|
+
spec.homepage = "https://ax-track.ch/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.4.0"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/adnexo-GmbH/ax-track-ruby-client"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/adnexo-GmbH/ax-track-ruby-client/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
|
33
|
+
spec.add_dependency "faraday", "~> 1.7"
|
34
|
+
spec.add_dependency "faraday_middleware", "~> 1.1"
|
35
|
+
|
36
|
+
# For more information and examples about making a new gem, checkout our
|
37
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
38
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "AxTrack"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
module AxTrack
|
5
|
+
|
6
|
+
class Client
|
7
|
+
# include HttpStatusCodes
|
8
|
+
# include ApiExceptions
|
9
|
+
|
10
|
+
BASE_URL = 'https://prod.api.ax-track.ch/api/v1'.freeze
|
11
|
+
|
12
|
+
attr_reader :api_key, :adapter
|
13
|
+
def initialize(api_key: ENV['AXTRACK_API_KEY'], adapter: Faraday.default_adapter)
|
14
|
+
@api_key = api_key
|
15
|
+
@adapter = adapter
|
16
|
+
end
|
17
|
+
|
18
|
+
def trackers
|
19
|
+
TrackerResource.new(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def assets
|
24
|
+
AssetResource.new(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def connection
|
28
|
+
@connection ||= Faraday.new(BASE_URL) do |conn|
|
29
|
+
#conn.request :url_encoded
|
30
|
+
conn.request :json
|
31
|
+
conn.response :json, content_type: 'application/json'
|
32
|
+
conn.adapter Faraday.default_adapter
|
33
|
+
conn.headers['Authorization'] = "Token #{api_key}" unless api_key.empty?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AxTrack
|
2
|
+
class Collection
|
3
|
+
attr_reader :data, :total, :next_cursor, :prev_cursor
|
4
|
+
|
5
|
+
# key is the subset of the json_response for which to create an array
|
6
|
+
# type is the class Type to wrap the results from key
|
7
|
+
def self.from_response(json_response, key:, type: )
|
8
|
+
body = json_response.body
|
9
|
+
new(
|
10
|
+
data: body[key].map { |attrs| type.new(attrs ) },
|
11
|
+
total: body.dig('count'),
|
12
|
+
next_cursor: body.dig('next'),
|
13
|
+
prev_cursor: body.dig('previous')
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize (data:, total:, next_cursor:, prev_cursor:)
|
18
|
+
@data = data
|
19
|
+
@total = total
|
20
|
+
@next_cursor = next_cursor.nil? || next_cursor.empty? ? nil : next_cursor
|
21
|
+
@prev_cursor = prev_cursor.nil? || prev_cursor.empty? ? nil : prev_cursor
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module AxTrack
|
4
|
+
class Object
|
5
|
+
|
6
|
+
# pass in an array for getters which should be generated.
|
7
|
+
# if nothing is passed in, it will create an instance variable for all instance variables.
|
8
|
+
def create_getters(required_getter_methods = instance_variables.map { |attr_name| attr_name[1..-1 ]})
|
9
|
+
required_getter_methods.each do |attr|
|
10
|
+
singleton_class.send :attr_reader, attr unless self.respond_to? attr
|
11
|
+
# define_singleton_method(v.to_s.tr('@','')) do
|
12
|
+
# instance_variable_get(v)
|
13
|
+
# end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AxTrack
|
2
|
+
class Asset < Object
|
3
|
+
|
4
|
+
def initialize(json_response)
|
5
|
+
# for each key create an own instance variable with a getter
|
6
|
+
json_response.each do |key, value|
|
7
|
+
instance_variable_set "@#{key}", value
|
8
|
+
end
|
9
|
+
|
10
|
+
create_getters
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module AxTrack
|
2
|
+
class Tracker < Object
|
3
|
+
|
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')
|
11
|
+
@last_message_timestamp = DateTime.parse(json_response['last_message_timestamp'], false) if json_response['last_message_timestamp']
|
12
|
+
@url = json_response['url']
|
13
|
+
@last_gps_position = GPSPosition.new(json_response['last_gps_measurement'] || json_response['asset_details'])
|
14
|
+
|
15
|
+
@battery = json_response.dig('asset_details', 'sensor_data', 'battery', 'value')
|
16
|
+
|
17
|
+
sensor_data = json_response.dig('asset_details', 'sensor_data')
|
18
|
+
sensor_data.delete('battery')
|
19
|
+
@sensor_data = sensor_data
|
20
|
+
|
21
|
+
create_getters
|
22
|
+
end
|
23
|
+
|
24
|
+
class GPSPosition < Object
|
25
|
+
|
26
|
+
def initialize(json_response)
|
27
|
+
@lat = json_response['lat']
|
28
|
+
@lng = json_response['lng']
|
29
|
+
@timestamp = DateTime.parse(json_response['timestamp'], false) if json_response['timestamp']
|
30
|
+
|
31
|
+
create_getters
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
module AxTrack
|
3
|
+
class Resource
|
4
|
+
attr_reader :client, :response
|
5
|
+
|
6
|
+
GithubAPIError = Class.new(StandardError)
|
7
|
+
BadRequestError = Class.new(GithubAPIError)
|
8
|
+
UnauthorizedError = Class.new(GithubAPIError)
|
9
|
+
ForbiddenError = Class.new(GithubAPIError)
|
10
|
+
ApiRequestsQuotaReachedError = Class.new(GithubAPIError)
|
11
|
+
NotFoundError = Class.new(GithubAPIError)
|
12
|
+
UnprocessableEntityError = Class.new(GithubAPIError)
|
13
|
+
ApiError = Class.new(GithubAPIError)
|
14
|
+
|
15
|
+
HTTP_OK_CODE = 200
|
16
|
+
|
17
|
+
HTTP_BAD_REQUEST_CODE = 400
|
18
|
+
HTTP_UNAUTHORIZED_CODE = 401
|
19
|
+
HTTP_FORBIDDEN_CODE = 403
|
20
|
+
HTTP_NOT_FOUND_CODE = 404
|
21
|
+
HTTP_UNPROCESSABLE_ENTITY_CODE = 429
|
22
|
+
|
23
|
+
def initialize(client)
|
24
|
+
@client = client
|
25
|
+
@response = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def request(http_method: :get, endpoint:, headers: {}, params: {}, body: {}, result_subset: nil)
|
29
|
+
raise "Client not defined" unless defined? @client
|
30
|
+
endpoint = endpoint + "/" unless endpoint[-1] == "/"
|
31
|
+
@response = client.connection.public_send(http_method, endpoint, params.merge(body))
|
32
|
+
|
33
|
+
unless response_successful?
|
34
|
+
raise error_class(response.status), "Code: #{response.status}, response: #{response.reason_phrase}"
|
35
|
+
end
|
36
|
+
|
37
|
+
result_subset ? response[result_subset.to_s] : response
|
38
|
+
end
|
39
|
+
|
40
|
+
def error_class(status)
|
41
|
+
case status
|
42
|
+
when HTTP_BAD_REQUEST_CODE
|
43
|
+
BadRequestError
|
44
|
+
when HTTP_UNAUTHORIZED_CODE
|
45
|
+
UnauthorizedError
|
46
|
+
when HTTP_FORBIDDEN_CODE
|
47
|
+
ForbiddenError
|
48
|
+
when HTTP_NOT_FOUND_CODE
|
49
|
+
NotFoundError
|
50
|
+
when HTTP_UNPROCESSABLE_ENTITY_CODE
|
51
|
+
UnprocessableEntityError
|
52
|
+
else
|
53
|
+
ApiError
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def response_successful?
|
58
|
+
response.status == HTTP_OK_CODE
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module AxTrack
|
2
|
+
class AssetResource < Resource
|
3
|
+
|
4
|
+
def list(per_page: nil, cursor: nil)
|
5
|
+
Collection.from_response response = request(endpoint: "assets",
|
6
|
+
params: {per_page: per_page, cursor: cursor}.compact),
|
7
|
+
key: 'results',
|
8
|
+
type: Asset
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(asset_id)
|
12
|
+
Asset.new request(http_method: :get,
|
13
|
+
endpoint: "assets/#{asset_id}").body
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(asset_id, **attributes)
|
17
|
+
Asset.new request(http_method: :patch,
|
18
|
+
endpoint: "assets/#{asset_id}",
|
19
|
+
body: attributes).body
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module AxTrack
|
2
|
+
class TrackerResource < Resource
|
3
|
+
|
4
|
+
def list(per_page: nil, cursor: nil)
|
5
|
+
Collection.from_response response = request(endpoint: "trackers",
|
6
|
+
params: {per_page: per_page, cursor: cursor}.compact),
|
7
|
+
key: 'results',
|
8
|
+
type: Tracker
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve(tracker_id)
|
12
|
+
Tracker.new request(http_method: :get,
|
13
|
+
endpoint: "trackers/#{tracker_id}").body
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/axTrack.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "axTrack/version"
|
4
|
+
|
5
|
+
module AxTrack
|
6
|
+
autoload :Client, 'axTrack/client'
|
7
|
+
autoload :Collection, 'axTrack/collection'
|
8
|
+
autoload :Error, 'axTrack/error'
|
9
|
+
autoload :Object, 'axTrack/object'
|
10
|
+
autoload :Resource, 'axTrack/resource'
|
11
|
+
|
12
|
+
autoload :Tracker, 'axTrack/objects/tracker'
|
13
|
+
autoload :Asset, 'axTrack/objects/asset'
|
14
|
+
|
15
|
+
autoload :TrackerResource, 'axTrack/resources/tracker_resource'
|
16
|
+
autoload :AssetResource, 'axTrack/resources/asset_resource'
|
17
|
+
|
18
|
+
class TrackerData < Object; end
|
19
|
+
class TrackersList < Object; end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ax-track-ruby-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Philipp Baumann
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
description: Official library for the AX Track application.
|
42
|
+
email:
|
43
|
+
- philipp@timly.ch
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".github/workflows/main.yml"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rubocop.yml"
|
51
|
+
- CHANGELOG.md
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- axTrack.gemspec
|
58
|
+
- bin/console
|
59
|
+
- bin/setup
|
60
|
+
- lib/axTrack.rb
|
61
|
+
- lib/axTrack/client.rb
|
62
|
+
- lib/axTrack/collection.rb
|
63
|
+
- lib/axTrack/error.rb
|
64
|
+
- lib/axTrack/object.rb
|
65
|
+
- lib/axTrack/objects/asset.rb
|
66
|
+
- lib/axTrack/objects/tracker.rb
|
67
|
+
- lib/axTrack/resource.rb
|
68
|
+
- lib/axTrack/resources/asset_resource.rb
|
69
|
+
- lib/axTrack/resources/tracker_resource.rb
|
70
|
+
- lib/axTrack/version.rb
|
71
|
+
homepage: https://ax-track.ch/
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata:
|
75
|
+
homepage_uri: https://ax-track.ch/
|
76
|
+
source_code_uri: https://github.com/adnexo-GmbH/ax-track-ruby-client
|
77
|
+
changelog_uri: https://github.com/adnexo-GmbH/ax-track-ruby-client/CHANGELOG.md
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.4.0
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.1.4
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: API Wrapper for AX Track (from Adnexo).
|
97
|
+
test_files: []
|