All Projects → nateklaiber → Automatic Client

nateklaiber / Automatic Client

Licence: mit
Client wrapper for the Automatic Link

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Automatic Client

Clamor
The Python Discord API Framework
Stars: ✭ 14 (-36.36%)
Mutual labels:  wrapper, api-client
Taviloglu.Wrike.ApiClient
.NET Client for Wrike API
Stars: ✭ 24 (+9.09%)
Mutual labels:  wrapper, api-client
pastebin-csharp
API client for Pastebin in C#
Stars: ✭ 25 (+13.64%)
Mutual labels:  wrapper, api-client
Client
GitLab API v4 client for PHP
Stars: ✭ 763 (+3368.18%)
Mutual labels:  api-client
Pizzly
The simplest, fastest way to integrate your app with an OAuth API 😋
Stars: ✭ 796 (+3518.18%)
Mutual labels:  api-client
Cv4pve Api Java
Proxmox VE Client API JAVA
Stars: ✭ 17 (-22.73%)
Mutual labels:  api-client
Groovehq
Ruby gem for GrooveHQ api
Stars: ✭ 22 (+0%)
Mutual labels:  api-client
Pykaldi
A Python wrapper for Kaldi
Stars: ✭ 756 (+3336.36%)
Mutual labels:  wrapper
Algoliasearch Client Javascript
⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
Stars: ✭ 907 (+4022.73%)
Mutual labels:  api-client
F32 For Android
Android library for temperature conversions and weather forecasts. Includes wrapper for OpenWeatherMap API
Stars: ✭ 16 (-27.27%)
Mutual labels:  wrapper
Giantbomb
A PHP wrapper for GiantBomb API
Stars: ✭ 5 (-77.27%)
Mutual labels:  wrapper
Moyasar Php
Moyasar PHP client library
Stars: ✭ 5 (-77.27%)
Mutual labels:  wrapper
Sandal2
SDL2 wrapper in C
Stars: ✭ 17 (-22.73%)
Mutual labels:  wrapper
Scintillanet
A Windows Forms control, wrapper, and bindings for the Scintilla text editor.
Stars: ✭ 781 (+3450%)
Mutual labels:  wrapper
Go Git Cmd Wrapper
A simple wrapper around git command in Go.
Stars: ✭ 22 (+0%)
Mutual labels:  wrapper
Twitter
Twitter API for Laravel 5.5+, 6.x, 7.x & 8.x
Stars: ✭ 755 (+3331.82%)
Mutual labels:  api-client
Slack
🎉✨ Slack API client for Node and browsers.
Stars: ✭ 903 (+4004.55%)
Mutual labels:  api-client
Uplink
A Declarative HTTP Client for Python
Stars: ✭ 824 (+3645.45%)
Mutual labels:  api-client
Tensorflow.jl
A Julia wrapper for TensorFlow
Stars: ✭ 822 (+3636.36%)
Mutual labels:  wrapper
Laravel Bigbluebutton
A BigBlueButton API wrapper for Laravel 5
Stars: ✭ 17 (-22.73%)
Mutual labels:  wrapper

Automatic Link Client

Build Status Gem Version

A wrapper to consume the Automatic API.

Installation

Add this line to your application's Gemfile:

gem 'automatic-client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install automatic-client

Usage

The API will require an OAuth access_token to retrieve data. You will store this token in an ENV variable inside of the .env file:

API_HOST='https://api.automatic.com'
AUTOMATIC_ACCESS_TOKEN='1234'

Console

require 'automatic/client'

trips = Automatic::Models::Trips.all

# Iterate through the trips
trips.each do |trip|
  puts "trip.user #{trip.user}"
  puts "trip.vehicle #{trip.vehicle}"

  puts "trip.start_location #{trip.start_location.coordinates}"
  puts "trip.start-at #{trip.start_at}"

  puts "trip.end_location #{trip.end_location.coordinates}"
  puts "trip.end_at #{trip.end_at}"

  puts "trip.fuel_cost #{trip.fuel_cost}"
  puts "trip.fuel_cvlume #{trip.fuel_volume}"
  puts "trip.average_mpg #{trip.average_mpg}"
  puts "trip.elapsed_time #{trip.elapsed_time}"
end

You can also use this data to get aggregate statistics as you see fit.

Polylines

Automatic will provide an encoded polyline with the path attribute. This gets wrapped around the polylines gem giving us the ability to decode the polyline.

# View a trip
trip = Automatic::Client::Trips.find_by_id('trip-id')
# => #<Automatic::Client::Trip:0x007fa36aa29760 ...>

# Return the proxy object
trip.polyline
# => #<Automatic::Client::Polyline:0x007fa36aa399f8 ...>

# Return the array of latitude and longitude parts
trip.polyline.decoded
#=> [[20,-400]]

Command Line

You can also utilize a few CLI executable scripts that will allow you to:

  • View a table of the data
  • Export your trips to a CSV file

You can read more here.

Routes

The supported endpoints are stored in Automatic::Client.routes. This allows you to view all endpoints and generate a url_for the given route. Routes are comprised of either a Uri Template or full path.

require 'automatic'
# => true

# Get the URL for a templated URL with optional params
Automatic::Client.routes.route_for('trips').url_for
# => "https://api.automatic.com/v1/trips"

# Add optional parameters to expand into the URL
Automatic::Client.routes.route_for('trips').url_for(page: 1, per_page: 50)
# => "https://api.automatic.com/v1/trips?page=1&per_page=50"

# Retrieve the URI Template for a single trip route
trip_route = Automatic::Client.routes.route_for('trip')
# => #<RestlessRouter::Route:0x007f985cb7b280 @name="trip", @path="https://api.automatic.com/v1/trips/{id}", @options={:templated=>true}>

# Specify the ID for the single trip route
trip_route.url_for(id: '1234')
# => "https://api.automatic.com/v1/trips/1234"

Responsibilities

  • Configuration: Use the ENV or runtime defined configuration options.
  • Connection: Create a connection to the API Host and handle server communication.
  • Request Handling: Make requests to the API Host and handle server communication.
  • Response Handling: Consume the body of the Request and handle accordingly.
  • Error Handling: Ensure the Response error and cast to domain specific models.
  • Response Modeling: Use the Response and cast to domain specific models.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

TODO

  • Add Core Extension helpers for different data types
  • Add Serializers for all types (JSON, CSV, PDF)
  • Extract configuration into it's own object. This will allow for class and instance level configurations for things like scopes, access_token, api_host, etc. This is currently handled with global ENV vars.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].