class Translator::Smartling::API::DownloadFile
Public Class Methods
new(project_id:, locale_id:, file_uri:, token:)
click to toggle source
# 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
Public Instance Methods
build_request()
click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb, line 14 def build_request Net::HTTP::Get.new(uri, headers) end
headers()
click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb, line 31 def headers { 'Authorization' => "Bearer #{@token}", 'Content-Type' => 'application/json' } end
return_value()
click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb, line 39 def return_value @return_value ||= @response.body end
success?()
click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb, line 35 def success? @response.code == '200' end
to_s()
click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb, line 43 def to_s "#{@file_uri} => #{@locale_id}" end
uri()
click to toggle source
# 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