Commit b174b1dede0af9e5d24b24c7dff3c17c0181e2bf

Authored by Fernando Brito
1 parent 2c8fb95f
Exists in master and in 2 other branches v2, wikilibras

ApiClient

lib/api_client.rb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +class ApiClient
  2 + API_URL = 'http://150.165.204.30:5000/api'
  3 +
  4 + def self.check_status
  5 + begin
  6 + ApiClient::Client.post(ApiClient::API_URL)
  7 + rescue
  8 + return false
  9 + end
  10 +
  11 + return true
  12 + end
  13 +
  14 +end
... ...
lib/api_client/client.rb 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +require 'httparty'
  2 +
  3 +module ApiClient::Client
  4 + include HTTParty
  5 + default_timeout 10 * 60
  6 +
  7 + def self.submit(request)
  8 + request.update(status: 'processing')
  9 +
  10 + options = { query: request.params }
  11 +
  12 + Delayed::Worker.logger.debug "[VLibras::Request] Options: #{options}"
  13 +
  14 + binding.pry
  15 +
  16 + response = self.post(url_with_service('texto'), { query: { texto: 'bola', transparencia: 'opaco' } })
  17 +
  18 + Delayed::Worker.logger.debug "[VLibras::Request] Status #{response.response.code}"
  19 +
  20 + if response.response.code == '200'
  21 + request.create_video(:url => response.parsed_response['response'])
  22 + request.update(:status => 'success')
  23 + else
  24 + request.update(:response => response.body, :status => 'error')
  25 + end
  26 + end
  27 +
  28 +private
  29 + def self.url_with_service(service)
  30 + URI.encode("#{ApiClient::API_URL}?servico=#{service}")
  31 + end
  32 +end
0 33 \ No newline at end of file
... ...
lib/api_client/service/video.rb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +module ApiClient::Service::Video
  2 +
  3 +end
0 4 \ No newline at end of file
... ...
lib/api_client/service/video_subtitle.rb 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +class ApiClient::Service::VideoSubtitle
  2 +end
0 3 \ No newline at end of file
... ...