Vizion
Vizion is a ruby gem client library for talking to VIZION API built using OpenStruct so you can easily access data in a Ruby-ish way.
Installation
Add this line to your application’s Gemfile:
gem 'vizion'
And then execute:
bundle
Or install it yourself as:
gem install vizion
Usage
You’ll need to generate an api key: https://vizionapi.com/sign-up Initialize client and making request:
require 'vizion'
client = Vizion::Client.new(api_key: "X-API-Key", timeout: 10)
client.carriers
Resources
Carriers
List of all supported carriers, to view the list click here.
Actions supported:
client.carriers.list
References
Actions supported:
client.references.list
client.references.retrieve(id)
client.references.updates(id)
client.references.create({})
client.references.delete(id)
Pagination
Use the page
query parameter to set the current page (default: 1)
Use the per_page
query parameter to set a per page limit (default: 25)
client.references.list(per_page: 10, page:2)
Create Reference with Auto Carrier Identification.
Add container reference for update tracking without a carrier code. To do this, provide only a container_id with in the body request payload. Please note, it will always be faster and more accurate to provide a carrier code when you can.
VIZION API will periodically check for updates and send updates via HTTP POST to the provided callback_url
parameter.
Raw body
{
"container_id": "CMAU4049810",
"callback_url": "https://yourdomain.com/webhook"
}
Ruby way
client.references.create(container_id: "CMAU4049810", callback_url: "https://yourdomain.com/webhook")
Create Reference with Carrier Code
Add container reference for update tracking using a carrier code.
Raw body
{
"container_id": "CAIU4482704",
"carrier_code": "HDMU",
"callback_url": "https://yourdomain.com/webhook"
}
Ruby way
client.references.create(container_id: "CMAU4049810", carrier_code: "HDMU", callback_url: "https://yourdomain.com/webhook")
If no callback_url parameter is provided, you will need to fetch status updates from the reference_updates action.
Contributing
Everyone is encouraged to help improve this project. Bug reports and pull requests are welcome at https://github.com/vertilux/vizion/pulls. Feel free to open an issue to get feedback on your idea before spending too much time on it.
License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).