Sha256: bb5c2e21a9c09931538a98e68510d3d101746649376586995f907fd8bcdc12b3

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

# Copyright 2024 DeepL SE (https://www.deepl.com)
# Use of this source code is governed by an MIT
# license that can be found in the LICENSE file.
# frozen_string_literal: true

module DeepL
  module Requests
    module Document
      class GetStatus < Base
        attr_reader :document_id, :document_key

        def initialize(api, document_id, document_key, options = {}, additional_headers = {})
          super(api, options, additional_headers)
          @document_id = document_id
          @document_key = document_key
        end

        def request
          payload = { document_key: document_key }
          build_doc_translation_status(*execute_request_with_retries(post_request(payload)))
        end

        def details
          "HTTP Headers: #{headers}\nPayload #{{ document_key: document_key }}"
        end

        def to_s
          "POST #{uri.request_uri}"
        end

        private

        def build_doc_translation_status(request, response)
          document_translation_status = JSON.parse(response.body)
          Resources::DocumentTranslationStatus.new(document_translation_status, request, response)
        end

        def path
          "document/#{document_id}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
deepl-rb-3.1.0 lib/deepl/requests/document/get_status.rb
deepl-rb-3.0.2 lib/deepl/requests/document/get_status.rb
deepl-rb-3.0.1 lib/deepl/requests/document/get_status.rb
deepl-rb-3.0.0 lib/deepl/requests/document/get_status.rb