Code Monkey home page Code Monkey logo

one-hour-api-ruby's Introduction

OneHourApi Build Status Coverage Status

Ruby Gem for the One Hour API v2. Not affiliated with One Hour Translation. Use at your own risk.

Installation

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

Usage

Authentication

require 'one_hour_api'
API_KEY=...
API_SECRET=...
client = OneHourApi::Client.new(API_KEY, API_SECRET)

Account info

Endpoint: /api/2/account

client.Account.get
# { credits: "100", account_id: "1", account_username: "you", role: "customer", uuid: "85284b85-8e04-42d1-86d0-934ff62193be" }

Contexts

Endpoint: /api/2/tm/context

  • list, add, remove contexts

Phrases

Endpoint: /api/2/tm/context/:id/phrases

  • list / add / remove phrases
  • add (existing) translation
  • invalidate translation

Projects - Translate Context

Endpoint: api/2/tm/context/:id/translate/:from/:to

  • request translation for new phrases and invalidated translations

API mock

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

API endpoints not yet implemented

  • ...

Development

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.

Release

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.

one-hour-api-ruby's People

Contributors

sjors avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.