Commit b174b1dede0af9e5d24b24c7dff3c17c0181e2bf
1 parent
2c8fb95f
Exists in
master
and in
2 other branches
ApiClient
Showing
4 changed files
with
51 additions
and
0 deletions
Show diff stats
... | ... | @@ -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 | ... | ... |