Ruby Gem for the One Hour API v2. Not affiliated with One Hour Translation. Use at your own risk.
Add this line to your application's Gemfile:
gem 'one_hour_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install one_hour_api
require 'one_hour_api'
API_KEY=...
API_SECRET=...
client = OneHourApi::Client.new(API_KEY, API_SECRET)
Endpoint: /api/2/account
client.Account.get
# { credits: "100", account_id: "1", account_username: "you", role: "customer", uuid: "85284b85-8e04-42d1-86d0-934ff62193be" }
Endpoint: /api/2/tm/context
- list, add, remove contexts
Endpoint: /api/2/tm/context/:id/phrases
- list / add / remove phrases
- add (existing) translation
- invalidate translation
Endpoint: api/2/tm/context/:id/translate/:from/:to
- request translation for new phrases and invalidated translations
The API responses can be mocked, so that you can test your integration.
require 'one_hour_api/mock'
client = OneHourApi::Mock::Client.new
client.Account.get # returns mock account info
The goal is for the mocks to maintain state, so that if e.g. you call client.Context.create(x)
, a subsequent call to client.Context.all
returns [x].
Todo:
- mock list, add, remove contexts
- mock creating a translation project, simulate human translators completing project
- mock adding / removing phrases, adding and invalidating translations
- ...
This Gem is heavily inspired by the Jira Gem.
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/guard
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment. 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 tags, and push the .gem
file to rubygems.org.