class Translator::Smartling::API::FileStatus

Public Class Methods

new(project_id:, file_uri:, token:) click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_status.rb, line 7
def initialize(project_id:, file_uri:, token:)
  @project_id   = project_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/file_status.rb, line 13
def build_request
  Net::HTTP::Get.new(uri, headers)
end
headers() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_status.rb, line 17
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/file_status.rb, line 33
def return_value
  @return_value ||= begin
    total_word_count = response_body['response']['data']['totalWordCount']
    total_string_count = response_body['response']['data']['totalStringCount']
    response_body['response']['data']['items'].map do |item|
      item['localeId'] if total_word_count == item['completedWordCount'] && total_string_count == item['completedStringCount']
    end.compact
  end
end
success?() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_status.rb, line 29
def success?
  @response.code == '200'
end
to_s() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_status.rb, line 43
def to_s
  "#{@file_uri} => #{return_value}"
end
uri() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_status.rb, line 21
def uri
  @uri ||= begin
    uri = URI("https://api.smartling.com/files-api/v2/projects/#{@project_id}/file/status")
    uri.query = URI.encode_www_form({ 'fileUri' => @file_uri })
    uri
  end
end