Sha256: ddefdc9de204ce3b3a587053fcdc67401a0cdac99f563f209cdecb4f27f2ffd9

Contents?: true

Size: 852 Bytes

Versions: 4

Compression:

Stored size: 852 Bytes

Contents

# Copyright 2021 Daniel Herzog
# Use of this source code is governed by an MIT
# license that can be found in the LICENSE.md file.
# frozen_string_literal: true

module DeepL
  module Requests
    class Languages < Base
      def initialize(api, options = {})
        super
      end

      def request
        build_languages(*execute_request_with_retries(get_request))
      end

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

      private

      def build_languages(request, response)
        data = JSON.parse(response.body)
        data.map do |language|
          Resources::Language.new(language['language'], language['name'],
                                  language['supports_formality'],
                                  request, response)
        end
      end

      def path
        'languages'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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