module Itranslate4

Constants

SERVICE_URL

Attributes

configuration[RW]

Public Class Methods

configure() { |configuration| ... } click to toggle source
# File lib/itranslate4.rb, line 10
def self.configure
  self.configuration ||= Configuration.new
  yield(self.configuration)
end
get_providers() click to toggle source
# File lib/itranslate4.rb, line 48
def self.get_providers
        Itranslate4.send_request :get, "#{SERVICE_URL}/GetProviders?auth=#{Itranslate4.configuration.key}"
end
get_routes(src, trg) click to toggle source
# File lib/itranslate4.rb, line 43
def self.get_routes(src, trg)
        Itranslate4.send_request :get, "#{SERVICE_URL}/GetRoutes?auth=#{Itranslate4.configuration.key}",
        {src: src, trg:trg}.as_json
end
languages() click to toggle source
# File lib/itranslate4.rb, line 39
def self.languages
        Itranslate4.send_request :get, "#{SERVICE_URL}/GetLanguages?auth=#{Itranslate4.configuration.key}"
end
parse_response(response) click to toggle source
# File lib/itranslate4.rb, line 30
        def self.parse_response(response)
        { code: response.code, body: response.body.empty? ? '' : JSON.parse(response.body, symbolize_names: true) }
end
send_request(method, url, params={}) click to toggle source
# File lib/itranslate4.rb, line 23
def self.send_request(method, url, params={})
  response = RestClient::Request.execute(method: method, url: url, headers: {params: params})
  self.parse_response(response)
rescue => e
  self.parse_response(e.response)
end
translate(src, trg, dat='',rid=nil) click to toggle source
# File lib/itranslate4.rb, line 34
def self.translate(src, trg, dat='',rid=nil)
        Itranslate4.send_request :get, "#{SERVICE_URL}/Translate?auth=#{Itranslate4.configuration.key}",
        {src: src, trg:trg, dat: dat, rid:rid}.as_json
end