Sha256: 1177c12dac58585ea120d528dd148c31a3eee71feac194d6f83d74f11151583d

Contents?: true

Size: 1.12 KB

Versions: 80

Compression:

Stored size: 1.12 KB

Contents

module Translator
  module Smartling
    module API
      class DownloadFile
        include Base

        def initialize(project_id:, locale_id:, file_uri:, token:)
          @project_id   = project_id
          @locale_id    = locale_id
          @file_uri     = file_uri
          @token        = token
        end

        def build_request
          Net::HTTP::Get.new(uri, headers)
        end

        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

        def headers
          { 'Authorization' => "Bearer #{@token}", 'Content-Type' => 'application/json' }
        end

        def success?
          @response.code == '200'
        end

        def return_value
          @return_value ||= @response.body
        end

        def to_s
          "#{@file_uri} => #{@locale_id}"
        end
      end
    end
  end
end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
station-0.5.16 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.15 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.14 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.13 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.12 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.11 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.10 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.9 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.8 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.7 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.6 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.5 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.4 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.3 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.2 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.1 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.5.0 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.4.9 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.4.8 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb
station-0.4.7 lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb