SeametrixRuby
Unofficial ruby gem for Seametrix API.
Installation
Add this line to your application's Gemfile:
gem 'seametrix_ruby', git: 'https://github.com/adiwids/seametrix_ruby.git', branch: 'master', require: 'seametrix'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install seametrix_ruby
Usage
:anchor: Ports Service
Search ports by LOCODE or port name (min. 3 characters of LOCODE or port name).
port_result = Seametrix::Ports.get('MTX')
port_result
is an instance of PortResult class, plain Ruby object version of JSON response.
:map: Routes Service
legs = [
["-101.123456, 14.772125", "117.443101, 1.123456"]
]
route_requests = legs.map do |leg|
start_coord, end_coord = leg
start_lon, start_lat = start_coord.split(',').map(&:strip)
end_lon, end_lat = start_coord.split(',').map(&:strip)
attrs = {
start_lon: start_lon,
start_lat: start_lat,
end_lon: end_lon,
end_lat: end_lat
}
SeametrixRuby::Requests::RouteRequest.new(attrs)
end
route_result = Seametrix::Routes.get(route_requests)
route_result
is an instance of RouteResult class, plain Ruby object version of JSON response.
Configuration
Seametrix.configure do |config|
config.base_url = "<URL of API endpoint> or see Configuration::DEFAULT_BASE_URL value"
config.access_key = "validAccessKey"
config.logger = Logger.new(STDOUT)
config.debugging = false
end
Test
$ bundle exec rake test
Supported Ruby Versions
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/adiwids/seametrix_ruby. This project is intended to be a safe, and welcoming space for collaboration.
- Fork this repository to your Github's.
- Create feature branch
git checkout -b feature/feature_name
. - Commit your changes with descriptive commit message.
- Push to the branch to the forked repository on your Github.
- Create a Pull Request.
License
The gem is available as open source under the terms of the MIT License.
Credits