VersaFleet API
You'll need a VersaFleet account to use the API, if you don't have one visit the VersaFleet website for more information.
Installation
Add versafleet
to your application's Gemfile:
bundle add versafleet
# OR in the Gemfile
gem "versafleet"
Usage
To access the API, you'll need to create a Versafleet::Client
and pass in your API Key and Secret Key. See How to obtain API keys
client = Versafleet::Client.new(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
The client then gives you access to each of resources.
Resources
Jobs
# list jobs with per page is 20
client.jobs.list(per_page: 20)
# view the a job details
client.jobs.retrieve(job_id: "id")
# create a job
client.jobs.create(job: {})
# update job
client.jobs.update(job_id: "id", job: {})
# cancel the job
client.jobs.cancel(job_id: "id")
# list tasks of job
client.jobs.list_tasks(job_id: "id")
Tasks
# list all tasks
client.tasks.list
# list all tasks by state
client.tasks.list_by_state(state: state)
# get the task details
client.tasks.retrieve(task_id: task_id)
# get the task by tracking id
client.tasks.retrieve_by_tracking_id(tracking_id: tracking_id)
# update the task
client.tasks.update(task_id: task_id, task_attributes: {})
# add a task to job
client.tasks.create(task_attributes: {})
# assign task to driver
client.tasks.assign(task_id: task_id, task: {driver_id: driver_id, vehicle_id: vehicle_id, remarks: "Notes"})
# assign multiple tasks to driver
client.tasks.assign_multiple(task: {ids: [], driver_id: driver_id, vehicle_id: vehicle_id, remarks: "Notes")
# unassign task
client.tasks.unassign(task_id: task_id)
# unassign multiple tasks
client.tasks.unassign_multiple(task: {ids: []})
# cancel the task
client.tasks.cancel(task_id: task_id)
# complete the task
client.tasks.complete(task_id: task_id)
# incomplete the task
client.tasks.incomplete(task_id: task_id)
# set state to the task
client.tasks.set_state(task_id: task_id, to_state: to_state)
# archive the task
client.tasks.archive(task_id: task_id)
# unarchive the task
client.tasks.unarchive(task_id: task_id)
# allocate task to transporter
client.tasks.allocate(task_id: task_id, sub_account_id: sub_account_id)
# get the task completion histories
client.tasks.completion_histories(task_id: task_id)
# get the base task completion histories
client.tasks.base_completion_histories(task_id: task_id)
TO DO
- [ ] Add API Documentation
- [ ] Add Docker support
- [ ] Support to All VersaFleet API endpoints.
🙏 Contributing
This project uses Standard for formatting Ruby code. Please make sure to run standardrb before submitting pull requests. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
Code of Conduct
Everyone interacting in the VersaFleet project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
License
The gem is available as open source under the terms of the MIT License.