Class: Translator::Smartling::API::DownloadFile
- Inherits:
-
Object
- Object
- Translator::Smartling::API::DownloadFile
show all
- Includes:
- Base
- Defined in:
- lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
Instance Method Summary
collapse
Methods included from Base
#call, #cleanup, #error, included, #make_request!, #response_body
Constructor Details
#initialize(project_id:, locale_id:, file_uri:, token:) ⇒ DownloadFile
Returns a new instance of DownloadFile.
7
8
9
10
11
12
|
# File 'lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb', line 7
def initialize(project_id:, locale_id:, file_uri:, token:)
@project_id = project_id
@locale_id = locale_id
@file_uri = file_uri
@token = token
end
|
Instance Method Details
#build_request ⇒ Object
14
15
16
|
# File 'lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb', line 14
def build_request
Net::HTTP::Get.new(uri, )
end
|
31
32
33
|
# File 'lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb', line 31
def
{ 'Authorization' => "Bearer #{@token}", 'Content-Type' => 'application/json' }
end
|
#return_value ⇒ Object
39
40
41
|
# File 'lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb', line 39
def return_value
@return_value ||= @response.body
end
|
#success? ⇒ Boolean
35
36
37
|
# File 'lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb', line 35
def success?
@response.code == '200'
end
|
#to_s ⇒ Object
43
44
45
|
# File 'lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb', line 43
def to_s
"#{@file_uri} => #{@locale_id}"
end
|
#uri ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb', line 18
def uri
@uri ||= begin
uri = URI("https://api.smartling.com/files-api/v2/projects/#{@project_id}/locales/#{@locale_id}/file")
uri.query = URI.encode_www_form(
{
'fileUri' => @file_uri,
'retrievalType' => 'published',
}
)
uri
end
end
|